Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   deletestring (serverside) (https://forums.graalonline.com/forums/showthread.php?t=40409)

Com013 11-17-2002 10:15 PM

deletestring (serverside)
 
Quote:

commands.rtf
deletestring list,index; deletes string list entry at position 'index'
It is not working correctly. I said it should delete index 1, but it removed index 0.
Now I have to use this:
NPC Code:

// deletestring clientr.hats,hatnum;

setstring temp,;
for (i=0; i<sarraylen(clientr.hats); i++) {
if (i != hatnum) addstring temp,#I(clientr.hats,i);
}
setstring clientr.hats,#s(temp);
setstring temp,;



I don't know whether it is working clientside/offline.

Tyhm 11-18-2002 06:48 AM

...you're starting at the highest index and working down, right?
Otherwise you're gonna skip every other index...
Delete 0
Index 1 becomes Index 0, 2 becomes 1, etc.
Delete 1 (formerly index 2...)
Delete 2 (formerly index 4...)

Com013 11-20-2002 02:34 AM

Quote:

Originally posted by Tyhm
...you're starting at the highest index and working down, right?
Otherwise you're gonna skip every other index...
Delete 0
Index 1 becomes Index 0, 2 becomes 1, etc.
Delete 1 (formerly index 2...)
Delete 2 (formerly index 4...)

Sorry, what are you talking about?
Do you mean that I used deletestring the wrong way? I didn't even use it in a loop.
Are you talking about the script I am using as replacement? I just copied every thing else into another string.

Admins 12-02-2002 02:49 AM

I am using deletestring for many things and its working, can you post some code example?

Com013 12-02-2002 03:01 AM

I don't want to publish it here.
It is on Classic Developement, Weapons, -System/Trading.

I have put "//" in front of the deletestring command.
The following six lines are what fixed it. (I rescripted the deletestring command).

CheeToS2 12-02-2002 03:14 AM

Quote:

Originally posted by Com013
I don't want to publish it here.
It is on Classic Developement, Weapons, -System/Trading.

I have put "//" in front of the deletestring command.
The following six lines are what fixed it. (I rescripted the deletestring command).

nice 6 lines :o

Com013 12-02-2002 03:37 AM

Quote:

Originally posted by CheeToS2


nice 6 lines :o

What do you mean? I published those six lines in my start post of this thread.

Admins 12-02-2002 11:07 PM

Arg you are using 'temp' ? that will send a lot of data to the player x-x And it still doesnt tell me what should be wrong. A code example of the bug would be good

CheeToS2 12-03-2002 03:28 AM

Quote:

Originally posted by Com013

What do you mean? I published those six lines in my start post of this thread.

Oh.. you said the following 6 lines.. but they didn't follow that text.. so :eek: :D

Loriel 12-03-2002 05:23 AM

Quote:

Originally posted by Stefan
Arg you are using 'temp' ? that will send a lot of data to the player x-x
Well, you could always code the server so it does not send data to the client which it cannot read/edit anyways.

Com013 12-04-2002 11:43 PM

Quote:

Originally posted by Stefan
Arg you are using 'temp' ? that will send a lot of data to the player x-x And it still doesnt tell me what should be wrong. A code example of the bug would be good
Ok, now I am using this.temp, but we are going off-topic here.
Tyhm told me sometime that only LATs are allowed to see the scripts used on Classic, so I won't post it here, but, like I wrote before, you can look at it on Classic Developement, it's in the -System/Trading weapon.
(I tried sending it to you using a PM, but it was 10 times too huge for a forum PM).

However, this is a very short version of it:
NPC Code:

if (actionserverside) {
hatnum = strtofloat(#p(0));
putnpc2 playerx,playery+2,{join hats;};
with (npcs[npcscount-1]) {
this.hat = strtofloat(#I(clientr.hats,hatnum));
deletestring clientr.hats,hatnum; // <- always delets #0
callnpc -1,updategani;
}
}
//#CLIENTSIDE
if (weaponfired) triggeraction 0,0,serverside,DeleteTest,2;



Quote:

Originally posted by CheeToS2
Oh.. you said the following 6 lines.. but they didn't follow that text
No, I meant the following six lines in the script and not in my post.

Loriel 12-04-2002 11:49 PM

Quote:

Originally posted by Com013
NPC Code:

if (actionserverside) {
hatnum = strtofloat(#p(0));
putnpc2 playerx,playery+2,{join hats;};
with (npcs[npcscount-1]) {
this.hat = strtofloat(#I(clientr.hats,hatnum));
deletestring clientr.hats,hatnum; // <- always delets #0
callnpc -1,updategani;
}
}
//#CLIENTSIDE
if (weaponfired) triggeraction 0,0,serverside,DeleteTest,2;


Variables like those are local to a certain NPC.

Com013 12-04-2002 11:56 PM

Quote:

Originally posted by Loriel

Variables like those are local to a certain NPC.

They don't start with this., so NO!

And:
NPC Code:

with (npcs[npcscount-1]) {
this.hat = strtofloat(#I(clientr.hats,hatnum)); // <- this works
deletestring clientr.hats,hatnum; // <- this doesn't
}


Kaimetsu 12-05-2002 12:05 AM

Personally I just wouldn't use a string array, though it depends on how many of each hat you want to allow people to have. If you use ascii() and #K() then you can compact numbers over a fairly large range into a single byte, and then just use a normal string with one character per hat.

Admins 12-05-2002 12:21 AM

Variables like hatnum are local, belonging to the current script, so you can use hatnum like you have written, and it works. You have problems when calling functions of joined classes, because those don't know of the local variables of the other script.

Admins 12-05-2002 12:40 AM

I will update & restart the npcservers on that machine, it seems to be quite buggy (the weapons are not saved).

Loriel 12-05-2002 12:55 AM

Quote:

Originally posted by Com013
NPC Code:

if (actionserverside) {
hatnum = strtofloat(#p(0));
putnpc2 playerx,playery+2,{join hats;};
with (npcs[npcscount-1]) {
this.hat = strtofloat(#I(clientr.hats,hatnum));
deletestring clientr.hats,hatnum; // <- always delets #0
callnpc -1,updategani;
}
}
//#CLIENTSIDE
if (weaponfired) triggeraction 0,0,serverside,DeleteTest,2;


He is not using classes there, Stefan... :\

Com013 12-05-2002 03:23 AM

Quote:

Originally posted by Kaimetsu
Personally I just wouldn't use a string array, though it depends on how many of each hat you want to allow people to have. If you use ascii() and #K() then you can compact numbers over a fairly large range into a single byte, and then just use a normal string with one character per hat.
Sounds good. But lazy as I am, I'd like Stefan to fix the deletestring command. ;)

Quote:

Originally posted by Stefan
Variables like hatnum are local, belonging to the current script, so you can use hatnum like you have written, and it works. You have problems when calling functions of joined classes, because those don't know of the local variables of the other script.
Yes, the classes I made are only accessing this.variables when they need data from the main script.
But here I am not calling a joined function. Here it looks like deletestring is always deleting number zero, no matter what I command it to delete.

I will test what happens when I enter a constant number to deletestring. Maybe it is just bugged when using variables. Though I doubt it.

Kaimetsu 12-05-2002 11:34 AM

Quote:

Originally posted by Com013

But here I am not calling a joined function. Here it looks like deletestring is always deleting number zero, no matter what I command it to delete.

I'm pretty sure he knows that, he's just elaborating. Let's wait and see what happens after the update&restart :)

Com013 03-15-2003 06:16 PM

*reviving the thread*

It's bugged again!!!


All times are GMT +2. The time now is 04:48 AM.

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