Author Topic: Super Needs Help  (Read 3191 times)

Yeah, do you mean an actual GUI or a bottom print though.
if(%this.bananas > 0) then you can bottom print it.

You are setting the wallet to a global variable which won't save and is not player based, if you want to store a variable on a client use %this.bananas = 50; but remember that it won't save unless you export it or something.
Thanks for help with Client based, but I mean a actual GUI I was looking to do somin like the deus ex inventory system where you have 32 Blocks and each item takes up a certain amout of blocks on the gui and when all 32 are used you cannot hold anything else
« Last Edit: April 27, 2015, 05:23:54 PM by SuperFlaminninja³ »

%take = 50;
%variable -= %take;

I think that's what you're asking? %take is how much you want to take from the other variable.


%take = 50;
%variable -= %take;

I think that's what you're asking? %take is how much you want to take from the other variable.
Thanks

Ok it is not subtracting, here's the code
Code: [Select]
$Bank = 1500;
$Wallet = 1500;
%Bannana = 500;

function buy (%Bannana)
{
if ($Wallet > %Bannana)
$Wallet -= %Bannana;
}

The code works perfectly.

How are you calling the function?
You need to give %Bannana a value; defining it as 500 outside of the scope of the function doesn't do anything because it's a local variable
call buy(50); and $Wallet will decrease by 50. If you just call buy(); then nothing will happen because you're not giving it any value to subtract

The code works perfectly.

How are you calling the function?
You need to give %Bannana a value; defining it as 500 outside of the scope of the function doesn't do anything because it's a local variable
call buy(50); and $Wallet will decrease by 50. If you just call buy(); then nothing will happen because you're not giving it any value to subtract
Ok so one last question is there any way I could make an event that would create its own variable and put a custom amount
Example:
If the player dosnt want to sell only bannanas lets say also apples then they could go into the wrench events and change it to be apples and change the price and still have bannanas?

Of course there is.

Code: [Select]
function GameConnection::buyItem(%this, %item, %quantity) {
    %bananaCost = 10;
    %appleCost = 5;

    if(%item == 0) { // banana
        if(%this.wallet >= %bananaCost * %quantity) {
            %this.wallet -= %bananaCost * %quantity;
            %this.bananas += %quantity;
        }
    }

    if(%item == 1) { // apple
        if(%this.wallet >= %appleCost * %quantity) {
            %this.wallet -= %appleCost * %quantity;
            %this.apples += %quantity;
        }
    }
}

registerOutputEvent("GameConnection", "buyItem", "list Banana 0 Apple 1" TAB "int 1 100 1", 0);

Ok so one last question is there any way I could make an event that would create its own variable and put a custom amount

Of course there is.
-snip-

Or you could use VCE for something simple like that

Or you could use VCE for something simple like that
This is coding help
if he wanted to use VCE he wouldn't have asked here

Of course there is.

Code: [Select]
function GameConnection::buyItem(%this, %item, %quantity) {
    %bananaCost = 10;
    %appleCost = 5;

    if(%item == 0) { // banana
        if(%this.wallet >= %bananaCost * %quantity) {
            %this.wallet -= %bananaCost * %quantity;
            %this.bananas += %quantity;
        }
    }

    if(%item == 1) { // apple
        if(%this.wallet >= %appleCost * %quantity) {
            %this.wallet -= %appleCost * %quantity;
            %this.apples += %quantity;
        }
    }
}

registerOutputEvent("GameConnection", "buyItem", "list Banana 0 Apple 1" TAB "int 1 100 1", 0);
actualy 3 More questions so sorry, is there a way to Display the Apple and bannana quantity on a GUI if there is a bannana in the inventory and if there is not have the option disapear. Question 2: Is there a way not only to have a  quantity for the buyer but for the seller also? Qestion 3: Will the $wallet amount be diffrent for each player online?

Yeah, do you mean an actual GUI or a bottom print though.
if(%this.bananas > 0) then you can bottom print it.

You are setting the wallet to a global variable which won't save and is not player based, if you want to store a variable on a client use %this.bananas = 50; but remember that it won't save unless you export it or something.

Yeah, do you mean an actual GUI or a bottom print though.
if(%this.bananas > 0) then you can bottom print it.

You are setting the wallet to a global variable which won't save and is not player based, if you want to store a variable on a client use %this.bananas = 50; but remember that it won't save unless you export it or something.
Thanks for help with Client based, but I mean a actual GUI I was looking to do somin like the deus ex inventory system where you have 32 Blocks and each item takes up a certain amout of blocks on the gui and when all 32 are used you cannot hold anything else


It was the third post down from the topic you don't need to do a four hour bump Lol.

If you want to make it appear on a GUI you'll need a server and client add-on.
Client could have something like this:

function clientCmdsetBananas(%count) {
   if(%count > 0)
      GuiName.setText(%count);
}
So you can send the client the amount of bananas from the server and update the HUD.