Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   I feel stupid (https://forums.graalonline.com/forums/showthread.php?t=62028)

excaliber7388 11-01-2005 10:25 PM

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;
}


Lance 11-01-2005 11:28 PM

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?

excaliber7388 11-01-2005 11:41 PM

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!

Lance 11-01-2005 11:46 PM

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).


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

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