SA-MP Forums Archive
LSPD job - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: LSPD job (/showthread.php?tid=163666)



LSPD job - baske007 - 28.07.2010

Hello everyone,

I have a problem: I made a script that makes a cop on/off duty. When I login, and I go to the locker room, everything is right. I type /duty, and I get the message: Officier ... is on duty. When I type /duty again, I get off duty. So that's good too. When I type it again, I get off duty again! Also, other commands/actions that require ponduty = 1 work fine after the third time. So, the first time /duty makes me on-duty, second time off duty, and all other attempts after the second, makes me off duty, but I already am...

pawn Код:
else if (strcmp("/duty", cmdtext, true) == 0)
    {
        if (pjob[playerid] == 1)
        {
            if(!IsPlayerInRangeOfPoint(playerid, 4.0, 223.51014709473, 188.08520507813, 1003.03125))
            {
                SendClientMessage(playerid, COLOR_RED, "You are not in the LSPD locker room!");
                return 1;
            }
            else
            {
                if (ponduty[playerid] == 0)
                {
                    ponduty[playerid] = 1;
                    format(message, sizeof(message), "Officer %s is now on duty");
                    lspdradio(message);
                    return 1;
                }
                else if (ponduty[playerid] == 1)
                {
                    format(message, sizeof(message), "Officer %s is now off duty");
                    lspdradio(message);
                    ponduty[playerid] = 0;
                    return 1;
                }
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "You aren't a cop, so you can't get on duty!");
            return 1;
        }

    }
I can't find the mistake

Bas


Re: LSPD job - Vince - 28.07.2010

As far as I can see everything looks good. Try removing the returns under if(ponduty .. , though.


Re: LSPD job - baske007 - 28.07.2010

I already tried that :S
Thanks for the reply anyway