23.12.2014, 00:20
(
Последний раз редактировалось Quickie; 23.12.2014 в 00:51.
)
i forgot to mention this one function in my last reply to your post
so you wont be needing the foreach loop to check if the item is in the iterator
pawn Код:
Iter_Contains(name, value)
//Checks if the given value is present in the given iterator.
pawn Код:
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[50]", Vehicle))
{
SendClientMessage(playerid, COLOR_ERROR, "USAGE: /veh (Vehicle)");
return 1;
}
new veh = GetVehicleModelIDFromName(Vehicle);
if(veh < 400 || veh > 611)
{
SendClientMessage(playerid, COLOR_ERROR, "Invalid Vehicle ID / Name.");
return 1;
}
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);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(Iter_Contains(AdminVeh,vehicleid)&&(PlayerInfo[playerid][pAdminlevel] < 1))
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, COLOR_ERROR, "This Is An Admin Vehicle.");
GameTextForPlayer(playerid, "Ejected: Admin Vehicle", 3000, 3);
}
}
return 1;
}