20.06.2014, 13:05
I need help; I want to make it where when a cop in this case presses the 'Y' key it would stun the nearest player next to them if you could just add it in below? Heres the script I have currently I just need to make it where when a player presses the 'Y' key it automaticly stuns the nearest player to them.
Код:
command(stun, playerid, params[]) { #pragma unused params new string[128], NearestPlayer = GetClosestPlayer(playerid); if(Groups[Player[playerid][Group]][CommandTypes] != 1 && Groups[Player[playerid][Group]][CommandTypes] != 4) { SendClientMessage(playerid, WHITE, "You're not a law enforcement officer!"); } else if(Groups[Player[NearestPlayer][Group]][CommandTypes] == 1 || Groups[Player[NearestPlayer][Group]][CommandTypes] == 4) { SendClientMessage(playerid, WHITE, "Nearest player is a law enforcer!"); } else { if(GetDistanceBetweenPlayers(NearestPlayer, playerid) < 6) { if(Player[NearestPlayer][Tazed] == 0) { if(!IsPlayerInAnyVehicle(NearestPlayer)) { TogglePlayerControllable(NearestPlayer, false); Player[NearestPlayer][Tazed] = 1; format(string, sizeof(string), "* %s has stunned %s, with their taser.", GetName(playerid), GetName(NearestPlayer)); NearByMessage(playerid, PURPLE, string); SendClientMessage(NearestPlayer, WHITE, "You have been tased. The effect will last for 12 seconds."); SetTimerEx("UntazePlayer", 12000, false, "d", NearestPlayer); } else { SendClientMessage(playerid, WHITE, "The suspect is in a vehicle, you can't tase whilst they're in a vehicle."); } } else { SendClientMessage(playerid, WHITE, "That player is already stunned."); } } else { SendClientMessage(playerid, WHITE, "No players in range!"); } } return 1; }