05.01.2015, 11:09
i made a rob command and here is the code
It works but when i rob someone i doesn't send the amount of money in the chat it give the player the amount of money but i doesn't do in the chat
PHP код:
CMD:rob(playerid, params[])
{
new targetid;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /rob [id]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
new Float:x, Float:y, Float:z;
new tPos = GetPlayerPos(targetid, x, y, z);
if(!IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) return SendClientMessage(playerid, COLOR_RED, "This player is too far away");
if(GetPlayerMoney(targetid) < 1000) return SendClientMessage(playerid, COLOR_RED, "This player doesn't have enough money");
new money = GetPlayerMoney(targetid);
GivePlayerMoney(playerid, money / 10);
GivePlayerMoney(targetid, -money / 10);
new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
new name2[MAX_PLAYER_NAME], string1[24+MAX_PLAYER_NAME];
GetPlayerName(targetid, name2, sizeof(name2));
format(string,sizeof(string),"%s has robbed %s",name, name2);
SendClientMessage(playerid, COLOR_SILVER, "You robbed %d", money);
SendClientMessage(targetid, COLOR_SILVER, "You got robbed and lost %d", money/10);
SendClientMessageToAll(COLOR_GREEN,string);
return 1;
}
