Minor help
#1

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.
Reply


Messages In This Thread
Minor help - by itsCody - 09.10.2015, 06:14
Re: Minor help - by xTURBOx - 09.10.2015, 06:36
Re: Minor help - by itsCody - 09.10.2015, 06:41

Forum Jump:


Users browsing this thread: 1 Guest(s)