/swat and /duty problem
#1

My problem is that i can use the commands /swat and /duty anywhere i am, not just in the locker room as supposed.

Swat command:
pawn Код:
if(strcmp(cmd, "/swat", true) == 0)
    {
        if(PlayerInfo[playerid][pMember]==1 || PlayerInfo[playerid][pLeader] == 1)
        {
            if(swat[playerid] == 0)
            {
                if(authorizeswat == 1)
                {
                    if (PlayerToPoint(3, playerid,255.3,77.4,1003.6) || PlayerInfo[playerid][pLocal] != 255)
                    {

                        ResetPlayerWeapons(playerid);
                        swat[playerid] = 1;
                        SetPlayerSkin(playerid, 285);

                        GivePlayerWeapon(playerid, 31, 500);
                        GivePlayerWeapon(playerid, 34, 150);
                        GivePlayerWeapon(playerid, 32, 730);
                        GivePlayerWeapon(playerid, 27, 250);

                        SetPlayerArmour(playerid, 100);
                        SetPlayerHealth(playerid, 100);

                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        format(string,sizeof(string), "* %s puts on his S.W.A.T uniform.", sendername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    }
                }
                else { SendClientMessage(playerid, COLOR_GREY, "SWAT is not authorized by a high command!"); }
            }
            else
            {
                if(PlayerInfo[playerid][pLeader] == 1) { SetPlayerSkin(playerid, 281); }
                if(PlayerInfo[playerid][pRank]==5) { SetPlayerSkin(playerid, 281); }
                if(PlayerInfo[playerid][pRank]==4) { SetPlayerSkin(playerid, 281); }
                if(PlayerInfo[playerid][pRank]==3) { SetPlayerSkin(playerid, 281); }
                if(PlayerInfo[playerid][pRank]==2) { SetPlayerSkin(playerid, 267); }
                if(PlayerInfo[playerid][pRank]==1) { SetPlayerSkin(playerid, 266); }

                swat[playerid] = 0;
                ResetPlayerWeapons(playerid);
                GivePlayerWeapon(playerid, 24, 500);
                GivePlayerWeapon(playerid, 3, 0);
                SetPlayerArmour(playerid, 0);
                SetPlayerHealth(playerid, 100);
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string,sizeof(string), "* %s puts his S.W.A.T uniform back in the locker.", sendername);
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);

            }
        }
        if(!IsACop(playerid) || PlayerInfo[playerid][pLeader] > 1 || PlayerInfo[playerid][pLeader] < 1)
        {
            SendClientMessage(playerid, COLOR_GREY, "You are not a cop!");
        }
        return 1;
    }
Duty command:
pawn Код:
if(strcmp(cmd, "/duty", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3)
            {
                if (PlayerToPoint(3, playerid,255.3,77.4,1003.6) || PlayerToPoint(3,playerid,-1616.1294,681.1594,7.1875) || PlayerInfo[playerid][pLocal] != 255)
                {
                    if(OnDuty[playerid]==0)
                    {
                        format(string, sizeof(string), "* Officer %s took a Badge and a Gun from his locker.", sendername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        GivePlayerWeapon(playerid, 24, 500);
                        GivePlayerWeapon(playerid, 3, 0);
                        GivePlayerWeapon(playerid, 29, 500);
                        OnDuty[playerid] = 1;
                        SetPlayerArmour(playerid, 100);
                        SetPlayerHealth(playerid, 100);
                    }
                    else if(OnDuty[playerid]==1)
                    {
                        format(string, sizeof(string), "* Officer %s places his Badge and Gun in his locker.", sendername);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        GivePlayerWeapon(playerid, 22, 150);
                        GivePlayerWeapon(playerid, 5, 0);
                        OnDuty[playerid] = 0;
                        SetPlayerHealth(playerid, 100);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD2, "   You are not in a locker room !");
                    return 1;
                }
            }
            else if(PlayerInfo[playerid][pMember] == 4||PlayerInfo[playerid][pLeader] == 4)
            {
                if(JobDuty[playerid] == 1)
                {
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You are now Off Duty from your Medic Job and will not receive calls anymore.");
                    JobDuty[playerid] = 0;
                    Medics -= 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You are now On Duty with your Medic Job and will receive calls from people in need.");
                    JobDuty[playerid] = 1;
                    Medics += 1;
                }
            }
            else if(PlayerInfo[playerid][pJob] == 7)
            {
                if(JobDuty[playerid] == 1)
                {
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You are now Off Duty from your Car Mechanic Job and will not receive calls anymore.");
                    JobDuty[playerid] = 0;
                    Mechanics -= 1;
                }
                else
                {
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You are now On Duty with your Car Mechanic Job and will receive calls from people in need.");
                    JobDuty[playerid] = 1;
                    Mechanics += 1;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "   You are not a Cop !");
            }
        }
        return 1;
    }
Reply
#2

PHP код:
if (PlayerToPoint(3playerid,255.3,77.4,1003.6) || PlayerInfo[playerid][pLocal] != 255
Can i know what "pLocal" stands for ?


And.. you better use IsPlayerInRangeOfPoint.
Reply
#3

I fixed it, i removed the PlayerInfo[playerid][pLocal != 255) and it works normal now. I tried the IsPlayerInRangeOfPoint but i can't use the command, it only works with PlayerToPoint
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)