19.10.2012, 00:39
Quote:
Is there anything even more simple? that i wont need an include, like a simple /jail [id] [time] [reason]
|
pawn Код:
#define white 0xFFFFFFAA // top of script
#pragma tabsize 0 // You can delete this, but I used it to get rid of loose indentation warnings.
// Put this code under "OnPlayerCommandText", use ctrl + f to search for it.
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/command", true) == 0)
{
new parameterstring[256], messagestring[128],
giveplayerid, moneytogive;
parameterstring = strtok(cmdtext, idx);
// You could check to see if the player is an admin here.
if(!strlen(parameterstring))
{
SendClientMessage(playerid, white, "Invalid syntax.");
return 1;
}
giveplayerid = strval(parameterstring);
parameterstring= strtok(cmdtext, idx);
if(!strlen(parameterstring))
{
SendClientMessage(playerid, white, "Invalid syntax.");
return 1;
}
moneytogive = strval(parameterstring);
if (IsPlayerConnected(giveplayerid))
{
GivePlayerMoney(giveplayerid, moneytogive);
format(messagestring, 128, "You gave that player $%d.", moneytogive);
SendClientMessage(playerid, white, messagestring);
}
else
{
SendClientMessage(playerid, white, "Invalid player.");
}
return 1;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}