SA-MP Forums Archive
Spawn Vehicle /v with the Name or just ID - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Spawn Vehicle /v with the Name or just ID (/showthread.php?tid=208354)



Spawn Vehicle /v with the Name or just ID - Yaszine - 08.01.2011

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 !


Re : Spawn Vehicle /v with the Name or just ID - Yaszine - 08.01.2011

Up !


Re : Spawn Vehicle /v with the Name or just ID - Yaszine - 08.01.2011

Please !


Re: Spawn Vehicle /v with the Name or just ID - Mean - 08.01.2011

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;
}



Re : Spawn Vehicle /v with the Name or just ID - Yaszine - 09.01.2011

It works, thanks a bunch !