View Single Post
  #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