29.12.2014, 08:16
I have made this private admin vehicle, but i can get on the vehicle even if i'm not admin.
pawn Код:
#define MAX_PRIVATE_VEHICLE_ADMIN 10
#define VEHICLE_COLOR1 6
#define VEHICLE_COLOR2 6
#define LABEL_DISTANCE 25
new Iterator:PrivateVehicleAdmin<MAX_PRIVATE_VEHICLE_ADMIN>;
pawn Код:
CMD:avehicle(playerid, params[])
{
new vModel, veh, vw;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "[ERROR]: You are not admin");
if(sscanf(params, "i", vModel)) return SendClientMessage(playerid, YELLOW, "[USE]: /avehicle [modelid]");
if(vModel < 400 || vModel > 611) return SendClientMessage(playerid, RED, "[ERROR]: Invalid modelid");
if(Iter_Count(PrivateVehicleAdmin) == MAX_PRIVATE_VEHICLE_ADMIN) return SendClientMessage(playerid, RED, "[ERROR]: It isn't possible create other private vehicle admin");
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
vw = GetPlayerVirtualWorld(playerid);
veh = CreateVehicle(vModel, Pos[0], Pos[1], Pos[2], Pos[3], VEHICLE_COLOR1, VEHICLE_COLOR2, -1);
Iter_Add(PrivateVehicleAdmin, veh);
PutPlayerInVehicle(playerid, veh, 0);
LabelVehicle = Create3DTextLabel("Admin Vehicle", ORANGE, 0, 0, 0, LABEL_DISTANCE, vw, 0);
Attach3DTextLabelToVehicle(LabelVehicle, veh, 0, 0, 1.5);
format(string1, sizeof(string1), "[INFO]: Vehicle created %d/%d | ID: %d", Iter_Count(PrivateVehicleAdmin), MAX_PRIVATE_VEHICLE_ADMIN, veh);
SendClientMessage(playerid, GREEN, string1);
return 1;
}
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new veh = GetPlayerVehicleID(playerid);
foreach(new i : PrivateVehicleAdmin)
{
if(i == veh)
{
if(!IsPlayerAdmin(playerid))
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, RED, "This Vehicle is only for admins");
}
}
}
}
return 1;
}