Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   chat.substring? (https://forums.graalonline.com/forums/showthread.php?t=77580)

Knightmare1 11-16-2007 03:15 AM

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.

Switch 11-16-2007 03:23 AM

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.

Inverness 11-16-2007 03:38 AM

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";


All times are GMT +2. The time now is 05:39 AM.

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