Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Old Scripting Engine (GS1)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-14-2006, 10:37 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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;
}

Reply With Quote
  #2  
Old 01-14-2006, 10:44 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to 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!
__________________
Skyld
Reply With Quote
  #3  
Old 01-14-2006, 10:46 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Thanks, I guess when you're looking at it you miss the easy stuff Thanks though
Reply With Quote
  #4  
Old 01-14-2006, 10:54 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
You're welcome.
__________________
Skyld
Reply With Quote
  #5  
Old 01-14-2006, 11:06 PM
Moondeath_2 Moondeath_2 is offline
"..."
Moondeath_2's Avatar
Join Date: Jan 2006
Location: Far Far Away.
Posts: 238
Moondeath_2 is an unknown quantity at this point
Send a message via AIM to Moondeath_2 Send a message via MSN to Moondeath_2 Send a message via Yahoo to Moondeath_2
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.
__________________
Aim: DarkFireXZ3
Email: [email protected] or [email protected]
Common Location: Unholy Nation
Gscript, Playerworld Rules, Support Center
Reply With Quote
  #6  
Old 01-14-2006, 11:16 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
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.
__________________
Skyld
Reply With Quote
  #7  
Old 01-15-2006, 12:28 AM
Moondeath_2 Moondeath_2 is offline
"..."
Moondeath_2's Avatar
Join Date: Jan 2006
Location: Far Far Away.
Posts: 238
Moondeath_2 is an unknown quantity at this point
Send a message via AIM to Moondeath_2 Send a message via MSN to Moondeath_2 Send a message via Yahoo to Moondeath_2
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.
__________________
Aim: DarkFireXZ3
Email: [email protected] or [email protected]
Common Location: Unholy Nation
Gscript, Playerworld Rules, Support Center
Reply With Quote
  #8  
Old 01-15-2006, 02:07 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
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.
__________________
Reply With Quote
  #9  
Old 01-15-2006, 06:01 AM
Raeiphon Raeiphon is offline
I never asked for this.
Join Date: Jun 2005
Posts: 855
Raeiphon is on a distinguished road
I honestly dont see why you used triggeraction, it's not required when the same variable is triggered anyway with playerchats..
__________________

I hope for nothing. I fear nothing. I am free.
Reply With Quote
  #10  
Old 01-15-2006, 06:05 AM
Prozac Prozac is offline
one of the good guys
Prozac's Avatar
Join Date: Jan 2006
Posts: 245
Prozac is on a distinguished road
Send a message via AIM to 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.
Reply With Quote
  #11  
Old 01-15-2006, 06:23 AM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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
Reply With Quote
  #12  
Old 01-15-2006, 03:27 PM
Maniaman Maniaman is offline
Registered User
Join Date: Aug 2005
Posts: 326
Maniaman is on a distinguished road
Why would you want #a as #p(0)?
__________________

Current Maloria Event: (click to go to it)
Reply With Quote
  #13  
Old 01-15-2006, 06:58 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
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.
__________________
Reply With Quote
  #14  
Old 01-15-2006, 08:29 PM
JkWhoSaysNi JkWhoSaysNi is offline
Ruler of the graalaxy
Join Date: Feb 2005
Location: Great Britain
Posts: 488
JkWhoSaysNi is on a distinguished road
Send a message via ICQ to JkWhoSaysNi
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.
Reply With Quote
  #15  
Old 01-15-2006, 08:37 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
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 :|
Reply With Quote
  #16  
Old 01-15-2006, 10:44 PM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
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.
Reply With Quote
  #17  
Old 01-15-2006, 10:56 PM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
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.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #18  
Old 01-15-2006, 11:36 PM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
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).
Reply With Quote
  #19  
Old 01-16-2006, 04:37 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
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.
__________________
Reply With Quote
Reply


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 01:15 AM.


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