if(newstate == PLAYER_STATE_DRIVER) { if(!IsPlayerAdmin(playerid)) RemovePlayerFromVehicle(playerid); }
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. ![]() |
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); } |
Originally Posted by wilcock33
Quote:
or do i add it to my script first? ok ill give it a shot ill report back in a mo |
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. |
new bool:PlayerAllowedAdminVehicles[MAX_PLAYERS] = false;
stock GetFileValue(string[])
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;
}
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;
}
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;
}
PlayerAllowedAdminVehicles[playerid] = false; // IMPORTANT otherwise another player can connect and use admin cars
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). ![]() |