19.08.2013, 20:49
Hi , with this command you need to put the player id that you want to rob , i want that the player dont need to put any id , when put /rob rob the nearest player
Код:
if(strcmp(cmd, "/rob", true) == 0) { tmp = strtok(cmdtext, idx); if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /rob [ID]"); else { if(IsPlayerSpawned(playerid)) { if(gTeam[playerid] == CIVILIAN) { if(strval(tmp) != playerid) { if(!IsPlayerInAnyVehicle(playerid)) { if(!IsPlayerInAnyVehicle(strval(tmp))) { if(IsPlayerConnected(strval(tmp))) { if(GetPlayerMoney(strval(tmp) > 0)) { if(GetDistanceBetweenPlayers(playerid, strval(tmp)) <= 8) { if(RecentlyRobbed[strval(tmp)] == 0) { if(GetPlayerMoney(strval(tmp)) > 4999) { new string[250], string2[250], string3[250], robbedcash, robbedname[MAX_PLAYER_NAME], robbername[MAX_PLAYER_NAME]; robbedcash = random(5000); GetPlayerName(playerid, robbername, sizeof(robbername)); GetPlayerName(strval(tmp), robbedname, sizeof(robbedname)); format(string, sizeof(string), "You have robbed $%d from %s[ID:%d]", robbedcash, robbedname, strval(tmp)); SendClientMessage(playerid, SERVER_COLOR, string); format(string2, sizeof(string2), "%s[ID:%d] has robbed $%d from you!", robbername, playerid, robbedcash); SendClientMessage(strval(tmp), RED, string2); format(string3, sizeof(string3), "[HQ] %s has robbed $%d from %s.", robbername, robbedname, robbedcash); SendRadioMessageToCops(string3); GivePlayerMoney(playerid, robbedcash); GivePlayerMoney(strval(tmp), -robbedcash); RecentlyRobbed[strval(tmp)] = 60; GivePlayerScore(playerid, 1); if(gTeam[strval(tmp)] == CIVILIAN) { SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)+ 2); } if(gTeam[strval(tmp)] == COP || gTeam[strval(tmp)] == SWAT || gTeam[strval(tmp)] == FBI || gTeam[strval(tmp)] == ARMY || gTeam[strval(tmp)] == Medic) { SetPlayerWantedLevel(playerid,GetPlayerWantedLevel(playerid)+ 5); } SetPlayerRobbingSkill(playerid, GetPlayerRobbingSkill(playerid)+1); return true; } else if(GetPlayerMoney(strval(tmp)) < 4999) { new string[250], recentlyrobber[MAX_PLAYER_NAME]; GetPlayerName(strval(tmp), recentlyrobber, sizeof(recentlyrobber)); format(string, sizeof(string), "%s[ID:%d] don't have enought money.", recentlyrobber, strval(tmp)); return SendClientMessage(playerid, ERROR, string); } } else if(RecentlyRobbed[strval(tmp)] > 0) { new string[250], recentlyrobber[MAX_PLAYER_NAME]; GetPlayerName(strval(tmp), recentlyrobber, sizeof(recentlyrobber)); format(string, sizeof(string), "%s[ID:%d] has been robbed recently. Try again later.", recentlyrobber, strval(tmp)); return SendClientMessage(playerid, ERROR, string); } else { new string[250], faraway[MAX_PLAYER_NAME]; GetPlayerName(strval(tmp), faraway, sizeof(faraway)); format(string, sizeof(string), "%s[ID:%d] is too far away.", faraway, strval(tmp)); return SendClientMessage(playerid, ERROR, string); } } else if(GetPlayerMoney(strval(tmp)) == 0) { new string[250], poor[MAX_PLAYER_NAME]; GetPlayerName(strval(tmp), poor, sizeof(poor)); format(string, sizeof(string), "%s[ID:%d] does not have any money.", poor, strval(tmp)); return SendClientMessage(playerid, ERROR, string); } } } else if(!IsPlayerConnected(strval(tmp))) { new string[250]; format(string, sizeof(string), "ID %d is not connected.", strval(tmp)); return SendClientMessage(playerid, ERROR, string); } } else if(IsPlayerInAnyVehicle(strval(tmp))) { new string[250], invehicle[MAX_PLAYER_NAME]; GetPlayerName(strval(tmp), invehicle, sizeof(invehicle)); format(string, sizeof(string), "%s[ID:%d] is in a vehicle. You cannot rob him.", invehicle, strval(tmp)); return SendClientMessage(playerid, ERROR, string); } } else if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, ERROR, "You cannot rob anyone from inside a vehicle."); } else return SendClientMessage(playerid, ERROR, "You cannot rob yourself."); } else return SendClientMessage(playerid, ERROR, "Only CIVILIANS can use this command!"); } } return 1; }