SA-MP Forums Archive
Arrest Command not Working! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Arrest Command not Working! (/showthread.php?tid=578695)



Arrest Command not Working! - Charalambos26 - 21.06.2015

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:
PHP код:
COMMAND:arrest(playeridparams[])
{
    new 
vehicleid GetPlayerVehicleID(playerid);
    if (
PlayerInfo[playerid][pSpawn] == && 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(paramsidx);
            if (!
strlen(tmp))
            {
                new 
WantedSuspects;
                for (new 
0GetMaxPlayers(); i++)
                {
                    if (
IsPlayerConnected(i) && != playerid && !IsPlayerNPC(i) && PlayerInfo[i][pSpawn] == && PlayerInfo[i][pWantedLevel] > && GetDistanceBetweenPlayers(playerid,i) < 10)
                    {
                        
WantedSuspects ++;
                        if (
WantedSuspects 0)giveplayerid i; break;
                    }
                }
                if (
WantedSuspects == 0)
                return 
SendClientMessage(playeridCOLOR_ERROR"No Suspects In Range.");
                }
                else
                {
                if (!
isNumeric(tmp))
                {
                    
giveplayerid ReturnUser(playeridtmp);
                    if (
giveplayerid == INVALID_PLAYER_ID)
                    {
                        return 
1;
                    }
                }
                else
                {
                    
giveplayerid strval(tmp);
                    if (!
IsPlayerConnected(giveplayerid))
                    {
                        
format(stringsizeof(string), "%d Is Not A Valid ID."giveplayerid);
                        
SendClientMessage(playeridCOLOR_ERRORstring);
                        return 
1;
                    }
                }
            }
            if (
giveplayerid == playerid)
            {
                
SendClientMessage(playeridCOLOR_ERROR"You Cannot Arrest Yourself.");
                return 
1;
            }
            if (
GetDistanceBetweenPlayers(playerid,giveplayerid) > 5)
            {
                
format(stringsizeof(string), "%s Is Not Close Enough To Arrest.",PlayerInfo[giveplayerid][pName]);
                
SendClientMessage(playerid,COLOR_ERRORstring);
                return 
1;
            }
            if (
GetPlayerVirtualWorld(playerid) != GetPlayerVirtualWorld(giveplayerid))
            {
                
SendClientMessage(playeridCOLOR_ERROR"No Suspects In Range.");
                return 
1;
            }
            if (
PlayerInfo[giveplayerid][pTeam] == TEAM_LAW || PlayerInfo[giveplayerid][pVigilante] == 1)
            {
                
format(stringsizeof(string), "%s (%d) Is A Law Enforcement Agent And Cannot Be Arrested.",PlayerInfo[giveplayerid][pName],giveplayerid);
                
SendClientMessage(playerid,COLOR_ERRORstring);
                return 
1;
            }
            if (
PlayerInfo[giveplayerid][pWantedLevel] < 6)
            {
                
format(stringsizeof(string), "%s (%d) Does Not Have A Warrant Issued.",PlayerInfo[giveplayerid][pName],giveplayerid);
                
SendClientMessage(playerid,COLOR_ERRORstring);
                return 
1;
            }
            if (
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPlayerState(giveplayerid) != PLAYER_STATE_ONFOOT)
            {
                
SendClientMessage(playeridCOLOR_ERROR"No Suspects In Range.");
                return 
1;
            }
            if (
PlayerInfo[giveplayerid][pAJailed] == 1)
            {
                
format(stringsizeof(string), "%s (%i) Is Already In Jail.",PlayerInfo[giveplayerid][pName],giveplayerid);
                
SendClientMessage(playeridCOLOR_ERRORstring);
                return 
1;
            }
            if (
PlayerInfo[giveplayerid][pJailed] == 1)
            {
                
format(stringsizeof(string), "%s (%i) Is Already In Jail.",PlayerInfo[giveplayerid][pName],giveplayerid);
                
SendClientMessage(playeridCOLOR_ERRORstring);
                return 
1;
            }
            if (!
IsPlayerInAnyVehicle(playerid))
            {
                
ApplyAnimation(playerid"PED""ARRESTgun",3.0 ,,,,,,1);
            }
            if (!
IsPlayerInAnyVehicle(giveplayerid))
            {
                
ApplyAnimation(giveplayerid"PED",  "handsup"3.0000101);
            }
            
format(stringsizeof(string), "Suspect %s (%i) Has Been Arrested By Officer %s (%i)",PlayerInfo[giveplayerid][pName],giveplayerid,PlayerInfo[playerid][pName],playerid);
            
SendClientMessageToAll(COLOR_SERVER_HELP_MSGstring);
            
format(stringsizeof(string), "You Have Arrested Suspect %s (%d) And Recieved A Cop Takedown Bonus Of $5000.",PlayerInfo[giveplayerid][pName],giveplayerid);
            
SendClientMessage(playeridCOLOR_SERVER_HELP_MSGstring);
            
format(stringsizeof(string), "~b~Arrested %s",PlayerInfo[giveplayerid][pName]);
            
GameTextForPlayer(playerid,string30003);
            
ServerInfo[sCityArrests]++;
            
GivePlayerCash(playerid5000);
            
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(stringsizeof(string), "BUSTED BY ~b~OFFICER %s",PlayerInfo[playerid][pName]);
            
GameTextForPlayer(giveplayerid,string10000);
            
format(stringsizeof(string), "You Have Been Arrested By Officer %s (%d). Minimum Sentence: %d Hours, %d Minutes Bail: $%d",PlayerInfo[playerid][pName],playeridPlayerInfo[giveplayerid][pJailHour],PlayerInfo[giveplayerid][pJailMinute],PlayerInfo[giveplayerid][pBail]);
            
SendClientMessage(giveplayeridCOLOR_SERVER_HELP_MSGstring);
            if (
PlayerInfo[giveplayerid][pHoldup] > && PlayerInfo[giveplayerid][pMission] == MISSION_TYPE_STORE_ROBBERY)
            {
                if (
PlayerInfo[giveplayerid][pHoldupAmount] > 0)
                {
                    
format(stringsizeof(string), "You Have Been Arrested. Holdup Failed. $%d Seized."PlayerInfo[giveplayerid][pHoldupAmount]);
                    
SendClientMessage(giveplayeridCOLOR_SERVER_HELP_MSGstring);
                    
SendClientMessage(playeridCOLOR_SERVER_HELP_MSG"You Have Stopped A Robbery And Received A $10000 Bonus.");
                    
GivePlayerCash(playerid10000);
                    
PlayerInfo[playerid][pEarnings] += 10000;
                }
            }
            
SetTimerEx("ArrestTimer"20000"d"playerid);
            
SetTimerEx("ArrestTimer"20000"d"giveplayerid);
            
TogglePlayerControllable(giveplayerid0);
            
SetPlayerWantedLevel(giveplayerid,0);
            
ResetPlayerWeapons(giveplayerid);
            
PlayerInfo[playerid][pArrests] ++;
            
PlayerInfo[giveplayerid][pArrested] ++;
            
IncreasePlayerRank(playerid);
        }
        else
        {
            
SendClientMessage(playeridCOLOR_ERROR"You Must Be A Law Enforcement Agent To Arrest Suspects.");
        }
    }
    else
    {
        
SendClientMessage(playeridCOLOR_ERROR"You Cannot Use This Command When You're Dead.");
    }
    return 
1;




Re: Arrest Command not Working! - Stanford - 21.06.2015

Try changing this:
pawn Код:
if (PlayerInfo[playerid][pSpawn] == 1 && CarInfo[vehicleid][cType] == VEHICLE_TYPE_LAW_ENFOREMENT)
to:

pawn Код:
if (PlayerInfo[playerid][pSpawn] == 1 && vehicleid == VEHICLE_TYPE_LAW_ENFOREMENT)
I hope I helped any feedback is appreciated!!


Re: Arrest Command not Working! - Charalambos26 - 21.06.2015

Still not working!


Re: Arrest Command not Working! - Dusan01 - 21.06.2015

probbably u didnt set under public OnPlayerSpawn:
PHP код:
PlayerInfo[playerid][pSpawn] = 1
and use code like this:
PHP код:
if (PlayerInfo[playerid][pSpawn] == && vehicleid == VEHICLE_TYPE_LAW_ENFOREMENT
check that and let me know is it working, if u have PlayerInfo[playerid][pSpawn] = 1; setted try code like this:
PHP код:
if (PlayerInfo[playerid][pSpawn] == 1



Re: Arrest Command not Working! - Charalambos26 - 21.06.2015

Still not working.