Please A need a little help here
#1

Hello There! i need some help about my server arrest system.
I want that if player is in a police vehcie Or Player is On Foot and wanted suspect is Only on foot. So player could arrest suspect by press 2 In Vehicle And MMB On Foot.
But There is problem while a player is in police vehicle he can't arrest wanted suspect and while both (player And wanted Suspect Be on Foot) then player can arrest The suspect by Press Mouse Middle Button.
So Please Help Me.

My Arrest Command:

dcmd_arrest(playerid, params[])
{
if (PlayerInfo[playerid][pSpawn] == 1)
{
if (PlayerInfo[playerid][pTeam] == TEAM_LAW || PlayerInfo[playerid][pVigilante] == 1)
{
new vehid, modelid;
vehid = GetPlayerVehicleID(playerid);
modelid = GetVehicleModel(vehid);

if(PlayerInfo[playerid][pKidnapped] > -1)
{
SendClientMessage(playerid,COLOR_ERROR,"You Have Been Kidnapped And You Cannot Arrest");
return 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] >= 6 && GetDistanceBetweenPlayers(playerid,i) <
{

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) >
{
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 (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(giveplayerid))
{

if (!IsPlayerInAnyVehicle(playerid) || IsPlayerInAnyVehicle(playerid) && CarInfo[modelid][cType] == VEHICLE_TYPE_LAW_ENFOREMENT)
{

ApplyAnimation(playerid, "PED", "ARRESTgun",3.0 ,0 ,1 ,1 ,1 ,0 ,1);

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 $5500.",PlayerInfo[giveplayerid][pName],giveplayerid);
SendClientMessage(playerid, COLOR_SERVER_HELP_MSG, string);
format(string, sizeof(string), "~b~Arrested ~w~%s",PlayerInfo[giveplayerid][pName]);
ShowDescriptionText(playerid,string);

ServerInfo[sCityArrests]++;


GivePlayerMoney(playerid, 5500);
PlayerInfo[playerid][pEarnings] += 5500;
PlayerInfo[playerid][pWorks] ++ ;

SetPlayerScore(playerid,GetPlayerScore(playerid) + 1);

PlayerInfo[giveplayerid][pJailHour] =1*2;
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]);
ShowDescriptionText(giveplayerid,string);

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 || PlayerInfo[giveplayerid][pMission] == MISSION_TYPE_BANK_ROBBERY_1 || PlayerInfo[giveplayerid][pMission] == MISSION_TYPE_BANK_ROBBERY_2 || PlayerInfo[giveplayerid][pMission] == MISSION_TYPE_ROBBERY)
{
if (PlayerInfo[giveplayerid][pHoldupAmount] > 0)
{
format(string, sizeof(string), "You Have Been Arrested. Robbery 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 $25000 Bonus.");

GivePlayerMoney(playerid, 25000);
PlayerInfo[playerid][pEarnings] += 25000;
}
}
SetPlayerWantedLevel(giveplayerid,0);
PlayerInfo[giveplayerid][pWantedLevel] = 0;
PlayerInfo[giveplayerid][pGunLic] = 0;
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] ++;
if(PlayerInfo[playerid][pCredits] <= 17)
{
PlayerInfo[playerid][pCredits] += 3;
}else{
PlayerInfo[playerid][pCredits] = 20;
}
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;
}



And OnPlayerKeyStateChange:


if (newkeys == KEY_LOOK_BEHIND)
{
if (PlayerInfo[playerid][pSpawn] == 1)
{
if(PlayerInfo[playerid][pTeam] == TEAM_LAW || PlayerInfo[playerid][pVigilante] == 1)
{
for (new i = 0; i < GetMaxPlayers(); i++)
{
if (IsPlayerConnected(i) && i != playerid && PlayerInfo[i][pSpawn] == 1 && GetDistanceBetweenPlayers(playerid,i) < 40)
{
if (!IsPlayerNPC(i) && PlayerInfo[i][pWantedLevel] > 0 && PlayerInfo[i][pWantedLevel] < 6)
{
PlayerCount ++;
if (PlayerCount > 0)suspectid = i;
break;
}
}
}
for (new i = 0; i < GetMaxPlayers(); i++)
{
if (IsPlayerConnected(i) && i != playerid && PlayerInfo[i][pSpawn] == 1 && GetDistanceBetweenPlayers(playerid,i) < 30)
{
if (PlayerInfo[i][pTeam] == TEAM_LAW || PlayerInfo[i][pVigilante] == 1)
{
if (PlayerInfo[playerid][pTicket] > 0)
{
PlayerCount ++;
if (PlayerCount > 0)copid = i;
break;
}
}
}
}
for (new i = 0; i < GetMaxPlayers(); i++)
{
if (IsPlayerConnected(i) && i != playerid && PlayerInfo[i][pSpawn] == 1 && GetDistanceBetweenPlayers(playerid,i) < 13)
{
if (!IsPlayerNPC(i) && PlayerInfo[i][pWantedLevel] > 5)
{
PlayerCount ++;
if (PlayerCount > 0)warrantid = i;
break;
}
}
}
if (PlayerCount == 0 && PlayerInfo[playerid][pTutorial] == 6)return SendClientMessage(playerid, COLOR_ERROR, "No Suspects In Range.");

if (copid > -1)
{
if (PlayerInfo[playerid][pWantedLevel] > 0 && PlayerInfo[playerid][pWantedLevel] < 6 && PlayerInfo[playerid][pTicket] > 0)
{
format(string, sizeof(string), "%d",copid);
return dcmd_pay(playerid, string);
}
}

if (warrantid > -1)
{
if (PlayerInfo[warrantid][pWantedLevel] > 5)
{
format(string, sizeof(string), "%d",warrantid);
return dcmd_arrest(playerid, string);
}
}

if (suspectid > -1)
{
if (PlayerInfo[suspectid][pWantedLevel] > 0 && PlayerInfo[suspectid][pWantedLevel] < 6 && PlayerInfo[suspectid][pTicket] == 0)
{
format(string, sizeof(string), "%d",suspectid);
return dcmd_ticket(playerid, string);
}else{
if (PlayerInfo[suspectid][pWantedLevel] > 0 && PlayerInfo[suspectid][pWantedLevel] < 6 && PlayerInfo[suspectid][pTicket] > 0)
{
format(string, sizeof(string), "%d",suspectid);
return dcmd_pullover(playerid, string);
}
}
}

}
}
}


PLEASE HELP ME ASAP!
Reply
#2

If keys are problem, read this:
https://sampwiki.blast.hk/wiki/Keys
Reply
#3

there is no problem with keys . read my post again bro
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)