22.12.2014, 18:09
hello, i've made a command /aveh whihc spawn vehicle on for admins.
but when other player enters it it doesnt remove him from vehicle. i made this using foreach please help me
My Code.
OnTop
Command /aveh
OnPlayerStateChange
Please Help me.
but when other player enters it it doesnt remove him from vehicle. i made this using foreach please help me
My Code.
OnTop
Quote:
#define MAX_ADMIN_VEHICLES 1000 new Iterator:AdminVeh<MAX_ADMIN_VEHICLES>; |
Quote:
COMMAND:aveh(playerid, params[]) { return cmd_avehicle(playerid, params); } COMMAND:avehicle(playerid, params[]) { new Vehicle[50],string[128], angle; if(PlayerInfo[playerid][pAdminlevel] < 1) { SendClientMessage(playerid, COLOR_ERROR, ""ERROR_MSG""); return 1; } if(sscanf(params, "s", Vehicle)) { SendClientMessage(playerid, COLOR_ERROR, "USAGE: /veh (Vehicle)"); return 1; } new veh = GetVehicleModelIDFromName(Vehicle); new Float:X, Float:Y, Float:Z; GetPlayerPos(playerid, X, Y, Z); if(Iter_Count(AdminVeh)== MAX_ADMIN_VEHICLES)return 1; Iter_Add(AdminVeh,CreateVehicle(veh, X+3, Y, Z, angle, -1, -1, -1)); format(string, sizeof(string), "You have Spawned a %s. ID: %i. ", VehicleNames[veh - 400], veh); SendClientMessage(playerid, COLOR_SERVER_HELP_MSG, string); if(veh < 400 || veh > 611) { SendClientMessage(playerid, COLOR_ERROR, "Invalid Vehicle ID / Name."); return 1; } return 1; } |
Quote:
public OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate == 2) { new vehicleid = GetPlayerVehicleID(playerid); foreach(new VehID:AdminVeh) { if(VehID == vehicleid) { if(PlayerInfo[playerid][pAdminlevel] < 1) { RemovePlayerFromVehicle(playerid); SendClientMessage(playerid, COLOR_ERROR, "This Is An Admin Vehicle."); GameTextForPlayer(playerid, "Ejected: Admin Vehicle", 3000, 3); } } } } return 1; } |