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-13-2011, 01:06 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Triggerserver not detected

I am coding a shop class for buying things on Lexia, and everything seems to be going amazingly well. The only thing I am being jammed on is adding the weapon to the player and subtracting the gold. Can somebody help me out? Here's the class. (Added to pastebin since incapsula is a douche)

http://pastebin.graalcenter.org/read...d=471071864374
__________________
Reply With Quote
  #2  
Old 11-13-2011, 03:51 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Maybe that?

http://pastebin.graalcenter.org/read...=1081401087146

Also I´d use clientr.gold for the players money, since using client.gold can get easily edited (as far as I heard).
__________________
MEEP!
Reply With Quote
  #3  
Old 11-13-2011, 05:38 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
The problem is that you're triggering serverside like it's a weapon. You can't do that.

Instead, something like

PHP Code:
function onCreated() {
  
this.itemName "whatever";
  
this.itemPrice 123123;
  
  
this.setShape(11616); // so it can be triggered)
}

function 
onActionPurchase() {
  echo(
player.account " wants to purchase this item!");
}

//#CLIENTSIDE
function Shop_Button1.onAction() {
  if (
client.gold client.store1 || client.gold == client.store1) {
    if (!(
hasweapon((@client.realitem)))) {
      
triggerAction(this.xthis.y"purchase"null);
    }
  }

You're trusting the clientside way too much. Any client. variables can be changed by the player; always assume they have been tampered with. You need to store the item price and name on the serverside if that's where you need to access them. I could easily purchase any item I wanted to on your server for no money at all.

While my example should work, I highly recommend you take the code out of the item class and centralize all of it in one weapon. The GUI code is easier to maintain in a single weapon, and the serverside bits are much easier to maintain. Not only can you not assume that a trigger will reach serverside when using triggerAction on a local NPC, but it's a mess whenever you need to change anything since you have to change the scripts in many levels.

Instead, just trigger a weapon when the item is clicked (see here).

Otherwise, you can keep the same code and still centralize the serverside bit by triggering a database NPC instead of the local NPC. This has huge benefits because you can be sure the trigger will reach serverside. See here.

Quote:
Originally Posted by callimuc View Post
No, never send the player's account in a trigger. All you're doing is opening up major vulnerabilities. With your code, I could force any player online to spend their money to purchase any item I wanted them to (assuming your code would work, which it won't).
__________________
Reply With Quote
  #4  
Old 11-13-2011, 08:40 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by cbk1994 View Post
The problem is that you're triggering serverside like it's a weapon. You can't do that.

Instead, something like

PHP Code:
function onCreated() {
  
this.itemName "whatever";
  
this.itemPrice 123123;
  
  
this.setShape(11616); // so it can be triggered)
}

function 
onActionPurchase() {
  echo(
player.account " wants to purchase this item!");
}

//#CLIENTSIDE
function Shop_Button1.onAction() {
  if (
client.gold client.store1 || client.gold == client.store1) {
    if (!(
hasweapon((@client.realitem)))) {
      
triggerAction(this.xthis.y"purchase"null);
    }
  }

I am using a class. Why are you telling me to assign item details in the class when I will be selling different items at different prices?
__________________

Last edited by Emera; 11-13-2011 at 08:51 PM..
Reply With Quote
  #5  
Old 11-13-2011, 08:49 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
On a side note I don't believe the function "hasweapon" exists any more, so that condition will always be false even if you do have the weapon.
Reply With Quote
  #6  
Old 11-13-2011, 09:03 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by ffcmike View Post
On a side note I don't believe the function "hasweapon" exists any more, so that condition will always be false even if you do have the weapon.
So then would I have to check through the players weapons manually?
__________________
Reply With Quote
  #7  
Old 11-13-2011, 09:05 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Emera View Post
So then would I have to check through the players weapons manually?
PHP Code:
if(findweapon("name") == NULL){

Reply With Quote
  #8  
Old 11-13-2011, 09:47 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Emera View Post
I am using a class. Why are you telling me to assign item details in the class when I will be selling different items at different prices?
The item details should be in the local NPC, not the class. I was basing it off your example. Again, you shouldn't be using that method anyway—see the bottom half of my post.
__________________
Reply With Quote
  #9  
Old 11-13-2011, 10:33 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by ffcmike View Post
On a side note I don't believe the function "hasweapon" exists any more, so that condition will always be false even if you do have the weapon.
It still exists, but it's expecting a bareword weapon name (because it's a GS1 function).
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #10  
Old 11-14-2011, 12:11 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
OK, so the buying of the item and the GUI showing are working. Next roadblock...
When I click an item to buy, the GUI shows and that's all fine. Now if I close that and chooses another item, it shoes the previous items stats. I deleted the "previous" item and now it shows the next item, but adding another will still show the first clicked items details.
http://pastebin.graalcenter.org/read...=0106756446210
Any help?

Also, the buying of the item is all broken now too D:
__________________
Reply With Quote
  #11  
Old 11-14-2011, 12:45 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Emera View Post
OK, so the buying of the item and the GUI showing are working. Next roadblock...
When I click an item to buy, the GUI shows and that's all fine. Now if I close that and chooses another item, it shoes the previous items stats. I deleted the "previous" item and now it shows the next item, but adding another will still show the first clicked items details.
http://pastebin.graalcenter.org/read...=0106756446210
Any help?
Don't ignore the advice I gave you regarding security; anyone with a memory editor could spawn anything they wanted to. There's no excuse for storing that stuff clientside and sending it serverside.

If you're not interested in becoming a better scripter than these forums aren't for you—try hiring a scripter instead. There are a lot of people who will be willing to help you, but I doubt that will remain true if you disregard what they tell you. If you are interested in becoming a better scripter, as your user title would suggest, then I would recommend you follow advice given to you.

If you want to ignore what I said about centralizing, that's fine—you might not see the benefits of that until you've got more experience—but trusting clientside data is never acceptable, and you should not get into a habit of doing it.
__________________
Reply With Quote
  #12  
Old 11-14-2011, 12:55 AM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
Quote:
Originally Posted by cbk1994 View Post
Don't ignore the advice I gave you regarding security; anyone with a memory editor could spawn anything they wanted to. There's no excuse for storing that stuff clientside and sending it serverside.

If you're not interested in becoming a better scripter than these forums aren't for you—try hiring a scripter instead. There are a lot of people who will be willing to help you, but I doubt that will remain true if you disregard what they tell you. If you are interested in becoming a better scripter, as your user title would suggest, then I would recommend you follow advice given to you.

If you want to ignore what I said about centralizing, that's fine—you might not see the benefits of that until you've got more experience—but trusting clientside data is never acceptable, and you should not get into a habit of doing it.
Can I focus on getting the damn script working before worrying about that? It's not even released to players get dammit. I'm not ignoring you. Not everything has to be instantaneous you know. I can change from clientside to serverside in a a few seconds, but until I get the code working, there isn't much point in changing it yet.
__________________
Reply With Quote
  #13  
Old 11-14-2011, 01:58 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Your code that you're showing us doesn't make any sense.

1. You create a GUI somewhere
2. You call setItem somewhere
3. You're using a client flag for gold

If you're creating a GUI in the Shop weapon, add a public function to make the window visible and populate it with the right values instead of using setItem in your level npc.

Weapon: -ShopWindow
http://pastebin.graalcenter.org/read...d=834421076809

Your class:
http://pastebin.graalcenter.org/read...d=040953102775

All I did was put your code in the right places and change a few things that cbk suggested.
__________________
Quote:
Reply With Quote
  #14  
Old 11-14-2011, 07:28 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Emera View Post
Can I focus on getting the damn script working before worrying about that? It's not even released to players get dammit. I'm not ignoring you. Not everything has to be instantaneous you know. I can change from clientside to serverside in a a few seconds, but until I get the code working, there isn't much point in changing it yet.
Why do you always get so worked up when someone questions you? Geez man, take a chill pill. And he's right - do things properly from the start and you might actually learn.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #15  
Old 11-14-2011, 05:58 PM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is a jewel in the roughMysticalDragon is a jewel in the rough
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Quote:
Originally Posted by ffcmike View Post
PHP Code:
if(findweapon("name") == NULL){

more of an efficient way i feel would be,
PHP Code:
 if (player.hasWeapon("")) 
since GS1 is redundant really.
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]




Last edited by MysticalDragon; 11-14-2011 at 06:15 PM..
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:05 AM.


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