Little help with variables please...
#2

Sure! First off, you'll need sscanf and ZCMD.

Then put this ontop of your script:

pawn Код:
#include <ZCMD>
#include <sscanf2>
Now, you'll need to actually do some research on the sscanf topic to learn about operators and such, but it's well worth learning.


Here's a basic "shell" for a ZCMD command:
pawn Код:
COMMAND:pay(playerid, params[])
{
    return 1;
}
Now we will add the code, starting with the beginning of the sscanf "declaration" i wanna call it, but it's obviously not, i just can't think of the word at the moment considering it's 8 AM.

pawn Код:
COMMAND:pay(playerid, params[])
{
    new
        PlayerBeingPaid,
        AmountBeingPaidToPlayer;
       
    if(sscanf(params, "ui", PlayerBeingPaid, AmountBeingPaidToPlayer))
        //What happens if they don't use the correct syntax; Usage message?
        return SendClientMessage(playerid, -1, "{FFFFFF}USAGE: /Pay [Player ID] [Amount]");
       
    //The rest of your code - What happens if they do use the correct syntax?
    if(GetPlayerMoney(playerid) >= AmountBeingPaidToPlayer) //Do they have enough money? If so, continue.
    {
        GivePlayerMoney(PlayerBeingPaid, AmountBeingPaidToPlayer);
        GivePlayerMoney(playerid, -AmountBeingPaidToPlayer);
    }
    //If not - Error message
    else return SendClientMessage(playerid, -1, "{FFFFFF}ERROR: You don't have enough money!");
    return 1;
}
I hope i've actually taught you something.
Reply


Messages In This Thread
Little help with variables please... - by 22reiko - 13.07.2011, 12:41
Re: Little help with variables please... - by Skylar Paul - 13.07.2011, 12:51
Re: Little help with variables please... - by 22reiko - 13.07.2011, 12:53
Re: Little help with variables please... - by Skylar Paul - 13.07.2011, 12:54
Re: Little help with variables please... - by 22reiko - 13.07.2011, 13:46
AW: Little help with variables please... - by Nero_3D - 13.07.2011, 15:04
Re: Little help with variables please... - by Skylar Paul - 13.07.2011, 15:48

Forum Jump:


Users browsing this thread: 1 Guest(s)