SA-MP Forums Archive
Urgent, Cop only command - 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: Urgent, Cop only command (/showthread.php?tid=501916)



Urgent, Cop only command - Mriss - 21.03.2014

Okay SO I made this command that cops can only use
pawn Код:
COMMAND:ar(playerid,params[])
{
    new pId;
    new pskin = GetPlayerSkin(playerid);
    if(gTeam[playerid] != TEAM_COPS)
    {
        if(sscanf(params, "d", pId)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /ar [ID]");
            else if(!IsPlayerConnected(pId)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
                else
                {
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(pId, x, y, z);
                    if(IsPlayerInRangeOfPoint(playerid, 12.0, x, y, z))
                    {
                        new pname[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME], string1[250], string2[256], string3[100], string4[100];
                        GetPlayerName(playerid, pname, sizeof(pname));
                        GetPlayerName(pId, aname, sizeof(aname));
                        if (GetPlayerWantedLevel(pId) == 0)
                        {
                            SendClientMessage(playerid, 0xFF0000AA, "This Player Is Not Wanted!");
                            return 1;
                        }
                        else if (GetPlayerWantedLevel(pId) == 1)
                        {
                            SendClientMessage(playerid, 0xFF0000AA, "Error: this player has to high of a wanted level use /tk");
                            return 1;
                        }
                        else if (GetPlayerWantedLevel(pId) > 1)
                        {
                            new WantedLevel = GetPlayerWantedLevel(pId);
                            SetPlayerInterior(pId, 3);
                            new rand = random(sizeof(JailCellSpawns));
                            SetPlayerPos(pId, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
                            SetTimerEx("UnJail",WantedLevel*1000*60,0,"i",pId);
                            InJail[pId] = 1;
                            GivePlayerMoney(pId, -WantedLevel*1000);
                            GivePlayerMoney(playerid, WantedLevel*1000);
                            SetPlayerWantedLevel(pId, 0);
                            format(string1, sizeof(string1), "%s(%d) Has Ben Arrested By Officer %s(%d)", aname, pId, pname, playerid);
                            SendClientMessageToAll(0xFF0000AA, string1);
                            format(string2, sizeof(string2), "You Have Ben Sent To Jail For %s Minuets For Having A Level %s Wanted Level!", WantedLevel, WantedLevel);
                            SendClientMessage(pId, 0xFF0000AA, string2);
                            format(string3, sizeof(string3), "You Have Recived A %s000 Bonus For Arresting A Level %s Suspect!", WantedLevel, WantedLevel);
                            SendClientMessage(playerid, 0xFF0000AA, string3);
                            format(string4, sizeof(string4), "You Have Payed A %s000 Penalty On Your Arrest For Having A %s Wanted Level!", WantedLevel, WantedLevel);
                            SendClientMessage(pId, 0xFF0000AA, string4);
                            return 1;
                        }
                    }
                }
            }
            else
            {
                return SendClientMessage(playerid, 0xFF0000AA, "Error: You are not a police officer!");
            }
    return 1;
}
But When I log in game and choose cop it says You are not a police officer...


Re: Urgent, Cop only command - PrivatioBoni - 21.03.2014

Change: if(gTeam[playerid] != TEAM_COPS)

To

if(gTeam[playerid] == TEAM_COPS)

!= means NOT team cops, but you want to, in this case, look to see if they are.


Re: Urgent, Cop only command - iThePunisher - 21.03.2014

i this the error is at != TEAM_COPS
try this
pawn Код:
COMMAND:ar(playerid,params[])
{
    new pId;
    new pskin = GetPlayerSkin(playerid);
    if(gTeam[playerid] == TEAM_COPS)
    {
        if(sscanf(params, "d", pId)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /ar [ID]");
            else if(!IsPlayerConnected(pId)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
                else
                {
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(pId, x, y, z);
                    if(IsPlayerInRangeOfPoint(playerid, 12.0, x, y, z))
                    {
                        new pname[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME], string1[250], string2[256], string3[100], string4[100];
                        GetPlayerName(playerid, pname, sizeof(pname));
                        GetPlayerName(pId, aname, sizeof(aname));
                        if (GetPlayerWantedLevel(pId) == 0)
                        {
                            SendClientMessage(playerid, 0xFF0000AA, "This Player Is Not Wanted!");
                            return 1;
                        }
                        else if (GetPlayerWantedLevel(pId) == 1)
                        {
                            SendClientMessage(playerid, 0xFF0000AA, "Error: this player has to high of a wanted level use /tk");
                            return 1;
                        }
                        else if (GetPlayerWantedLevel(pId) > 1)
                        {
                            new WantedLevel = GetPlayerWantedLevel(pId);
                            SetPlayerInterior(pId, 3);
                            new rand = random(sizeof(JailCellSpawns));
                            SetPlayerPos(pId, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
                            SetTimerEx("UnJail",WantedLevel*1000*60,0,"i",pId);
                            InJail[pId] = 1;
                            GivePlayerMoney(pId, -WantedLevel*1000);
                            GivePlayerMoney(playerid, WantedLevel*1000);
                            SetPlayerWantedLevel(pId, 0);
                            format(string1, sizeof(string1), "%s(%d) Has Ben Arrested By Officer %s(%d)", aname, pId, pname, playerid);
                            SendClientMessageToAll(0xFF0000AA, string1);
                            format(string2, sizeof(string2), "You Have Ben Sent To Jail For %s Minuets For Having A Level %s Wanted Level!", WantedLevel, WantedLevel);
                            SendClientMessage(pId, 0xFF0000AA, string2);
                            format(string3, sizeof(string3), "You Have Recived A %s000 Bonus For Arresting A Level %s Suspect!", WantedLevel, WantedLevel);
                            SendClientMessage(playerid, 0xFF0000AA, string3);
                            format(string4, sizeof(string4), "You Have Payed A %s000 Penalty On Your Arrest For Having A %s Wanted Level!", WantedLevel, WantedLevel);
                            SendClientMessage(pId, 0xFF0000AA, string4);
                            return 1;
                        }
                    }
                }
            }
            else
            {
                return SendClientMessage(playerid, 0xFF0000AA, "Error: You are not a police officer!");
            }
    return 1;
}



Re: Urgent, Cop only command - BizzyD - 21.03.2014

Try this:

Код:
COMMAND:ar(playerid,params[])
{
    new pId;
    new pskin = GetPlayerSkin(playerid);
    if(gTeam[playerid] == TEAM_COPS) 
    {
        if(sscanf(params, "d", pId)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /ar [ID]");
            else if(!IsPlayerConnected(pId)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
                else
                {
                    new Float:x, Float:y, Float:z;
                    GetPlayerPos(pId, x, y, z);
                    if(IsPlayerInRangeOfPoint(playerid, 12.0, x, y, z))
                    {
                        new pname[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME], string1[250], string2[256], string3[100], string4[100];
                        GetPlayerName(playerid, pname, sizeof(pname));
                        GetPlayerName(pId, aname, sizeof(aname));
                        if (GetPlayerWantedLevel(pId) == 0)
                        {
                            SendClientMessage(playerid, 0xFF0000AA, "This Player Is Not Wanted!");
                            return 1;
                        }
                        else if (GetPlayerWantedLevel(pId) == 1)
                        {
                            SendClientMessage(playerid, 0xFF0000AA, "Error: this player has to high of a wanted level use /tk");
                            return 1;
                        }
                        else if (GetPlayerWantedLevel(pId) > 1)
                        {
                            new WantedLevel = GetPlayerWantedLevel(pId);
                            SetPlayerInterior(pId, 3);
                            new rand = random(sizeof(JailCellSpawns));
                            SetPlayerPos(pId, JailCellSpawns[rand][0], JailCellSpawns[rand][1], JailCellSpawns[rand][2]);
                            SetTimerEx("UnJail",WantedLevel*1000*60,0,"i",pId);
                            InJail[pId] = 1;
                            GivePlayerMoney(pId, -WantedLevel*1000);
                            GivePlayerMoney(playerid, WantedLevel*1000);
                            SetPlayerWantedLevel(pId, 0);
                            format(string1, sizeof(string1), "%s(%d) Has Ben Arrested By Officer %s(%d)", aname, pId, pname, playerid);
                            SendClientMessageToAll(0xFF0000AA, string1);
                            format(string2, sizeof(string2), "You Have Ben Sent To Jail For %s Minuets For Having A Level %s Wanted Level!", WantedLevel, WantedLevel);
                            SendClientMessage(pId, 0xFF0000AA, string2);
                            format(string3, sizeof(string3), "You Have Recived A %s000 Bonus For Arresting A Level %s Suspect!", WantedLevel, WantedLevel);
                            SendClientMessage(playerid, 0xFF0000AA, string3);
                            format(string4, sizeof(string4), "You Have Payed A %s000 Penalty On Your Arrest For Having A %s Wanted Level!", WantedLevel, WantedLevel);
                            SendClientMessage(pId, 0xFF0000AA, string4);
                            return 1;
                        }
                    }
                }
            }
            else
            {
                return SendClientMessage(playerid, 0xFF0000AA, "Error: You are not a police officer!");
            }
    return 1;
}