Admin Vehicles
#1

hello all,

i was wondering if you could set a car purly for the admins to use, and let other players use them with permission from an admin (in command form, eg /giveadminvarrights 1)

is it possible?

thanks!
Reply
#2

The way i would do it would probably by defining the admin vehicles, and then do a check upon OnPlayerEnterVehicle (by a loop) if the vehicle is an admin vehicle.
And then of course, make a definition in the user's file/database row named "CanUseAdminCar" or something similar.

Shouldn't be too much hassle for you to do.
Reply
#3

First, get the id of the vehile (hint make a command that displays it!!) then do this under on player state change:

Код:
if(newstate == PLAYER_STATE_DRIVER)
{
if(!IsPlayerAdmin(playerid)) RemovePlayerFromVehicle(playerid);
}
Reply
#4

Quote:
Originally Posted by Bry4n
The way i would do it would probably by defining the admin vehicles, and then do a check upon OnPlayerEnterVehicle (by a loop) if the vehicle is an admin vehicle.
And then of course, make a definition in the user's file/database row named "CanUseAdminCar" or something similar.

Shouldn't be too much hassle for you to do.
if only, im new too scripting and have only just about managed how to add cars!
maybe you caoud post a pawno code?

cheers
Reply
#5

Quote:
Originally Posted by cj101
First, get the id of the vehile (hint make a command that displays it!!) then do this under on player state change:

Код:
if(newstate == PLAYER_STATE_DRIVER)
{
if(!IsPlayerAdmin(playerid)) RemovePlayerFromVehicle(playerid);
}
ok ill give it a shot
ill report back in a mo
Reply
#6

Quote:
Originally Posted by wilcock33
Quote:
Originally Posted by cj101
First, get the id of the vehile (hint make a command that displays it!!) then do this under on player state change:

Код:
if(newstate == PLAYER_STATE_DRIVER)
{
if(!IsPlayerAdmin(playerid)) RemovePlayerFromVehicle(playerid);
}
ok, where is the OnPlayertStateChange?
or do i add it to my script first?
ok ill give it a shot
ill report back in a mo
Reply
#7

i'll make u one if you want - i'm bored. Just tell me the admin vehicles you want locked. Also If you want a command, i'll make that, but the player would lose his permission to use admin commands once he re-connects, if that's ok?

Are you using an admin filterscipt or using the RCON admin? If you are using a filterscript, tell me what variable you use to identify if the player is an admin.
Reply
#8

Quote:
Originally Posted by [B2K
Hustler ]
i'll make u one if you want - i'm bored. Just tell me the admin vehicles you want locked. Also If you want a command, i'll make that, but the player would lose his permission to use admin commands once he re-connects, if that's ok?

Are you using an admin filterscipt or using the RCON admin? If you are using a filterscript, tell me what variable you use to identify if the player is an admin.
ok thanks alot for offereing, i could use some help
ok i am using the SeifAdmin script, and idk how we identify admins, we just know by there names lol
yes thats exactly what i want, they lose it when they disconnect
i want all the hydras and hunters LOCKED for admins only, and a command that givs players permission to use them

thanks!
Reply
#9

OK, No problem, I'll have a look at Seif Admin script and will edit this post with the command and code. See u in a bit. ( i mean post it in a bit).

EDIT: Ok this should work, i hope.

Open up your SeifAdmin filterscript file, not your gamemode. Press Ctrl+F and find this: new Missile[MAX_PLAYERS];
Then underneath that line put this:

