Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-01-2005, 10:25 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
I feel stupid

I feel stupid posting this, I really do, it's gotta be some thing small X_X here we go again:
whats wrong with this script:
NPC Code:
if (actionbuy){
if(strequals(#p(0),float)){
addweapon Event Prizes/Float;
setstring clientr.eventcoin,#v(strtofloat(#s(clientr.eventco in))-10);
}
}
//#CLIENTSIDE
//sorry 'bout this next part, it's easier to script
if(playerchats && strequals(#c,buy float) && strtofloat(#s(clientr.eventcoin))>10){
triggeraction playerx,playery,buy,float;
}

Reply With Quote
  #2  
Old 11-01-2005, 11:28 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
If this is a level NPC, you should do all of that serverside.

The most compelling reason for this is security. Do you really want to trust the client's perception of clientr.eventcoin?

Other than that, there are three main flaws with your script as-is:

1) You're triggering to playerx and playery instead of somewhere on the surface of the NPC.
2) The serverside part of your NPC has no surface to trigger onto (unless there's an image set). Use a setshape to remedy this.
3) Your serverside code has no error-checking. This kinda goes along with the security thing I mentioned. What do you suppose might happen if someone has 10 event coins and says the purchase line twice in a row before the server finishes processing the first triggeraction?

Last edited by Lance; 11-01-2005 at 11:38 PM.. Reason: elaboration
Reply With Quote
  #3  
Old 11-01-2005, 11:41 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
oh thanks, didn't know i would still need setshape for this i origionally used x,y but it didn't work (no setshape) and the coin thing? GP, ill set a check in there for that thanks!
Reply With Quote
  #4  
Old 11-01-2005, 11:46 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 excaliber7388
oh thanks, didn't know i would still need setshape for this i origionally used x,y but it didn't work (no setshape) and the coin thing? GP, ill set a check in there for that thanks!
You're welcome. I would like to reiterate, though, that I strongly suggest making the whole buying-with-event-coins script serverside. There is a serverside playerchats event, so why not make use of it? It would make the error-checking for that script much simpler, and you'd have fewer things to worry about (like clientside-edited strings).
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 09:31 AM.


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