Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-16-2007, 03:15 AM
Knightmare1 Knightmare1 is offline
Billy Allan
Knightmare1's Avatar
Join Date: Apr 2007
Posts: 804
Knightmare1 can only hope to improve
chat.substring?

i was wonderng, how does this work? i do tons of scripting, and yet if i come across a chat.substring i give one of my friends the script so they fix it, but i wanna find out how to do it myself.
__________________
I am the devil, I am here to do to devils work.
Reply With Quote
  #2  
Old 11-16-2007, 03:23 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
It uses everything in the player's chat or w.e after the number in ().
Example:
PHP Code:
function onActionServerSide() {
 if (
params[0] == ":ap") {
  
with(findplayer
 
}
}
//#CLIENTSIDE
function onPlayerChats() {
 if (
player.chat.starts(":ap") {
  
triggerserver("gui",this.name,":ap",player.account,player.chat.substring(6).trim);
 }

Would set the player using the weapon's AP as the player's chat at/after the 6th letter of the players chat, and if there's a space there, going to the letter after it.
Atleast, I think so.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #3  
Old 11-16-2007, 03:38 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Uh, trim() is a function not a variable. Also substring() can be used two ways, the first being like you said.

variable.substring(index);

The index being the index of the character you want to start the substring at. The second way being:

variable.substring(index, length);

Length is the amount of characters after the index that you want included in the substring, you can use a length of -1 for all characters.

"abcdefghi".substring(4) == "efghi";
"abcdefghi".substring(4, -1) == "efghi";
"abcdefghi".substring(3, 3) = "def";
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:38 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.