25.08.2013, 06:05
pawn Код:
if(strcmp(cmd, "/arrest", true) == 0 || strcmp(cmd, "/ar", true) == 0)
{
new string[128];
new ID;
if(IsSpawned[ID] == 0)
{
SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
return 1;
}
if(IsCuffed[playerid] == 0)
{
format(string,sizeof(string),"%s(%d) is not cuffed. You have to place the suspect in cuffs before attempted to arrest them.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != ARMY && gTeam[playerid] != FBI)
{
SendClientMessage(playerid,COLOR_ERROR,"You are not a Law Enforcement officer ");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /(ar)rrest(id)");
return 1;
}
giveplayerid = strval(tmp);
if(!IsNumeric(tmp))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /(ar)rrest (id)");
return 1;
}
if(!IsPlayerConnected(giveplayerid))
{
format(string, sizeof(string), "ID (%d) is not an active player", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
new oname[24];
new pname[24];
GetPlayerName(playerid,oname, 24);
GetPlayerName(giveplayerid, pname, 24);
if(GetPlayerWantedLevel(giveplayerid) <= 3)
{
format(string, sizeof(string), "%s(%d) does not have a warrant. You cannot arrest a player without a warrant",pname,giveplayerid);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot arrest a suspect if you are in a car");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 10)
{
format(string, sizeof(string), "%s(%d) is too far away. You cannot arrest that player",pname,giveplayerid);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(IsSpawned[giveplayerid] == 0)
{
format(string, sizeof(string), "%s(%d) is dead. You cannot arrest a dead body",pname,giveplayerid);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
SetPlayerVirtualWorld(giveplayerid,0);
if(GetPlayerWantedLevel(playerid) >=1)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot use this command if you are wanted by the police");
return 1;
}
if(giveplayerid == playerid)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot arrest yourself");
return 1;
}
new spawn = random(sizeof(PrisonSpawn)), string2[250], Float:health, copname[MAX_PLAYER_NAME], arrested[MAX_PLAYER_NAME];
GetPlayerName(playerid, copname, sizeof(copname));
GetPlayerName(strval(tmp), arrested, sizeof(arrested));
GetPlayerHealth(strval(tmp), health);
SendClientMessage(strval(tmp), GREY, "|_| San Andreas Police Dept. |_|");
format(string, sizeof(string), "You have been arrested by Law Enforcement Officer %s (%d).", copname);
SendClientMessage(strval(tmp), WHITE, string);
ResetPlayerWeapons(strval(tmp));
SetPlayerPos(strval(tmp), PrisonSpawn[spawn][0], PrisonSpawn[spawn][1], PrisonSpawn[spawn][2]);
SetPlayerFacingAngle(strval(tmp), PrisonSpawn[spawn][3]);
SetCameraBehindPlayer(strval(tmp));
if(GetPlayerWantedLevel(strval(tmp)) >= 4 && GetPlayerWantedLevel(strval(tmp)) <= 5)
{
PrisonTime[strval(tmp)] = 60;
GivePlayerMoney(playerid,25000);
GivePlayerScore(playerid,1);
}
else if(GetPlayerWantedLevel(strval(tmp)) >= 6 && GetPlayerWantedLevel(strval(tmp)) <= 8)
{
PrisonTime[strval(tmp)] = 120;
GivePlayerMoney(playerid,35000);
GivePlayerScore(playerid,1);
}
else if(GetPlayerWantedLevel(strval(tmp)) >= 9 && GetPlayerWantedLevel(playerid) <= 11)
{
PrisonTime[strval(tmp)] = 180;
GivePlayerMoney(playerid,45000);
GivePlayerScore(playerid,2);
}
else if(GetPlayerWantedLevel(strval(tmp)) >= 12 && GetPlayerWantedLevel(strval(tmp)) <= 14)
{
PrisonTime[strval(tmp)] = 240;
GivePlayerMoney(playerid,55000);
GivePlayerScore(playerid,2);
}
else if(GetPlayerWantedLevel(strval(tmp)) >= 15)
{
PrisonTime[strval(tmp)] = 300;
GivePlayerMoney(playerid,65000);
GivePlayerScore(playerid,3);
}
SetPlayerWantedLevel(strval(tmp), 0);
SetPlayerInterior(strval(tmp),3);
SetPlayerHealth(strval(tmp),99999);
TogglePlayerControllable(strval(tmp), true);
SetPlayerJailed(strval(tmp), true);
format(string2, sizeof(string2), "Law Enforcement Officer %s (%d) has arrested Wanted Suspect %s (%d).", copname, playerid, arrested, strval(tmp));
Announce(string2);
if(health <= 90)
{
SendClientMessage(strval(tmp), GREY, "|_| San Andreas Police Dept. |_|");
SendClientMessage(strval(tmp), WHITE, "SAPD has given you some food.");
SetPlayerHealth(strval(tmp), health+10);
IsCuffed[playerid] =0;
ApplyAnimation(strval(tmp), "FOOD", "EAT_Burger", 4.0, 0, 0, 0, 0, 0);
}
return 1;
}
I have a problem with this Arrest Command, Here I'll explain
Before I need to arrest a suspect, I need to cuff them. So I cuff ''suspect (id:2)'', I try to arrest the suspect and it says ''suspect (id:0)'' must be cuffed before arrest blablashit. I think it always returns to id 0! Please help
Here's my cuff command.
[QUOTE][CODE]dcmd_cuff(playerid,params[])
{
new string[128];
new ID;
if(sscanf(params, "u", ID))
{
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /cuff (Player Name/ID)");
return 1;
}
if(IsSpawned[playerid] != 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
return 1;
}
if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != FBI && gTeam[playerid] != ARMY)
{
SendClientMessage(playerid,COLOR_ERROR,"Only law enforcement can place cuffs on suspects.");
return 1;
}
if(!IsPlayerConnected(ID))
{
format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot cuff them",ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(GetDistanceBetweenPlayers(playerid,ID) > 4)
{
format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to place cuffs on him.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(gTeam[ID] == COP || gTeam[ID] == SWAT || gTeam[ID] == FBI || gTeam[ID] == ARMY)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot place other Law Enforcement officer in cuffs. You might lose your job for that ..");
return 1;
}
if(IsCuffed[ID] == 1)
{
format(string,sizeof(string),"%s(%d) is already cuffed. You don't want to waste a second pair of cuffs on them.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot place a suspect in cuffs while in a vehicle. Exit the vehicle first.");
return 1;
}
if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot place a suspect in cuffs while they are in a vehicle. Get them to exit the vehicle first.");
return 1;
}
if(playerid == ID)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot put cuffs on yourself, it wouldn't be a good idea with rapists around.");
return 1;
}
if(IsSpawned[ID] != 1)
{
format(string,sizeof(string),"%s(%d) is not spawned. You cannot place cuffs on dead people ..",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(GetDistanceBetweenPlayers(playerid,ID) <= 4)
{
SendClientMessage(playerid,COLOR_WHITE,"[[_Suspect Cuffed_]]");
format(string,sizeof(string),"You have placed cuffs on %s(%d)! They can no longer move.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
SendClientMessage(ID,COLOR_LIGHTBLUE,"[[_Placed in handcuffs_]]");
format(string,sizeof(string),"Law enforcement officer %s(%d) has placed you in handcuffs!",PlayerName(playerid),playerid);
SendClientMessage(ID,COLOR_LIGHTBLUE,string);
TogglePlayerControllable(ID,0);
ApplyAnimation(ID, "ped", "cower", 3.0, 1, 0, 0, 0, 0); // Taking Cover
IsCuffed[ID] =1;
return 1;
}
return 1;
}
Here's my Cuff command for you to check
pawn Код:
dcmd_cuff(playerid,params[])
{
new string[128];
new ID;
if(sscanf(params, "u", ID))
{
SendClientMessage(playerid,COLOR_ERROR,"USAGE: /cuff (Player Name/ID)");
return 1;
}
if(IsSpawned[playerid] != 1)
{
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
return 1;
}
if(gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != FBI && gTeam[playerid] != ARMY)
{
SendClientMessage(playerid,COLOR_ERROR,"Only law enforcement can place cuffs on suspects.");
return 1;
}
if(!IsPlayerConnected(ID))
{
format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot cuff them",ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(GetDistanceBetweenPlayers(playerid,ID) > 4)
{
format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to place cuffs on him.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(gTeam[ID] == COP || gTeam[ID] == SWAT || gTeam[ID] == FBI || gTeam[ID] == ARMY)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot place other Law Enforcement officer in cuffs. You might lose your job for that ..");
return 1;
}
if(IsCuffed[ID] == 1)
{
format(string,sizeof(string),"%s(%d) is already cuffed. You don't want to waste a second pair of cuffs on them.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot place a suspect in cuffs while in a vehicle. Exit the vehicle first.");
return 1;
}
if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot place a suspect in cuffs while they are in a vehicle. Get them to exit the vehicle first.");
return 1;
}
if(playerid == ID)
{
SendClientMessage(playerid,COLOR_ERROR,"You cannot put cuffs on yourself, it wouldn't be a good idea with rapists around.");
return 1;
}
if(IsSpawned[ID] != 1)
{
format(string,sizeof(string),"%s(%d) is not spawned. You cannot place cuffs on dead people ..",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_ERROR,string);
return 1;
}
if(GetDistanceBetweenPlayers(playerid,ID) <= 4)
{
SendClientMessage(playerid,COLOR_WHITE,"[[_Suspect Cuffed_]]");
format(string,sizeof(string),"You have placed cuffs on %s(%d)! They can no longer move.",PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
SendClientMessage(ID,COLOR_LIGHTBLUE,"[[_Placed in handcuffs_]]");
format(string,sizeof(string),"Law enforcement officer %s(%d) has placed you in handcuffs!",PlayerName(playerid),playerid);
SendClientMessage(ID,COLOR_LIGHTBLUE,string);
TogglePlayerControllable(ID,0);
ApplyAnimation(ID, "ped", "cower", 3.0, 1, 0, 0, 0, 0); // Taking Cover
IsCuffed[ID] =1;
return 1;
}
return 1;
}