Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 07-05-2009, 12:35 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
I couldn't find the article I was looking for on the wiki, so I'll summarize for you.

You need to change the player's money serverside. The best way to do this would be to trigger serverside like this

PHP Code:
triggerserver("gui"name"sellFish""Salmon"); 
Then, at the top of your script (on serverside), you need to determine how much salmon the player has, then figure out how much to pay them. Take away the salmon, then pay the player.

PHP Code:
function onActionServerSide(cmdfish) {
  if (
cmd == "sellFish") {
    if (
fish == "Salmon") {
      
temp.amount clientr.fish.Salmon;
      
temp.pricePerFish 15;
      
      
clientr.fish.Salmon 0;
      
clientr.money += (pricePerFish amount);
    }
  }

This is a basic outline of what you want to do. If you were to add the rest of your script, it would look like this:

PHP Code:
function onActionServerSide(cmdfish) {
  if (
cmd == "sellFish") {
    if (
fish == "Salmon") {
      
temp.amount clientr.fish.Salmon;
      
temp.pricePerFish 15;
      
      
clientr.fish.Salmon 0;
      
clientr.money += (pricePerFish amount);
    } else if (
fish == "Shrimp") {
      
temp.amount clientr.fish.Shrimp;
      
temp.pricePerFish 10;
      
      
clientr.fish.Shrimp 0;
      
clientr.money += (pricePerFish amount);
    } 
// and a long list of else-ifs paying the player
  
}
}
//#CLIENTSIDE
// insert all your GUI stuff here

function MyGUI_Button1.onAction() {
  
triggerserver("gui"name"sellFish""Salmon");
}
function 
MyGUI_Button2.onAction() {
  
triggerserver("gui"name"sellFish""Shrimp");
}

// and all the other buttons, etc 

However, an easier way to do the serverside bit would be

PHP Code:
function onActionServerSide(cmdfish) {
  if (
cmd == "sellFish") {
    
// now you need to figure out how much to pay for each fish, so
    // add it to the list here
    
    
temp.price.Salmon 15;
    
temp.price.Trout 10;
    
temp.price.FlyFish 5;
    
temp.price.Shrimp 10;
    
// add all the other fish as well here
    
    // now that you did that list, you don't have to add anything else
    // down here for each fish
    
    
temp.amount clientr.fish.(fish);
    
temp.pricePerFish temp.price.(@ fish);
    
clientr.money += (amount pricePerFish);
    
clientr.fish.(fish) = 0;
  }

This just saves work, and makes it easier to change things later on. If that method confuses you, use the first one. Remember you're going to have to change the variables around to fit your server (e.g. clientr.money, clientr.fish.name)
__________________
Reply With Quote
 


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:12 PM.


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