creating a /givedrugs command, help me please.
#1

Hey,

I wanna create a /givedrugs command.

I have this array:

drugs[MAX_PLAYERS];

I want that it works like this:
pawn Код:
// on /givedrugs [id]
{
if (drugs[playerid] >= 1)
{
drugs[playerid] -= 1;
drugs[id] += 1;
}

else
{
SendClientMessage(playerid, 0xFFFFFFFF, "You don't have any drugs!")
}

return 1;
}
but how can I make that if you typ let's say: /givedrugs 10
id = 10;
Does anyone knows how to fix this?

And tell me if you need more info ...

Dirk
Reply
#2

If you want to create a command with parameters there are many ways:
Reply
#3

Quote:
Originally Posted by MadeMan
If you want to create a command with parameters there are many ways:
thanks, but what's the best one to use?
Reply
#4

Quote:
Originally Posted by dirkblok
Quote:
Originally Posted by MadeMan
If you want to create a command with parameters there are many ways:
thanks, but what's the best one to use?
Try using SSCANF and ZCMD, here, i've made you one.

pawn Код:
zcmd(givedrugs, playerid, params[])
{
    new user;
    if(!sscanf(params, "u", user))
    {
      if (drugs[playerid] >= 1)
        {
          drugs[playerid] -= 1;
            drugs[user] += 1;
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "You don't have any drugs!")
    }
    else return SendClientMessage(playerid, white, "[USAGE]: /GiveDrugs [ID] (This will give them 1 drug, and you -1 drug)");
    return 1;
}
Reply
#5

Quote:
Originally Posted by sizeof(Sky));
Quote:
Originally Posted by dirkblok
Quote:
Originally Posted by MadeMan
If you want to create a command with parameters there are many ways:
thanks, but what's the best one to use?
Try using SSCANF and ZCMD, here, i've made you one.

pawn Код:
zcmd(givedrugs, playerid, params[])
{
    new user;
    if(!sscanf(params, "u", user))
    {
      if (drugs[playerid] >= 1)
        {
          drugs[playerid] -= 1;
            drugs[user] += 1;
        }
        else return SendClientMessage(playerid, 0xFFFFFFFF, "You don't have any drugs!")
    }
    else return SendClientMessage(playerid, white, "[USAGE]: /GiveDrugs [ID] (This will give them 1 drug, and you -1 drug)");
    return 1;
}
Thanks, but I got it done with strtok, but thanks for trying to help me anyways
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)