21.06.2015, 15:42
Hello!
My arrest command is a bit bugging,
when I type /arrest it says like "You can arrested when you are dead"
Heres the code:
My arrest command is a bit bugging,
when I type /arrest it says like "You can arrested when you are dead"
Heres the code:
PHP код:
COMMAND:arrest(playerid, params[])
{
new vehicleid = GetPlayerVehicleID(playerid);
if (PlayerInfo[playerid][pSpawn] == 1 && CarInfo[vehicleid][cType] == VEHICLE_TYPE_LAW_ENFOREMENT)
{
if (PlayerInfo[playerid][pTeam] == TEAM_LAW || PlayerInfo[playerid][pVigilante] == 1)
{
new idx,giveplayerid,string[256],tmp[256];
tmp = strtok(params, idx);
if (!strlen(tmp))
{
new WantedSuspects;
for (new i = 0; i < GetMaxPlayers(); i++)
{
if (IsPlayerConnected(i) && i != playerid && !IsPlayerNPC(i) && PlayerInfo[i][pSpawn] == 1 && PlayerInfo[i][pWantedLevel] > 5 && GetDistanceBetweenPlayers(playerid,i) < 10)
{
WantedSuspects ++;
if (WantedSuspects > 0)giveplayerid = i; break;
}
}
if (WantedSuspects == 0)
return SendClientMessage(playerid, COLOR_ERROR, "No Suspects In Range.");
}
else
{
if (!isNumeric(tmp))
{
giveplayerid = ReturnUser(playerid, tmp);
if (giveplayerid == INVALID_PLAYER_ID)
{
return 1;
}
}
else
{
giveplayerid = strval(tmp);
if (!IsPlayerConnected(giveplayerid))
{
format(string, sizeof(string), "%d Is Not A Valid ID.", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
}
}
if (giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Arrest Yourself.");
return 1;
}
if (GetDistanceBetweenPlayers(playerid,giveplayerid) > 5)
{
format(string, sizeof(string), "%s Is Not Close Enough To Arrest.",PlayerInfo[giveplayerid][pName]);
SendClientMessage(playerid,COLOR_ERROR, string);
return 1;
}
if (GetPlayerVirtualWorld(playerid) != GetPlayerVirtualWorld(giveplayerid))
{
SendClientMessage(playerid, COLOR_ERROR, "No Suspects In Range.");
return 1;
}
if (PlayerInfo[giveplayerid][pTeam] == TEAM_LAW || PlayerInfo[giveplayerid][pVigilante] == 1)
{
format(string, sizeof(string), "%s (%d) Is A Law Enforcement Agent And Cannot Be Arrested.",PlayerInfo[giveplayerid][pName],giveplayerid);
SendClientMessage(playerid,COLOR_ERROR, string);
return 1;
}
if (PlayerInfo[giveplayerid][pWantedLevel] < 6)
{
format(string, sizeof(string), "%s (%d) Does Not Have A Warrant Issued.",PlayerInfo[giveplayerid][pName],giveplayerid);
SendClientMessage(playerid,COLOR_ERROR, string);
return 1;
}
if (GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPlayerState(giveplayerid) != PLAYER_STATE_ONFOOT)
{
SendClientMessage(playerid, COLOR_ERROR, "No Suspects In Range.");
return 1;
}
if (PlayerInfo[giveplayerid][pAJailed] == 1)
{
format(string, sizeof(string), "%s (%i) Is Already In Jail.",PlayerInfo[giveplayerid][pName],giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if (PlayerInfo[giveplayerid][pJailed] == 1)
{
format(string, sizeof(string), "%s (%i) Is Already In Jail.",PlayerInfo[giveplayerid][pName],giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if (!IsPlayerInAnyVehicle(playerid))
{
ApplyAnimation(playerid, "PED", "ARRESTgun",3.0 ,0 ,1 ,1 ,1 ,0 ,1);
}
if (!IsPlayerInAnyVehicle(giveplayerid))
{
ApplyAnimation(giveplayerid, "PED", "handsup", 3.0, 0, 0, 0, 1, 0, 1);
}
format(string, sizeof(string), "Suspect %s (%i) Has Been Arrested By Officer %s (%i)",PlayerInfo[giveplayerid][pName],giveplayerid,PlayerInfo[playerid][pName],playerid);
SendClientMessageToAll(COLOR_SERVER_HELP_MSG, string);
format(string, sizeof(string), "You Have Arrested Suspect %s (%d) And Recieved A Cop Takedown Bonus Of $5000.",PlayerInfo[giveplayerid][pName],giveplayerid);
SendClientMessage(playerid, COLOR_SERVER_HELP_MSG, string);
format(string, sizeof(string), "~b~Arrested %s",PlayerInfo[giveplayerid][pName]);
GameTextForPlayer(playerid,string, 3000, 3);
ServerInfo[sCityArrests]++;
GivePlayerCash(playerid, 5000);
PlayerInfo[playerid][pEarnings] += 5000;
SetPlayerScore(playerid,GetPlayerScore(playerid) + 1);
SetPlayerScore(giveplayerid,GetPlayerScore(giveplayerid) - 1);
PlayerInfo[giveplayerid][pJailHour] =1*4;
PlayerInfo[giveplayerid][pJailMinute] = 1*PlayerInfo[giveplayerid][pWantedLevel];
PlayerInfo[giveplayerid][pBail] = PlayerInfo[giveplayerid][pWantedLevel]*1000;
format(string, sizeof(string), "BUSTED BY ~b~OFFICER %s",PlayerInfo[playerid][pName]);
GameTextForPlayer(giveplayerid,string, 1000, 0);
format(string, sizeof(string), "You Have Been Arrested By Officer %s (%d). Minimum Sentence: %d Hours, %d Minutes Bail: $%d",PlayerInfo[playerid][pName],playerid, PlayerInfo[giveplayerid][pJailHour],PlayerInfo[giveplayerid][pJailMinute],PlayerInfo[giveplayerid][pBail]);
SendClientMessage(giveplayerid, COLOR_SERVER_HELP_MSG, string);
if (PlayerInfo[giveplayerid][pHoldup] > 0 && PlayerInfo[giveplayerid][pMission] == MISSION_TYPE_STORE_ROBBERY)
{
if (PlayerInfo[giveplayerid][pHoldupAmount] > 0)
{
format(string, sizeof(string), "You Have Been Arrested. Holdup Failed. $%d Seized.", PlayerInfo[giveplayerid][pHoldupAmount]);
SendClientMessage(giveplayerid, COLOR_SERVER_HELP_MSG, string);
SendClientMessage(playerid, COLOR_SERVER_HELP_MSG, "You Have Stopped A Robbery And Received A $10000 Bonus.");
GivePlayerCash(playerid, 10000);
PlayerInfo[playerid][pEarnings] += 10000;
}
}
SetTimerEx("ArrestTimer", 2000, 0, "d", playerid);
SetTimerEx("ArrestTimer", 2000, 0, "d", giveplayerid);
TogglePlayerControllable(giveplayerid, 0);
SetPlayerWantedLevel(giveplayerid,0);
ResetPlayerWeapons(giveplayerid);
PlayerInfo[playerid][pArrests] ++;
PlayerInfo[giveplayerid][pArrested] ++;
IncreasePlayerRank(playerid);
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You Must Be A Law Enforcement Agent To Arrest Suspects.");
}
}
else
{
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command When You're Dead.");
}
return 1;
}