creating a /givedrugs command, help me please. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: creating a /givedrugs command, help me please. (
/showthread.php?tid=105496)
creating a /givedrugs command, help me please. -
dirkblok - 29.10.2009
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
Re: creating a /givedrugs command, help me please. -
MadeMan - 29.10.2009
If you want to create a command with parameters there are many ways:
Re: creating a /givedrugs command, help me please. -
dirkblok - 29.10.2009
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?
Re: creating a /givedrugs command, help me please. -
(.Aztec); - 29.10.2009
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;
}
Re: creating a /givedrugs command, help me please. -
dirkblok - 29.10.2009
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