#4

i have made this one quick for you..:
pawn Код:
CMD:veh(playerid, params[])
{
        if(!(PlayerInfo[playerid][pAdmin] >= 4))
            return SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use this command.");

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
            return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [vehicle name/ID] [color1(optional)] [color2(optional)]");

        new car = ReturnVehicleModelID(tmp);
        if(!car)
            return SendClientMessage(playerid, COLOR_GREY, "   Invalid vehicle model name/ID.");

            new color1, color2;
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                    color1 = -1;
                    color2 = -1;
        }
        else
        {
            color1 = strval(tmp);
            if(color1 < -1 || color1 > 200)
                return SendClientMessage(playerid, COLOR_GREY, "   Enter a valid color [0-200]");

                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp)) color2 = color1;
                    else color2 = strval(tmp);
                    if(color2 < -1 || color2 > 200)
                return SendClientMessage(playerid, COLOR_GREY, "   Enter a valid color [0-200]");
        }

        if(IsPlayerInAnyVehicle(playerid))
            RemovePlayerFromVehicle(playerid);
        new Float:X, Float:Y, Float:Z, Float:A;
                GetPlayerPos(playerid, X,Y,Z);
        GetPlayerFacingAngle(playerid,A);
        new carid = CreateVehicle(car, X,Y,Z,A, color1, color2, -1);

        PutPlayerInVehicle(playerid,carid,0);
        LinkVehicleToInterior(carid,GetPlayerInterior(playerid));
        SendClientMessage(playerid, -1, "You have spawned a vehicle");
        return 1;
}
and add this anywhere in your script:
pawn Код:
stock ReturnVehicleModelID(string[])
{
    if(IsNumeric(string))
    {
        new id = strval(string);
        if(id >= 400 && id <= 611)
        {
            return id;
        }
    }
    for(new i = 0;i < sizeof(vehName);i++)
    {
        if(strfind(vehName[i],string,true) != -1)
        {
            return i + 400;
        }
    }
    return 0;
}
Reply


Messages In This Thread
/veh - by TonyNames - 06.03.2014, 19:50
Re: /veh - by Mriss - 06.03.2014, 19:51
Re: /veh - by Drago987 - 06.03.2014, 20:07
Re: /veh - by XK - 06.03.2014, 21:25
Re: /veh - by FutureGenerationGaming - 06.03.2014, 22:58
Re: /veh - by XK - 06.03.2014, 23:05
Re: /veh - by FutureGenerationGaming - 06.03.2014, 23:44
Re: /veh - by TonyNames - 08.03.2014, 12:35
Re: /veh - by Shawn912 - 09.03.2014, 18:33

Forum Jump:


Users browsing this thread: 1 Guest(s)