What am I doing wrong on this command?
#1

Hello, I'm trying to make a command for admins only, and when I try to compile it, I get a message saying it crashed and it never compiles. This is what I got so far.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/test", cmdtext, true, 12) == 0)
    {
        if(AirBreakVar[playerid] == 0)
        {
            if (!IsPlayerAdmin(playerid)) return SendClientMessage, 0xFF0000FF, "You're not authorized to use this Command");
            if(IsPlayerInAnyVehicle(playerid) == 0)
            {
                AirBreakVar[playerid] = 1;
                SetCameraBehindPlayer(playerid);

                TogglePlayerControllable(playerid, 0);
                SendClientMessage(playerid, yellow, "Air Break on, /abset to change the move distance, /aboff to turn off");
            }
            else
            {
                SendClientMessage(playerid, red, "You can not activate Air Break when in a vehicle");
            }
        }
        else
        {
            SendClientMessage(playerid, red, "Your Air Break is already on");
        }
        return 1;
    }
I have a feeling it's the
pawn Код:
if (!IsPlayerAdmin(playerid)) return SendClientMessage, 0xFF0000FF, "You're not authorized to use this Command");
But I'm not sure. Any help would be appreciated.
Reply
#2

There's nothing wrong with the line you outlined. Is that your entire OnPlayerCommandText callback?

Also why do you specify a length of 12 in strcmp? There's no need to specify a length at all!
Reply
#3

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(
strcmp(cmdtext"/test"true) == 0)
    {
        if(
AirBreakVar[playerid] == 0)
        {
            if (!
IsPlayerAdmin(playerid)) return SendClientMessage0xFF0000FF"You're not authorized to use this Command");
            if(
IsPlayerInAnyVehicle(playerid) == 0)
            {
                
AirBreakVar[playerid] = 1;
                
SetCameraBehindPlayer(playerid);
                
TogglePlayerControllable(playerid0);
                
SendClientMessage(playeridyellow"Air Break on, /abset to change the move distance, /aboff to turn off");
            }
            else
            {
                
SendClientMessage(playeridred"You can not activate Air Break when in a vehicle");
            }
        }
        else
        {
            
SendClientMessage(playeridred"Your Air Break is already on");
        }
        return 
1;
    } 
Not sure, but try it.
Reply
#4

Quote:
Originally Posted by G4M3Ov3r
Посмотреть сообщение
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(
strcmp(cmdtext"/test"true) == 0)
    {
        if(
AirBreakVar[playerid] == 0)
        {
            if (!
IsPlayerAdmin(playerid)) return SendClientMessage0xFF0000FF"You're not authorized to use this Command");
            if(
IsPlayerInAnyVehicle(playerid) == 0)
            {
                
AirBreakVar[playerid] = 1;
                
SetCameraBehindPlayer(playerid);
                
TogglePlayerControllable(playerid0);
                
SendClientMessage(playeridyellow"Air Break on, /abset to change the move distance, /aboff to turn off");
            }
            else
            {
                
SendClientMessage(playeridred"You can not activate Air Break when in a vehicle");
            }
        }
        else
        {
            
SendClientMessage(playeridred"Your Air Break is already on");
        }
        return 
1;
    } 
Not sure, but try it.
I just tried, but get this message when I try to compile. Something is making it crash.
Reply
#5

Quote:
Originally Posted by rangerxxll
Посмотреть сообщение
I just tried, but get this message when I try to compile. Something is making it crash.
Try removing the whole command, and compile, if it doesn't work, it means you're missing a bracket somewhere, if it works, its from the code, and I'll check it out and fix it for you.
Reply
#6

Well since you didn't answer my question, I'm going to assume that this is the entire OnPlayerCommandText callback and you quite clearly forgot to close it off at the end, here is what you need to add:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/test", cmdtext, true) == 0)
    {
        if(AirBreakVar[playerid] == 0)
        {
            if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You're not authorized to use this Command");
            if(IsPlayerInAnyVehicle(playerid) == 0)
            {
                AirBreakVar[playerid] = 1;
                SetCameraBehindPlayer(playerid);

                TogglePlayerControllable(playerid, 0);
                SendClientMessage(playerid, yellow, "Air Break on, /abset to change the move distance, /aboff to turn off");
            }
            else
            {
                SendClientMessage(playerid, red, "You can not activate Air Break when in a vehicle");
            }
        }
        else
        {
            SendClientMessage(playerid, red, "Your Air Break is already on");
        }
        return 1;
    }
    return 0;
}
Reply
#7

Quote:
Originally Posted by G4M3Ov3r
Посмотреть сообщение
Try removing the whole command, and compile, if it doesn't work, it means you're missing a bracket somewhere, if it works, its from the code, and I'll check it out and fix it for you.
When I remove
pawn Код:
if (!IsPlayerAdmin(playerid)) return SendClientMessage, 0xFF0000FF, "You're not authorized to use this Command");
It compiles just fine.
Reply
#8

pawn Код:
if(!IsPlayerAdmin(playerid)) return SendClientMessage, 0xFF0000FF, "You're not authorized to use this Command");
Try that.
Reply
#9

pawn Код:
if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0xFF0000FF, "You're not authorized to use this Command");
Reply
#10

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Well since you didn't answer my question, I'm going to assume that this is the entire OnPlayerCommandText callback and you quite clearly forgot to close it off at the end, here is what you need to add:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/test", cmdtext, true) == 0)
    {
        if(AirBreakVar[playerid] == 0)
        {
            if (!IsPlayerAdmin(playerid)) return SendClientMessage, 0xFF0000FF, "You're not authorized to use this Command");
            if(IsPlayerInAnyVehicle(playerid) == 0)
            {
                AirBreakVar[playerid] = 1;
                SetCameraBehindPlayer(playerid);

                TogglePlayerControllable(playerid, 0);
                SendClientMessage(playerid, yellow, "Air Break on, /abset to change the move distance, /aboff to turn off");
            }
            else
            {
                SendClientMessage(playerid, red, "You can not activate Air Break when in a vehicle");
            }
        }
        else
        {
            SendClientMessage(playerid, red, "Your Air Break is already on");
        }
        return 1;
    }
    return 0;
}
Still does not work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)