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 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");
}
}
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 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");
}
}
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
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.