10.04.2012, 19:18
Hello everyone, I have this command where it allows other players to give other players cash.
But it doesn't work. You can type /gc in the chat and it will tell you what to do but then after that it just says unknown command.
So if I was to type /gc 2 50000 it will say unknown command.
2 = ID
50000 = amount giving to players.
But it doesn't work. You can type /gc in the chat and it will tell you what to do but then after that it just says unknown command.
So if I was to type /gc 2 50000 it will say unknown command.
2 = ID
50000 = amount giving to players.
pawn Код:
if((strcmp("/givecash", cmdtext, true) == 0) || (strcmp("/gc", cmdtext, true) == 0))
{
new id, pos, pname[MAX_PLAYER_NAME], string[128];
if(strlen(cmdtext[10]) == 0) return SendClientMessage(playerid, red, "Use: /givecash [playerid] [ammount]");
if((pos = strfind(cmdtext, " ", true, 10)) != -1) return SendClientMessage(playerid, red, "Use: /givecash [playerid] [ammount]");
if(strval(cmdtext[10]) == 0)
{
for(new i; i < MAX_PLAYERS; i++)
{
GetPlayerName(i, pname, sizeof(pname));
if(strfind(pname, cmdtext[10], true) != -1)
{
id = i;
goto next;
}
}
return SendClientMessage(playerid, red, "Error: player not connected");
}
else
{
id = strval(cmdtext[10]);
}
next:
if(IsPlayerConnected(id) == 0) return SendClientMessage(playerid, red, "Error: player not connected");
if(strval(cmdtext[pos + 1]) < 0 || strval(cmdtext[pos + 1]) > 1000000) return SendClientMessage(playerid, red, "Error: Invalid amount");
GivePlayerMoney(id, strval(cmdtext[pos + 1]));
GetPlayerName(id, pname, sizeof(pname));
format(string, sizeof(string), "You have given %s (%d) $%d", pname, id, strval(cmdtext[pos + 1]));
SendClientMessage(playerid, yellow, string);
GivePlayerMoney(playerid, -strval(cmdtext[pos + 1]));
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s (%d) has given you $%d", pname, playerid, strval(cmdtext[pos + 1]));
SendClientMessage(id, yellow, string);
return 1;
}