Author Topic: /buyjets  (Read 3069 times)

Code: [Select]
function serverCmdBuyJets(%client)
{
    if(%client.mineJets)
commandToClient(%client, 'centerPrint', "You already bought some jets!", 3);

    else if(%client.mineMoney >= 50)
    {
%client.mineJets = 1;
commandToClient(%client, 'centerPrint', "You have bought some Jets for \c3$50", 3);
%client.mineMoney -= 50;
serverCmdchangeDatablock(PlayerNoJet);
    }

    else
commandToClient(%client, 'centerPrint', "You cannot afford some Jets for \c3$50", 3);
    %client.sendMiningStatus();
}

Now if I typed /buyJets would it work?

No, and if it did work, it would take away jets.

Change serverCmdchangeDatablock(PlayerNoJet)
to
if(isObject(%client.player))
%client.player.changeDataBlock(YOUR DATABLOCK THAT HAS JETS HERE);

And you may want to make something that gives their jets back when they respawn.

Code: [Select]
function serverCmdBuyJets(%client)
{
    if(%client.mineJets)
commandToClient(%client, 'centerPrint', "You already bought some jets!", 3);

    else if(%client.mineMoney >= 50)
    {
%client.mineJets = 1;
commandToClient(%client, 'centerPrint', "You have bought some Jets for \c3$50", 3);
        if(isObject(%client.player))
        %client.player.changeDataBlock(StandardPlayer);
    }

    else
commandToClient(%client, 'centerPrint', "You cannot afford Jets for \c3$50", 3);
    %client.sendMiningStatus();
}

And you may want to make something that gives their jets back when they respawn.

How do I make it so that it gives the client a variable like "mineJets"?
Then how do I make it so that when a player spawns, and the server check the client for "mineJets", if the client does have it, then he has jets. IF he doesn't, then he don't get no jets?

How do I make it so that it gives the client a variable like "mineJets"?
You've already done that.
Then how do I make it so that when a player spawns, and the server check the client for "mineJets", if the client does have it, then he has jets. IF he doesn't, then he don't get no jets?
Package GameConnection::spawnPlayer, and have it check for .minejets.
Schedule for 100 to change it's datablock based on if they have jets or not.

Code: [Select]
function GameConnection::spawnPlayer(%client)
{
        if(%client.minejets == 1);
        {
         if(isObject(%client.player))
        %client.player.changeDataBlock(StandardPlayer);
        }
}     

this?

this?

You've already done that.Package GameConnection::spawnPlayer, and have it check for .minejets.
Schedule for 100 to change it's datablock based on if they have jets or not.

I honestly don't know what that means. I just started scripting.

I honestly don't know what that means. I just started scripting.
schedule(__,__,__);

I believe Chron means that you should use a schedule(100,0,[insert your function here]); to add the jets.. I believe. I'm not quite sure, someone correct me if I'm wrong please.

schedule(__,__,__);

I believe Chron means that you should use a schedule(100,0,[insert your function here]); to add the jets.. I believe. I'm not quite sure, someone correct me if I'm wrong please.

That didn't help me at all.


Code: [Select]
function GameConnection::spawnPlayer(%client)
{
        if(%client.minejets == 1);
        {
         if(isObject(%client.player))
        %client.player.changeDataBlock(StandardPlayer);
        }
}     

Will this work?

Package it.

Also

        if(%client.minejets)
                %client.player.schedule(100,changeDataBlock,StandardPlayer);

Could I do this?

Code: [Select]
function serverCmdBuyJets(%client)
{
    if(%client.mineJets)
commandToClient(%client, 'centerPrint', "You already bought some jets!", 3);

    else if(%client.mineMoney >= 50)
    {
%client.mineJets = 1;
commandToClient(%client, 'centerPrint', "You have bought some Jets for \c3$50", 3);
%client.mineMoney -= 50;
serverCmdchangeDatablock(PlayerNoJet);
    }

    else
    {
commandToClient(%client, 'centerPrint', "You cannot afford some Jets for \c3$50", 3);
        %client.sendMiningStatus();
    }
    else
        if(%client.minejets == 1);
        {
         if(isObject(%client.player))
        %client.player.changeDataBlock(StandardPlayer);
        }
}

No because that's broken code.


Explain please.
I'm not sure if this is answering your whole problem, but it's with the 'else' s. I would suggest using ingame console to determine problem lines.

So, your problem is you've got else's. When you use else (just plain else, mind you), it means that you're finishing the 'if()' sequence. Therefore, the else if(%client.minejets == 1) has nothing to target. (I believe that's why.. I know thats a reason why it's wrong.

Second of all, your fourth else: You used else <br> if(%client...) It needs to be else if(%client...) like all of your other elses.

Also, your last function needs to be in a "function GameConnection::spawnPlayer" or else it will not work, which is what i believe Chron is pointing out.

Code: [Select]
function GameConnection::spawnPlayer(%client)
{
        if(%client.minejets)
        %client.player.schedule(100,changeDataBlock,StandardPlayer);
}

Can't I use this?