SA-MP Forums Archive
Minor help - 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: Minor help (/showthread.php?tid=591177)



Minor help - itsCody - 09.10.2015

When I walk into the checkpoint, it puts me on-duty, however when I leave and re-enter the checkpoint it won't put me off-duty. I've also redid the code without the "else if(...)" and still nothing, did anybody else have this issue or is it some general bug or am I not doing something correctly.

Sorry if the code is messy, I'll clean it up when I get it working.


PHP Code:
if(checkpointid == CheckPoints[03]) // Police on/off-duty
    
{
        if(
GetPlayerWantedLevel(playerid) != 0)
            return 
SendClientMessage(playerid, -1"You are not able to go on-duty while wanted.");
            
        if(
PlayerInfo[playerid][On_Duty] != 1)
        {
            new 
SkillData[2], weapons[13][2];
            
SkillData[00] = PlayerSkill[playerid];
            
SkillData[01] = PlayerInfo[playerid][Player_Skin];
            for (new 
0<= 12i++)
            {
                
GetPlayerWeaponData(playeridiweapons[i][0], weapons[i][1]);
            }
            
ResetPlayerWeapons(playerid);
            
            
GivePlayerWeapon(playerid24250);
            
GivePlayerWeapon(playerid29250);
            
GivePlayerWeapon(playerid27250);
            
GivePlayerWeapon(playerid31250);
            
            
SetPlayerSkin(playerid281);
            
PlayerSkill[playerid] = SKILL_NONE;
            
PlayerJob[playerid] = JOB_POLICE;
            
SetPlayerTeam(playeridJOB_POLICE);
            
SetPlayerColor(playeridCOLOR_BLUE);
            
PlayerInfo[playerid][On_Duty] = 1;
            
SendClientMessage(playerid, -1"You are now on-duty");
        }
        
        else if(
PlayerInfo[playerid][On_Duty] == 1)
        {
            
PlayerSkill[playerid] = SkillData[00];
            
SetPlayerSkin(playeridSkillData[01]);
            
PlayerJob[playerid] = JOB_NONE;
            
SetPlayerTeam(playeridNO_TEAM);
            
SetPlayerColor(playeridCOLOR_WHITE);
            
ResetPlayerWeapons(playerid);
            for (new 
0<= 12i++)
            {
                
GivePlayerWeapon(playeridweapons[i][0], weapons[i][1]);
            }
            
PlayerInfo[playerid][On_Duty] = 0;
            
SendClientMessage(playerid, -1"You are now off-duty");
        }
    } 
Any help is appreciated thanks.

Fixed:

PHP Code:
if(checkpointid == CheckPoints[03]) // Police on/off-duty
    
{
        if(
GetPlayerWantedLevel(playerid) != 0)
            return 
SendClientMessage(playerid, -1"You are not able to go on-duty while wanted.");
            
        new 
SkillData[2], weapons[13][2];
        
SkillData[00] = PlayerSkill[playerid];
        
SkillData[01] = PlayerInfo[playerid][Player_Skin];
        for (new 
0<= 12i++)
        {
            
GetPlayerWeaponData(playeridiweapons[i][0], weapons[i][1]);
        }
            
        if(
PlayerInfo[playerid][On_Duty] != 1)
        {
            
ResetPlayerWeapons(playerid);
            
            
GivePlayerWeapon(playerid24250);
            
GivePlayerWeapon(playerid29250);
            
GivePlayerWeapon(playerid27250);
            
GivePlayerWeapon(playerid31250);
            
            
SetPlayerSkin(playerid281);
            
PlayerSkill[playerid] = SKILL_NONE;
            
PlayerJob[playerid] = JOB_POLICE;
            
SetPlayerTeam(playeridJOB_POLICE);
            
SetPlayerColor(playeridCOLOR_BLUE);
            
PlayerInfo[playerid][On_Duty] = 1;
            
SendClientMessage(playerid, -1"You are now on-duty");
        }
        
        else if(
PlayerInfo[playerid][On_Duty] == 1)
        {
            
PlayerSkill[playerid] = SkillData[00];
            
SetPlayerSkin(playeridSkillData[01]);
            
PlayerJob[playerid] = JOB_NONE;
            
SetPlayerTeam(playeridNO_TEAM);
            
SetPlayerColor(playeridCOLOR_WHITE);
            
ResetPlayerWeapons(playerid);
            for (new 
0<= 12i++)
            {
                
GivePlayerWeapon(playeridweapons[i][0], weapons[i][1]);
            }
            
PlayerInfo[playerid][On_Duty] = 0;
            
SendClientMessage(playerid, -1"You are now off-duty");
        }
    } 
Basically I just put the loop and SkillData stuff outside of the checks.


Re: Minor help - xTURBOx - 09.10.2015

You are not setting on duty to 1 on first place


Re: Minor help - itsCody - 09.10.2015

Quote:
Originally Posted by xTURBOx
View Post
You are not setting on duty to 1 on first place
If you looked down it states
PHP Code:
PlayerInfo[playerid][On_Duty] = 1
SendClientMessage(playerid, -1"You are now on-duty"); 
Anyway I fixed the issue. Will post fix above.