Spawn Vehicle /v with the Name or just ID
#1

Peace ..,

I have a "/v" spawning vehicles system with only the Name, EX: /v Infernus
Now I need also how to make /v ID like: /v 411

With this following code:
pawn Код:
dcmd_v(playerid,params[])
{
        new Index;
        new tmp[256];  tmp  = strtok(params,Index);
        new tmp2[256]; tmp2 = strtok(params,Index);
        new tmp3[256]; tmp3 = strtok(params,Index);
        if(PlayerInterior[playerid] > 1) return SendClientMessage(playerid,RED, "You can't spawn a vehicle inside houses / hotels / ..."); // xD
        if(!strlen(tmp)) return
        SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /v [Name] [Colour1] [Colour2]");
        new car;
        new string[128];
        new colour1, colour2;
        if(!IsNumeric(tmp))
        car = GetVehicleModelIDFromName(tmp);
        else car = strval(tmp);
        if(car < 400 || car > 611) return  SendClientMessage(playerid, BALTA, "Invalid Name!");
        if(!strlen(tmp2)) colour1 = random(126); else colour1 = strval(tmp2);
        if(!strlen(tmp3)) colour2 = random(126); else colour2 = strval(tmp3);
        new Float:X,Float:Y,Float:Z;
        new Float:Angle,int1;
        GetPlayerPos(playerid, X,Y,Z);
        GetPlayerFacingAngle(playerid,Angle);
        int1 = GetPlayerInterior(playerid);
        Car[playerid] = CreateVehicle(car, X,Y,Z, Angle, colour1, colour2, 60*10000); //-1
        LinkVehicleToInterior(Car[playerid],int1);
    }
Please !
Reply
#2

Up !
Reply
#3

Please !
Reply
#4

This code should work...
Piece of code that makes ID or name:
pawn Код:
if(!IsNumeric(tmp))
        car = GetVehicleModelIDFromName(tmp);
        else car = strval(tmp);
Check if your IsNumeric function is same as this one:
pawn Код:
stock IsNumeric(string[])
{
    for (new i = 0, j = strlen(string);
    i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0')
        return 0;
    }
    return 1;
}
Reply
#5

It works, thanks a bunch !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)