Checkpoint[1] = CreateDynamicCP(1541.5448,-1655.8884,13.5590, 2.0, -1, -1, -1, 50);
if(checkpointid == Checkpoint[1])
{
new ID;
new pwl = GetPlayerWantedLevel(ID);
new i;
new string[256];
if(pwl == 4)
{
if(GetPlayerState(ID) == PLAYER_STATE_PASSENGER && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
TogglePlayerDynamicCP(playerid,Checkpoint[1], true);
format(string, sizeof(string), "Police Officer %s has arrested wanted suspect %s", PlayerInfo(playerid), PlayerInfo(ID));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
CNR_PrintString(string);
format(string, sizeof(string), "[POLICE RADIO] Suspect %s has been sent to jail", PlayerInfo(ID));
SendCopMessage(string);
AccountInfo[ID][pJailTime] = 60 ;
AccountInfo[ID][pJailed] = 1 ;
SetPlayerInterior(ID, 10);
new rnd = random(sizeof(PrisonSpawn));
SetPlayerPos(ID, PrisonSpawn[rnd][0], PrisonSpawn[rnd][1], PrisonSpawn[rnd][2]);
SendClientMessage(ID, COLOR_GREY, "**LOS SANTOS PRISON**");
SendClientMessage(ID, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison. You will be released soon.");
TogglePlayerControllable(ID, 1);
SetPlayerWantedLevel(ID, 0);
if(IsPlayerAttachedObjectSlotUsed(ID, i)) RemovePlayerAttachedObject(ID, i);
SetPlayerSpecialAction(ID, SPECIAL_ACTION_NONE);
AccountInfo[ID][pCuffed] = 0 ;
TextDrawHideForPlayer(playerid, CF[playerid]);
GivePlayerMoney(playerid, 6500);
IncreaseScore(playerid, 1);
TogglePlayerDynamicCP(ID, Checkpoint[1], false);
TogglePlayerDynamicCP(playerid, Checkpoint[1], false);
}
return 1;
}
if(pwl == 5)
{
if(GetPlayerState(ID) == PLAYER_STATE_PASSENGER && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
format(string, sizeof(string), "Police Officer %s has arrested wanted suspect %s", PlayerInfo(playerid), PlayerInfo(ID));
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
CNR_PrintString(string);
format(string, sizeof(string), "[POLICE RADIO] Suspect %s has been sent to jail", PlayerInfo(ID));
SendCopMessage(string);
AccountInfo[ID][pJailTime] = 80 ;
AccountInfo[ID][pJailed] = 1 ;
SetPlayerInterior(ID, 10);
new rnd = random(sizeof(PrisonSpawn));
SetPlayerPos(ID, PrisonSpawn[rnd][0], PrisonSpawn[rnd][1], PrisonSpawn[rnd][2]);
SendClientMessage(ID, COLOR_GREY, "**LOS SANTOS PRISON**");
SendClientMessage(ID, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison. You will be released soon.");
TogglePlayerControllable(ID, 1);
SetPlayerWantedLevel(ID, 0);
if(IsPlayerAttachedObjectSlotUsed(ID, i)) RemovePlayerAttachedObject(ID, i);
SetPlayerSpecialAction(ID, SPECIAL_ACTION_NONE);
AccountInfo[ID][pCuffed] = 0 ;
GivePlayerMoney(playerid, 7500);
IncreaseScore(playerid, 1);
TextDrawHideForPlayer(playerid, CF[playerid]);
TextDrawHideForPlayer(playerid, PNotifications[playerid]);
TogglePlayerDynamicCP(ID, Checkpoint[1], false);
}
return 1;
}
if(pwl == 6)
{
if(GetPlayerState(ID) == PLAYER_STATE_PASSENGER && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
format(string, sizeof(string), "Police Officer %s has arrested wanted suspect %s", PlayerInfo(playerid), PlayerInfo(ID));
SendClientMessageToAll(COLOR_BLUE, string);
CNR_PrintString(string);
format(string, sizeof(string), "[POLICE RADIO] Suspect %s has been sent to jail", PlayerInfo(ID));
SendCopMessage(string);
AccountInfo[ID][pJailTime] = 100 ;
AccountInfo[ID][pJailed] = 1 ;
SetPlayerInterior(ID, 10);
new rnd = random(sizeof(PrisonSpawn));
SetPlayerPos(ID, PrisonSpawn[rnd][0], PrisonSpawn[rnd][1], PrisonSpawn[rnd][2]);
SendClientMessage(ID, COLOR_GREY, "**LOS SANTOS PRISON**");
SendClientMessage(ID, COLOR_LIGHTBLUE, "[PRISON] You have been sent to prison. You will be released soon.");
TogglePlayerControllable(ID, 1);
SetPlayerWantedLevel(ID, 0);
if(IsPlayerAttachedObjectSlotUsed(ID, i)) RemovePlayerAttachedObject(ID, i);
SetPlayerSpecialAction(ID, SPECIAL_ACTION_NONE);
AccountInfo[ID][pCuffed] = 0 ;
GivePlayerMoney(playerid, 10000);
IncreaseScore(playerid, 1);
TogglePlayerDynamicCP(ID, Checkpoint[1], false);
TogglePlayerDynamicCP(playerid, Checkpoint[1], false);
}
return 1;
}
}
return 1;
}
cmd(detain, playerid, params[])
{
new ID; new string[200];
if(!IsCop(playerid))
return SendClientMessage(playerid, COLOR_RED, "You are not a Law Enforcement officer.");
if(AccountInfo[playerid][pSpawned] == 0)
return SendClientMessage(playerid, COLOR_RED, "You cannot use this command at this time.");
if(sscanf(params, "u", ID))
return SendClientMessage(playerid, COLOR_RED, "Usage: /detain (ID)");
if(!IsPlayerConnected(ID))
return SendClientMessage(playerid, COLOR_RED, "Invalid ID.");
if(AccountInfo[ID][pJailed] == 1)
{
format(string, sizeof(string), "~r~~h~You cannot detain a prisiner.");
TextDrawSetString(PNotifications[playerid],string);
TextDrawShowForPlayer(playerid, PNotifications[playerid]);
SetTimer("NTF", 3000, 0);
}
if(AccountInfo[ID][pCuffed] == 0)
{
format(string, sizeof(string), "~r~~h~You must cuff before detaining Suspect.");
TextDrawSetString(PNotifications[playerid],string);
TextDrawShowForPlayer(playerid, PNotifications[playerid]);
SetTimer("NTF", 3000, 0);
}
if(IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, COLOR_RED, "You cannot use this command in a vehicle.");
if(IsPlayerInAnyVehicle(ID))
return SendClientMessage(playerid, COLOR_RED, "You cannot detain that player. He/She is in a vehicle.");
if(playerid == ID)
return SendClientMessage(playerid, COLOR_RED, "You cannot detain yourself.");
if(AccountInfo[playerid][pLastVehicle] == 0)
return SendClientMessage(playerid, COLOR_RED, "You must enter a vehicle first.");
if(GetDistanceBetweenPlayers(playerid, ID) > 4)
return SendClientMessage(playerid, COLOR_RED, "That playeris too far away.");
if(GetPlayerWantedLevel(ID) <= 1)
return SendClientMessage(playerid, COLOR_RED, "You cannot detain this player.");
format(string, 200, "[DISPATCH] Officer %s has taken %s and detained them.",PlayerInfo(playerid), PlayerInfo(ID));
SendCopMessage(string);
format(string, 200, "[POLICE] Officer %s has detained %s.", PlayerInfo(playerid), PlayerInfo(ID));
SendClientMessageToAll(COLOR_DODGERBLUE, string);
CNR_PrintString(string);
SendClientMessage(playerid, COLOR_GREY, "**LOST SANTOS POLICE**");
SendClientMessage(playerid, COLOR_GREY, "You have been detained. You will be taken to jail shortly.");
AccountInfo[ID][pCuffed] = 1;
AccountInfo[ID][pCuffTimer] = 200;
TextDrawHideForPlayer(ID, CF[playerid]);
PutPlayerInVehicle(ID, AccountInfo[playerid][pLastVehicle], 1);
SetPlayerScore(playerid, 1);
GivePlayerMoney(playerid, 10000);
SetPlayerHealth(ID, 100);
TogglePlayerDynamicCP(playerid,Checkpoint[1], true);
TogglePlayerDynamicCP(ID,Checkpoint[1], true);
return 1;
}
Man, "ID" will always be 0 as it isn't being asigned a player id.
|
There's a lot of ways, you could store the detained player's id in a variable and use it to perform the action. It's up to you..
|
There's a lot of ways, you could store the detained player's id in a variable and use it to perform the action. It's up to you..
|