Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Script Help. (https://forums.graalonline.com/forums/showthread.php?t=36675)

nyghtGT 08-26-2002 09:17 PM

Script Help.
 
Well, i'm trying to get this so that when a player gets online he adds his account name to a string and then an NPC checks that string and if the players online don't match the names in the string, a little message saying, "Player <accout namr> has left game."

Currently I Have:
NPC Code:

tokenize2 ,,,#s(this.logged);
for (i=0;i<tokenscount;i++) {
this.found=false;
with (getplayer(#t(i))) this.found=true;
if (this.found==false) {
deletestring this.logged,#t(i);
setstring this.temp,#t(i);
for (p=0;p<allplayerscount;p++){
with (allplayers[p]) {
insertstring client.messages,0,Player #s(this.temp) left the game.;
}
}
}
}
}
if (this.count!=allplayerscount){
for(i=0;i<allplayerscount;i++){
with(allplayers[i]){
this.gotten=false;
for (j=0;j<tokenscount;j++;){
if (strequals(#a,#t(j))) this.gotten=true;
}
if (strlen(#F)>0){
if (this.gotten==false) {
addstring this.logged,#a;
}
} else {setplayerprop #3,headrc.png;}
}
}
}
this.count=allplayerscount;
timeout=.1;


Any help or input would be appreciated.

BTW, this is all serverside database NPCs.

emortylone 08-26-2002 11:37 PM

LOL, the way I was considering doing something like this was:
[code]
if (actionplayeronline)
{ setstring this.online,#s(this.online),#a;
timeout=1;
}
if (timeout)
{ tokenize2 ,,#s(this.online);
for (i=0;i<tokenscount;i++)
{ with (getplayer(#t(i)))
{ if (!playerisonline)
{ actions to show that they are not online;
for (o=0;o<tokenscount;o++)
{ deletestring this.online,#s(this.online)-#t(i);}
}
}
}
}
---Shifter
gtg bell rang!

screen_name 08-27-2002 06:54 AM

if (actionplayeronline) { << - Put this in the Control NPC, then add it to the string and check the name, etc etc

Bhala 08-27-2002 08:03 AM

There is an easyer way of check if a string is in a string array. Do this:

if(lindexof(str,strarray)>-1)

thats to check if it is in a string array

if(lindexof(str,strarray)=-1)

checks if it isnt in a string array

screen_name 08-27-2002 08:44 AM

I loved it when Stefan released string arrays.
Before that I had to:

NPC Code:

tokenize #s(bla);
for (this.i=0;this.i<tokenscount;this.i++) {
if (this.found==0 && strequals(#a,#t(this.i))) {
this.found = 1;
// Other stuff here
}
}



All that code compacted into one little bit of code. :p


All times are GMT +2. The time now is 06:03 PM.

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