Makeing Custom Plate Commands
#1

Alright so I got this code here. It allows me to change a vehicle plate. But i want it to Admin level 4 and up can use it only. I've been playing around but i just fail some how. Could any one help

Код:
CMD:plate( playerid, params[] )
{
        if( isnull( params ) )
            return SendClientMessage( playerid, -1, "Syntax: /plate [plate(1-32 letters)]" );
 
        if( strlen( params ) > 32 )
            return SendClientMessage( playerid, -1, "Syntax: /plate [plate(1-32 letters)]" );
 
        if( !IsPlayerInAnyVehicle( playerid ) )
            return SendClientMessage( playerid, -1, "Error: You need to be in a vehicle." );
 
 
        new szString[128], pVeh, Float:vPos[4];
        pVeh = GetPlayerVehicleID( playerid );
 
        format( v_Plate[pVeh], 32, "%s", params );
        SetVehicleNumberPlate( pVeh, params );
 
        GetPlayerPos( playerid, vPos[0], vPos[1], vPos[2] );
        GetVehicleZAngle( pVeh, vPos[3] );
        SetVehicleToRespawn( pVeh );
        SetVehiclePos( pVeh, vPos[0], vPos[1], vPos[2] );
        SetVehicleZAngle( pVeh, vPos[3] );
        PutPlayerInVehicle( playerid, pVeh, 0 );
 
        format( szString, 128, "Your vehicle plate has succesfully changed to %s.", params );
        SendClientMessage( playerid, -1, szString );
 
        return 1;
}
 
CMD:setplate( playerid, params[] )
{
        new iVictim, szPlate[32];
        if( sscanf( params, "us[32]", iVictim, szPlate ) )
            return SendClientMessage( playerid, -1, "Syntax: /plate [playerid][plate(1-32 letters)]" );
 
        if( strlen( szPlate ) > 32 )
            return SendClientMessage( playerid, -1, "Syntax: /plate [playerid][plate(1-32 letters)]" );
 
        if( !IsPlayerAdmin( playerid ) )
            return SendClientMessage( playerid, -1, "Error: You're not an administrator." );
 
        if( !IsPlayerConnected( iVictim ) )
            return SendClientMessage( playerid, -1, "Error: That player isn't connected." );
 
        if( !IsPlayerInAnyVehicle( iVictim ) )
            return SendClientMessage( playerid, -1, "Error: That player isn't in a vehicle." );
 
        new szString[128], pVeh, Float:vPos[4];
        pVeh = GetPlayerVehicleID( iVictim );
 
        format( v_Plate[pVeh], 32, "%s", szPlate );
        SetVehicleNumberPlate( pVeh, szPlate );
 
        GetPlayerPos( iVictim, vPos[0], vPos[1], vPos[2] );
        GetVehicleZAngle( pVeh, vPos[3] );
        SetVehicleToRespawn( pVeh );
        SetVehiclePos( pVeh, vPos[0], vPos[1], vPos[2] );
        SetVehicleZAngle( pVeh, vPos[3] );
        PutPlayerInVehicle( iVictim, pVeh, 0 );
 
        format( szString, 128, "An administrator set your vehicle plate to %s.", szPlate );
        SendClientMessage( playerid, -1, szString );
 
        return 1;
}
 
CMD:getplate( playerid, params[] )
{
        if( isnull( params ) )
                return SendClientMessage( playerid, -1, "Syntax: /getplate [vehicleid]" );
 
        new szString[128];
        format( szString, 128, "[ VEHICLE ID: %d | PLATE: %s ]", strval( params ), v_Plate[strval( params )] );
        SendClientMessage( playerid, -1, szString );
 
        return 1;
}
Reply
#2

pawn Код:
CMD:plate( playerid, params[] )
{
    if(/*admingvariable*/ >= 4)
    {
        if( isnull( params ) )
            return SendClientMessage( playerid, -1, "Syntax: /plate [plate(1-32 letters)]" );

        if( strlen( params ) > 32 )
            return SendClientMessage( playerid, -1, "Syntax: /plate [plate(1-32 letters)]" );

        if( !IsPlayerInAnyVehicle( playerid ) )
            return SendClientMessage( playerid, -1, "Error: You need to be in a vehicle." );


        new szString[128], pVeh, Float:vPos[4];
        pVeh = GetPlayerVehicleID( playerid );

        format( v_Plate[pVeh], 32, "%s", params );
        SetVehicleNumberPlate( pVeh, params );

        GetPlayerPos( playerid, vPos[0], vPos[1], vPos[2] );
        GetVehicleZAngle( pVeh, vPos[3] );
        SetVehicleToRespawn( pVeh );
        SetVehiclePos( pVeh, vPos[0], vPos[1], vPos[2] );
        SetVehicleZAngle( pVeh, vPos[3] );
        PutPlayerInVehicle( playerid, pVeh, 0 );

        format( szString, 128, "Your vehicle plate has succesfully changed to %s.", params );
        SendClientMessage( playerid, -1, szString );
    }
    else return SendClientMessage(playerid, -1, "You must be a level 4 admin to access this command!");
    return 1;
}
You didn't state whether you wanted it on both commands or just one. Obviously, change /*adminvariable*/ to your administrator variable. If you don't have one, create it, make it save, etcetra. In your second command, it says "IsPlayerAdmin" meaning if the player is rcon admin, change that to the code I provided above ((if(adminvariable >= 4))) to change it to the level 4 admin.

EDIT: Didn't see the third command. Like I said, you never specified whether you wanted it on one command or all of them. Please be more specific next time.
Reply
#3

Ahhh cool thanks, Yeah how would i input tha tto all of the commands.
Reply
#4

Actually that popped up a bunch of errors. So i tried adding this to them all.

Код:
if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][p] >= 1)
            return SendClientMessage( playerid, -1, "Error: You're not an administrator." );
But hmm still errors.

EDIT: My admin variable is if(PlayerInfo[playerid][pAdmin] >= 4
Reply
#5

Hmm That above didn't work. Still trying.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)