09.10.2015, 06:14
(
Last edited by itsCody; 09/10/2015 at 06:44 AM.
)
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.
Any help is appreciated thanks.
Fixed:
Basically I just put the loop and SkillData stuff outside of the checks.
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 i = 0; i <= 12; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 24, 250);
GivePlayerWeapon(playerid, 29, 250);
GivePlayerWeapon(playerid, 27, 250);
GivePlayerWeapon(playerid, 31, 250);
SetPlayerSkin(playerid, 281);
PlayerSkill[playerid] = SKILL_NONE;
PlayerJob[playerid] = JOB_POLICE;
SetPlayerTeam(playerid, JOB_POLICE);
SetPlayerColor(playerid, COLOR_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(playerid, SkillData[01]);
PlayerJob[playerid] = JOB_NONE;
SetPlayerTeam(playerid, NO_TEAM);
SetPlayerColor(playerid, COLOR_WHITE);
ResetPlayerWeapons(playerid);
for (new i = 0; i <= 12; i++)
{
GivePlayerWeapon(playerid, weapons[i][0], weapons[i][1]);
}
PlayerInfo[playerid][On_Duty] = 0;
SendClientMessage(playerid, -1, "You are now off-duty");
}
}
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 i = 0; i <= 12; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
}
if(PlayerInfo[playerid][On_Duty] != 1)
{
ResetPlayerWeapons(playerid);
GivePlayerWeapon(playerid, 24, 250);
GivePlayerWeapon(playerid, 29, 250);
GivePlayerWeapon(playerid, 27, 250);
GivePlayerWeapon(playerid, 31, 250);
SetPlayerSkin(playerid, 281);
PlayerSkill[playerid] = SKILL_NONE;
PlayerJob[playerid] = JOB_POLICE;
SetPlayerTeam(playerid, JOB_POLICE);
SetPlayerColor(playerid, COLOR_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(playerid, SkillData[01]);
PlayerJob[playerid] = JOB_NONE;
SetPlayerTeam(playerid, NO_TEAM);
SetPlayerColor(playerid, COLOR_WHITE);
ResetPlayerWeapons(playerid);
for (new i = 0; i <= 12; i++)
{
GivePlayerWeapon(playerid, weapons[i][0], weapons[i][1]);
}
PlayerInfo[playerid][On_Duty] = 0;
SendClientMessage(playerid, -1, "You are now off-duty");
}
}