Command error
#1

I have a command which can be executed only by cops and admins level 5.

I have this check:

pawn Код:
if(gTeam[playerid] != TEAM_COP || Player[playerid][AccountLevel] < 5) return SCM(playerid, COLOR_LIGHTRED, "* You must be a law enforcement officer to remove a roadblock.");
But doesn't work. It says i need to be a Law Enforcement Officer. (P.S I'm a civ with admin level 5).
Reply
#2

I do not see anything wrong with that line, are you sure the problem is there?

Have you set the level correctly in 5 or greater than 5?

Show the complete code.
Reply
#3

TRY THIS!

Код:
if(gTeam[playerid] == TEAM_COP || Player[playerid][AccountLevel] < 5) return SCM(playerid, COLOR_LIGHTRED, "* You must be a law enforcement officer to remove a roadblock.");
Reply
#4

Quote:
Originally Posted by UFF
Посмотреть сообщение
TRY THIS!

Код:
if(gTeam[playerid] == TEAM_COP || Player[playerid][AccountLevel] < 5) return SCM(playerid, COLOR_LIGHTRED, "* You must be a law enforcement officer to remove a roadblock.");
Dude, you setted it like this
Код:
gTeam[playerid] == TEAM_COP
it will now check that if the player is cop then he get that error that he needs to be law.

Edit: Use This
PHP код:
if(gTeam[playerid] != TEAM_COP && Player[playerid][AccountLevel] < 5) return SCM(playeridCOLOR_LIGHTRED"* You must be a law enforcement officer to remove a roadblock."); 
&& will check that if the player is anything from those 2 options then he will be allowed to use the cmd.
Reply
#5

Ok thanks. I have another problem referred to this command too.

pawn Код:
CMD:rrb(playerid, params[])
{
    if(gTeam[playerid] != TEAM_COP && Player[playerid][AccountLevel] < 5) return SCM(playerid, COLOR_LIGHTRED, "* You must be a law enforcement officer to remove a roadblock.");

    if (Player[playerid][AccountLevel] < 5) return 0;

    if(Player[playerid][Jailed] == 1) return SCM(playerid, COLOR_LIGHTRED, "* You can't use this command while jailed.");

    SendNearbyMessage(playerid, 30.0, COLOR_BBLUE, "* %s has picked up a roadblock object.", ReturnName(playerid, 0));
   
    new string[100];
    format(string,sizeof(string),"* [DISPATCHER]: %s has picked up a roadblock.",  ReturnName(playerid, 0));
    SendMessageToCops(string);
   
    for(new i = 0; i < sizeof(Roadblocks); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, Roadblocks[i][sX], Roadblocks[i][sY], Roadblocks[i][sZ]))
        {
            if(Roadblocks[i][sCreated] == 1)
            {
                Roadblocks[i][sCreated] = 0;
                Roadblocks[i][sX] = 0.0;
                Roadblocks[i][sY] = 0.0;
                Roadblocks[i][sZ] = 0.0;
                DestroyDynamicObject(Roadblocks[i][sObject]);
            }
        }
        else
        {
            SCM(playerid, COLOR_LIGHTRED, "* You are not near a roadblock.");
        }
    }
    return 1;
}
This command should remove a single roadblock object in a range of 5 meters from the player. Problem is, i get spammed with "you are not near a roadblock".
Reply
#6

Quote:

CMD:rrb(playerid, params[])
{
if(gTeam[playerid] != TEAM_COP && Player[playerid][AccountLevel] < 5) return SCM(playerid, COLOR_LIGHTRED, "* You must be a law enforcement officer to remove a roadblock.");

if (Player[playerid][AccountLevel] < 5) return 0;

if(Player[playerid][Jailed] == 1) return SCM(playerid, COLOR_LIGHTRED, "* You can't use this command while jailed.");

SendNearbyMessage(playerid, 30.0, COLOR_BBLUE, "* %s has picked up a roadblock object.", ReturnName(playerid, 0));

new string[100];
format(string,sizeof(string),"* [DISPATCHER]: %s has picked up a roadblock.", ReturnName(playerid, 0));
SendMessageToCops(string);

for(new i = 0; i < sizeof(Roadblocks); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 5.0, Roadblocks[i][sX], Roadblocks[i][sY], Roadblocks[i][sZ]))
{
// --- Pay Attention fixed if(Roadblocks[playerid][sCreated] == 1)
{
Roadblocks[i][sCreated] = 0;
Roadblocks[i][sX] = 0.0;
Roadblocks[i][sY] = 0.0;
Roadblocks[i][sZ] = 0.0;
DestroyDynamicObject(Roadblocks[i][sObject]);
}
}
else
{
SCM(playerid, COLOR_LIGHTRED, "* You are not near a roadblock.");
}
}
return 1;
}

// --- Pay Attention fixed if(Roadblocks[playerid][sCreated] == 1)
Reply
#7

Quote:
Originally Posted by SaMuRy
Посмотреть сообщение
// --- Pay Attention fixed if(Roadblocks[playerid][sCreated] == 1)
what are you doing dude?
please dont post if you dont know whats the real matter okay.


PHP код:
CMD:rrb(playeridparams[])
{
    if(
gTeam[playerid] != TEAM_COP && Player[playerid][AccountLevel] < 5) return SCM(playeridCOLOR_LIGHTRED"* You must be a law enforcement officer to remove a roadblock.");
    if (
Player[playerid][AccountLevel] < 5) return 0;
    if(
Player[playerid][Jailed] == 1) return SCM(playeridCOLOR_LIGHTRED"* You can't use this command while jailed.");
    
SendNearbyMessage(playerid30.0COLOR_BBLUE"* %s has picked up a roadblock object."ReturnName(playerid0));
    
    new 
string[100];
    
format(string,sizeof(string),"* [DISPATCHER]: %s has picked up a roadblock.",  ReturnName(playerid0));
    
SendMessageToCops(string);
    new 
countrb=0;
    for(new 
0sizeof(Roadblocks); i++)
    {
        if(
IsPlayerInRangeOfPoint(playerid5.0Roadblocks[i][sX], Roadblocks[i][sY], Roadblocks[i][sZ]))
        {
            if(
Roadblocks[i][sCreated] == 1)
            {
                
Roadblocks[i][sCreated] = 0;
                
Roadblocks[i][sX] = 0.0;
                
Roadblocks[i][sY] = 0.0;
                
Roadblocks[i][sZ] = 0.0;
                
DestroyDynamicObject(Roadblocks[i][sObject]);
                
countrb++;
            }
        }
    }
    if(
countrb>0)
    {
        
SCM(playeridCOLOR_LIGHTRED"* You are not near a roadblock.");
    }
    return 
1;

use this
Reply
#8

remove AccountLevel one ur using it 2 times
Reply
#9

Ok gonna test later. About the gteam and admin level check, hold on:

pawn Код:
if(gTeam[playerid] != TEAM_COP && Player[playerid][AccountLevel] < 5
Doing in this way will check if player is not a cop AND has an admin level lower than 5. I don't have to do in this way.

I need to check if is only a civilian (TEAM_CIVILIAN) OR an admin with level 5.

With your check EVERY admin from 0 to 4 is allowed to execute that command (even players since their admin level is 0!).

Or im wrong?
Reply
#10

if you using < then it will allow all the admin levels like
if you d <1 then it will allowed for 1-max levels
if you do <5 then it will allowed for 5- max levels
if you do <7 then it will allowed for 7- max levels

it works like this

and to make your command for law enforcer you are using correct
you are using Account Level 2 times thats why maybe its not working for the team cops.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)