Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Old Scripting Engine (GS1) (https://forums.graalonline.com/forums/forumdisplay.php?f=154)
-   -   Script not working (https://forums.graalonline.com/forums/showthread.php?t=63445)

excaliber7388 01-14-2006 10:37 PM

Script not working
 
I know this isn't what you wanted to see, but anyway, whats wrong with this shop script?
NPC Code:
// NPC made by Excaliber
if (created)
{
setshape 1,32,32;
}
if(actionbuy)
{
with(getplayer(#p(0)))
{
if(strequals(#c,buy thunder shot) && playerrupees>249999 && strtofloat(#s(serverr.thundershotstock>0)))
{
playerrupees-=250000;
setstring serverr.eventsbalance,#v(strtofloat(#s(serverr.eve ntsbalance))+250000);
addweapon Thunder Shot;
}
if(strequals(#c,buy thunder spin) && playerrupees>17499 && strtofloat(#s(serverr.thunderspinstock>0)))
{
playerrupees-=17500;
setstring serverr.eventsbalance,#v(strtofloat(#s(serverr.eve ntsbalance))+17500);
addweapon Thunder Spin;
}
if(strequals(#c,buy flame wall) && playerrupees>9499 && strtofloat(#s(serverr.flamewallstock>0)))
{
playerrupees-=9500;
addweapon Flame Wall;
setstring serverr.eventsbalance,#v(strtofloat(#s(serverr.eve ntsbalance))+9500);
}
if(strequals(#c,buy thunder wall) && playerrupees>10999 && strtofloat(#s(serverr.thunderwallstock>0)))
{
playerrupees-=11000;
setstring serverr.eventsbalance,#v(strtofloat(#s(serverr.eve ntsbalance))+11000);
addweapon Thunder Wall;
}
if(strequals(#c,buy fire spin 2) && playerrupees>14999 && strtofloat(#s(serverr.firespin2stock>0)))
{
playerrupees-=15000;
setstring serverr.eventsbalance,#v(strtofloat(#s(serverr.eve ntsbalance))+15000);
addweapon Fire Spin 2;
}
if(strequals(#c,buy nuke shot 2)&& playerrupees>14999 && strtofloat(#s(serverr.nukeshot2stock>0)))
{
playerrupees-=15000;
setstring serverr.eventsbalance,#v(strtofloat(#s(serverr.eve ntsbalance))+15000);
addweapon Nuke Shot 2;
}
}
}
//#CLIENTSIDE
if(playerchats)
{
triggeraction x,y,buy,#a,#c;
}


Skyld 01-14-2006 10:44 PM

HTML Code:

strtofloat(#s(serverr.thundershotstock>0))
... is not doing what you think it is.

Perhaps you mean:
HTML Code:

strtofloat(#s(serverr.thundershotstock)) > 0
The same also applies to your other stock checks.

Also, please name your threads better. Thank you!

excaliber7388 01-14-2006 10:46 PM

Thanks, I guess when you're looking at it you miss the easy stuff :\ Thanks though ^^

Skyld 01-14-2006 10:54 PM

You're welcome.

Moondeath_2 01-14-2006 11:06 PM

Quote:

Originally Posted by Skyld
HTML Code:

strtofloat(#s(serverr.thundershotstock>0))
... is not doing what you think it is.

Perhaps you mean:
HTML Code:

strtofloat(#s(serverr.thundershotstock)) > 0
The same also applies to your other stock checks.

Also, please name your threads better. Thank you!

Hrm, coldn't you use strlen(#s(serverr.thundershotstock)) > 0 ? I don't know really that well i dislike gs1 in so many ways. :rolleyes:

Skyld 01-14-2006 11:16 PM

Quote:

Originally Posted by Moondeath_2
Hrm, coldn't you use strlen(#s(serverr.thundershotstock)) > 0 ? I don't know really that well i dislike gs1 in so many ways. :rolleyes:

Not quite! strlen() returns the length of a given string. If the string contains "0", then it's length would technically still be above 0, thus giving an undesired effect.

Moondeath_2 01-15-2006 12:28 AM

Quote:

Originally Posted by Skyld
Not quite! strlen() returns the length of a given string. If the string contains "0", then it's length would technically still be above 0, thus giving an undesired effect.

I see I lack the the skill of delphi. ^^

ZeLpH_MyStiK 01-15-2006 02:07 AM

Quote:

Originally Posted by Moondeath_2
I see I lack the the skill of delphi. ^^

What does any of that have to do with delphi? It's common sense.

Raeiphon 01-15-2006 06:01 AM

I honestly dont see why you used triggeraction, it's not required when the same variable is triggered anyway with playerchats..

Prozac 01-15-2006 06:05 AM

also setting a serverr.string to 0 will delete the string
since 0 is the same as null. I learned this the hard way with my custom hp system. you can substitiute and test for the word "none" i suppose though gs2 (if you convert the script) may want a "string" to look like that an int/floats to have no quotations. hm i see the point of my post has past so i will stop.

excaliber7388 01-15-2006 06:23 AM

Yeah, but when it's 0, and deleted, it's still read as 0, which is okay. Also, when the script needs the string again, it is recreated, so it's not a problem. And the triggeraction is there so I can get the player's account as #p(0). Eh, it's secure, and it works fine now :)

Maniaman 01-15-2006 03:27 PM

Why would you want #a as #p(0)?

ZeLpH_MyStiK 01-15-2006 06:58 PM

Quote:

Originally Posted by Prozac
also setting a serverr.string to 0 will delete the string
since 0 is the same as null. I learned this the hard way with my custom hp system. you can substitiute and test for the word "none" i suppose though gs2 (if you convert the script) may want a "string" to look like that an int/floats to have no quotations. hm i see the point of my post has past so i will stop.

Wrong. Setting serverr.string to 0 will give it a string value of 0. Null is not the same as 0.

JkWhoSaysNi 01-15-2006 08:29 PM

Quote:

Originally Posted by Maniaman
Why would you want #a as #p(0)?


I do that too. It seems logical that if you're running a script serverside it shouldn't be able to know tha value of #a since it's not running on the client. How would you know who called the serverside function? Although i've since realised you can use #a serverside... but i don't understand why.

excaliber7388 01-15-2006 08:37 PM

Quote:

Originally Posted by JkWhoSaysNi
I do that too. It seems logical that if you're running a script serverside it shouldn't be able to know tha value of #a since it's not running on the client. How would you know who called the serverside function? Although i've since realised you can use #a serverside... but i don't understand why.

You can? That make little to no sence XD I always thought that if you wanted something serversde to act on a player you would need getplayer and send the account with the action :|

Rick 01-15-2006 10:44 PM

Quote:

Originally Posted by JkWhoSaysNi
I do that too. It seems logical that if you're running a script serverside it shouldn't be able to know tha value of #a since it's not running on the client. How would you know who called the serverside function? Although i've since realised you can use #a serverside... but i don't understand why.

Because the code is run in the context of who triggered the action.

napo_p2p 01-15-2006 10:56 PM

Quote:

Originally Posted by ZeLpH_MyStiK
Wrong. Setting serverr.string to 0 will give it a string value of 0. Null is not the same as 0.

On GS2 enabled servers, I've found that setting a string to 0 gets rid of the string.

Lance 01-15-2006 11:36 PM

Quote:

Originally Posted by JkWhoSaysNi
I do that too. It seems logical that if you're running a script serverside it shouldn't be able to know tha value of #a since it's not running on the client. How would you know who called the serverside function? Although i've since realised you can use #a serverside... but i don't understand why.

No, that doesn't seem logical at all.

Anyway, don't trust the client to send the right parameters like that (unless you really want trainer users to be able to trigger that action for any player).

ZeLpH_MyStiK 01-16-2006 04:37 PM

So i've done some testing, it seems that on a gs2 enabled server, setting a serverr string to zero does destroy the string, although not entirely. There is still somewhat of a reminant of the string. Example:
NPC Code:

function onCreated() {
serverr.zelphtest = "OMG! Set!";
sendtonc("serverr.zelphtest: "@serverr.zelphtest);
// returns serverr.zelphtest: OMG! Set!
serverr.zelphtest = "0";
sendtonc("serverr.zelphtest: "@serverr.zelphtest);
// returns serverr.zelphtest: 0
serverr.zelphtest = "";
sendtonc("serverr.zelphtest: "@serverr.zelphtest);
// returns serverr.zelphtest:
}


Notice the difference between the last two? Of course, in gs2, a string can be treated as a float and vice-versa so it doesnt really matter.


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

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