Help with Admin Vehicle.
#2

i forgot to mention this one function in my last reply to your post
pawn Код:
Iter_Contains(name, value)

//Checks if the given value is present in the given iterator.
so you wont be needing the foreach loop to check if the item is in the 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;
}
Reply


Messages In This Thread
Help with Admin Vehicle. - by danish007 - 22.12.2014, 18:09
Re: Help with Admin Vehicle. - by Quickie - 23.12.2014, 00:20
Re: Help with Admin Vehicle. - by danish007 - 23.12.2014, 09:18
Re: Help with Admin Vehicle. - by danish007 - 24.12.2014, 18:03
Re: Help with Admin Vehicle. - by Clad - 24.12.2014, 18:08
Re: Help with Admin Vehicle. - by Biess - 24.12.2014, 19:05
Re: Help with Admin Vehicle. - by danish007 - 24.12.2014, 20:35
Re: Help with Admin Vehicle. - by danish007 - 25.12.2014, 17:57
Re: Help with Admin Vehicle. - by dominik523 - 25.12.2014, 18:04
Re: Help with Admin Vehicle. - by danish007 - 25.12.2014, 20:46

Forum Jump:


Users browsing this thread: 1 Guest(s)