commands for admin?
#1

Hi all,how to set this 2 commands only for rcon admins?

Код:
   if (strcmp("/fix", cmdtext, true) == 0 || strcmp("/vrepair", cmdtext, true) == 0) if(GetPlayerState(playerid)-1) return RepairVehicle(GetPlayerVehicleID(playerid)),ChangeVehicleColor(GetPlayerVehicleID(playerid),random(126),random(126)), SendClientMessage(playerid, 0xAAFFCC33, "Vehicle colored & repaired!"); else return SendClientMessage(playerid, 0xFF9933AA, "You have to be a driver in a vehicle!");
Код:
if(!strcmp(cmd, "/nos", true))
    {
        if(IsPlayerInInvalidNosVehicle(playerid, GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, COLOR_RED, "This car can't have NOS!");
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You need to be inside a vehicle to do this!");
        AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        GivePlayerMoney(playerid, -2500);
        PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
        return true;
    }
Thanks
Reply
#2

Add (IsPlayerAdmin(playerid)
Reply
#3

There is a function called IsPlayerAdmin(playerid) (https://sampwiki.blast.hk/wiki/IsPlayerAdmin)
You can use this as you did with IsPlayerInInvalidNOSVehicle
Reply
#4

just add (IsPlayerAdmin(playerid) to your script
Reply
#5

pawn Код:
if(!strcmp(cmd, "/nos", true))
{
    if(!IsPlayerAdmin(playerid)) return return SendClientMessage(playerid, COLOR_RED, "You aren't admin!");
    else if(!IsPlayerInAnyVehicle(playerid, GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, COLOR_RED, "This car can't have NOS!");
    else if(IsPlayerInInvalidNosVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You need to be inside a vehicle to do this!");
    {
        AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        GivePlayerMoney(playerid, -2500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
        return 1;
    }
}
Reply
#6

IsPlayerInAnyVehicle has only one parameter, which is playerid, also it is used to check if a player is in a vehicle (any).
https://sampwiki.blast.hk/wiki/IsPlayerInAnyVehicle


pawn Код:
if(!strcmp(cmd, "/nos", true))
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You aren't admin!");
    else if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You have to be in a vehicle");
    else if(IsPlayerInInvalidNosVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "NOS can't be added on this vehicle!");
    {
        AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        GivePlayerMoney(playerid, -2500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
        return 1;
    }
}
Reply
#7

Quote:
Originally Posted by The_Moddler
Посмотреть сообщение
pawn Код:
if(!strcmp(cmd, "/nos", true))
{
    if(!IsPlayerAdmin(playerid)) return return SendClientMessage(playerid, COLOR_RED, "You aren't admin!");
    else if(!IsPlayerInAnyVehicle(playerid, GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, COLOR_RED, "This car can't have NOS!");
    else if(IsPlayerInInvalidNosVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You need to be inside a vehicle to do this!");
    {
        AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        GivePlayerMoney(playerid, -2500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
        return 1;
    }
}
is incirrect he returning no values heres the thing

pawn Код:
if(!strcmp(cmd, "/nos", true))
{
    if(!IsPlayerAdmin(playerid)) return 1;
    SendClientMessage(playerid, COLOR_RED, "You aren't admin!");
    else if(!IsPlayerInAnyVehicle(playerid, GetPlayerVehicleID(playerid))) return SendClientMessage(playerid,   COLOR_RED, "This car can't have NOS!");
    else if(IsPlayerInInvalidNosVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "You need to be inside a vehicle to do this!");
    {
        AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        GivePlayerMoney(playerid, -2500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
        return 1;
    }
}
Reply
#8

Quote:
Originally Posted by pushingmyluck
Посмотреть сообщение
is incirrect he returning no values heres the thing

pawn Код:
if(!strcmp(cmd, "/nos", true))
{
    if(!IsPlayerAdmin(playerid)) return 1;
    SendClientMessage(playerid, COLOR_RED, "You aren't admin!");
}
SendClientMessage will be called even if the player is logged in as an RCON admin, because it's not affected by the if statement.

pawn Код:
if ( !IsPlayerAdmin( playerid ) )
    return SendClientMessage( playerid, -1, "You're not an admin" );
pawn Код:
if ( !IsPlayerAdmin( playerid ) )
{
    SendClientMessage( playerid, -1, "You are not allowed to use this command" );
    SendClientMessage( playerid, -1, "You have to be logged in as an RCON admin" );
}
If you want to control more than 1 functions with the if statement or any other, use braces {}.
Reply
#9

pawn Код:
if(!strcmp(cmd, "/nos", true))
{
    if(!IsPlayerAdmin(playerid))
{
 SendClientMessage(playerid, COLOR_RED, "You aren't admin!");
}
else
{
    else if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You have to be in a vehicle");
    else if(IsPlayerInInvalidNosVehicle(playerid)) return SendClientMessage(playerid, COLOR_ORANGE, "NOS can't be added on this vehicle!");
    {
        AddVehicleComponent(GetPlayerVehicleID(playerid), 1010);
        GivePlayerMoney(playerid, -2500);
        PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
        return 1;
    }
}
}
Reply
#10

Quote:
Originally Posted by [NoV]LaZ
Посмотреть сообщение
SendClientMessage will be called even if the player is logged in as an RCON admin, because it's not affected by the if statement.

pawn Код:
if ( !IsPlayerAdmin( playerid ) )
    return SendClientMessage( playerid, -1, "You're not an admin" );
pawn Код:
if ( !IsPlayerAdmin( playerid ) )
{
    SendClientMessage( playerid, -1, "You are not allowed to use this command" );
    SendClientMessage( playerid, -1, "You have to be logged in as an RCON admin" );
}
If you want to control more than 1 functions with the if statement or any other, use braces {}.
was in a rush :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)