pawn Код:
new bool:PlayerAllowedAdminVehicles[MAX_PLAYERS] = false;
Then after this callback/function:
pawn Код:
stock GetFileValue(string[])
paste this (modified version of Andre's IsCopCar function):
pawn Код:
stock IsAdminCar(carid)
{
  new Operative[] = { 520, 425, 432, 447 }; // Hydra, Hunter, Tank, Seasparrow, Add more by adding a ', [vehicleid]'
  for(new i = 0; i < sizeof(Operative); i++)
  {
    if(GetVehicleModel(carid) == Operative[i]) return 1;
  }
  return 0;
}
anywhere in your script (but outside any commands and callbacks).

Then after OnPlayerCommandText or after any command paste this:

pawn Код:
if(strcmp(cmd, "/allowadmincar", true) == 0) // Unfreezes the player
    {
        if (AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid)) /// Change Admin level here
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, ORANGE, "USAGE: /allowadmincar [playername/id]");
                SendClientMessage(playerid, ORANGE, "FUNCTION: Will allow player to access admin vehicles the specified player.");
                return 1;
            }
            new giveplayerid = ReturnUser(tmp);
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                new string2[128];
                GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "-| Administrator %s has allowed %s access to admin vehicles|-", sendername,giveplayername);
                format(string2, sizeof(string2), "*** Hi %s , Administrator: %s given you permission to use admin vehicles. Enjoy!", giveplayername, sendername);
                SendClientMessageToAdmins(ADMIN_RED, string, 1);
                SendClientMessage(giveplayerid, LIGHTBLUE, string2);
                PlayerAllowedAdminVehicles[giveplayerid] = true; // IMPORTANT
            }
            else if(giveplayerid == INVALID_PLAYER_ID)
            {
                format(string, sizeof(string), "%d is not a connected player.", giveplayerid);
                SendClientMessage(playerid, RED, string);
            }
        }
        else SendClientMessage(playerid, RED, "You need to be an Administrator to do that!");
        return 1;
    }

    if(strcmp(cmd, "/removeadmincar", true) == 0) // Unfreezes the player
    {
        if (AccountInfo[playerid][AdminLevel] >= 1 || IsPlayerAdmin(playerid)) /// Change Admin level here
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, ORANGE, "USAGE: /removeadmincar [playername/id]");
                SendClientMessage(playerid, ORANGE, "FUNCTION: Will allow player to access admin vehicles the specified player.");
                return 1;
            }
            new giveplayerid = ReturnUser(tmp);
            if(giveplayerid != INVALID_PLAYER_ID)
            {
                new string2[128];
                GetPlayerName(giveplayerid, giveplayername, sizeof(giveplayername));
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), "-| Administrator %s has allowed %s access to admin vehicles|-", sendername,giveplayername);
                format(string2, sizeof(string2), "*** Hi %s , Administrator: %s removed your permission to use admin vehicles.", giveplayername, sendername);
                SendClientMessageToAdmins(ADMIN_RED, string, 1);
                SendClientMessage(giveplayerid, LIGHTBLUE, string2);
                PlayerAllowedAdminVehicles[giveplayerid] = false; // IMPORTANT
            }
            else if(giveplayerid == INVALID_PLAYER_ID)
            {
                format(string, sizeof(string), "%d is not a connected player.", giveplayerid);
                SendClientMessage(playerid, RED, string);
            }
        }
        else SendClientMessage(playerid, RED, "You need to be an Administrator to do that!");
        return 1;
    }
After that, you just need to paste this outside and callbacks and commands.
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        new carid;
        carid = GetVehicleModel(GetPlayerVehicleID(playerid));
        if (AccountInfo[playerid][AdminLevel] <= 1 || !IsPlayerAdmin(playerid)) /// Change Admin level here
        {
            if(IsAdminCar(carid) && !PlayerAllowedAdminVehicles[playerid]) // If Player Enters any Admin Car and is not allowed Admin Vehicles
            {
                SendClientMessage(playerid, 0xFF0000AA, "You cannot use this Vehicle, You need to be an Admin to do that or have permission given - Ejected!");
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 1;
}
Put this under your OnPlayerDisconnect callback.
pawn Код:
PlayerAllowedAdminVehicles[playerid] = false; // IMPORTANT otherwise another player can connect and use admin cars
It should disable Hydra, Hunter, Tank, Seasparrow vehicles for non-admins unless you give them permission using the /allowadmincar [playerid/part of name] command. To remove their permission use /removeadmincar [playerid/ part of name]. When non-admins disconnect they will lose their permission.

Let me know if it works. It's untested.
Reply
#10

Quote:
Originally Posted by [B2K
Hustler ]
OK, No problem, I'll have a look at Seif Admin script and will edit this post with the command and code. See u in a bit. ( i mean post it in a bit).
ok thanks much

^^ i edited it so please look!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)