07.04.2010, 12:06
I have this command to rob a player, here it is
The only problem is when I rob the person, the server crashes. Can anyone tell me whats wrong with it, because I cant figure out what is.
Код:
dcmd_rob(playerid,params[]) { if (justrobbed[playerid] == 1) return SendClientMessage(playerid, red, "You can not rob anyone. You must wait two minutes before attempting to rob another person."); if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /rob [playerid]"); new player1, playername[MAX_PLAYER_NAME], robber[MAX_PLAYER_NAME], string[128]; player1 = strval(params); if (playerid == player1) return SendClientMessage(playerid, red, "You can not rob yourself!"); if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) { new Float:x, Float:y, Float:z; GetPlayerPos(player1,x,y,z); if (IsPlayerInRangeOfPoint(playerid, 5, x, y, z)){ justrobbed[playerid] = 1; SetTimerEx("Rob", 120000, false, "%d", playerid); GetPlayerName(player1, playername, sizeof(playername)); GetPlayerName(playerid, robber, sizeof(robber)); switch(random(5)) { case 1: { format(string,sizeof(string),"You have just been robbed by %s!",robber); SendClientMessage(player1,red,string); format(string,sizeof(string),"You have just robbed %s and got a +2 wanted level, and $500",playername); SendClientMessage(playerid,red,string); SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 2); GivePlayerMoney(playerid, 500); GivePlayerMoney(player1, - 500); } case 2, 3, 4, 5: { format(string,sizeof(string),"You fail to rob %s, You just got 2 stars!",playername); SendClientMessage(playerid,red,string); format(string,sizeof(string),"%s has tried, but failed to rob you!",robber); SendClientMessage(player1,red,string); SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) + 2); } } } else return SendClientMessage(playerid, red, "You are not close enough to that player to rob them."); } else return SendClientMessage(playerid, red, "Player is not connected"); return 1; }