SA-MP Forums Archive
[HELP]Giving car with OnPlayerText... - 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: [HELP]Giving car with OnPlayerText... (/showthread.php?tid=166456)



[HELP]Giving car with OnPlayerText... - LasTRace - 08.08.2010

Hi, i want to give a car to players when they write its name. I mean, if a player types "Infernus", an infernus will spawn in front of him. But, for sure, we need to use GetVehicleModelIDFromName when doing it... how can i realize that?

here is GetVehicleModelIDFromName code:

pawn Код:
GetVehicleModelIDFromName(vname[])
{
        for(new i = 0; i < 211; i++)
        {
                if(strfind(VehicleNames[i], vname, true) != -1)
                return i + 400;
        }
        return -1;
}



Re: [HELP]Giving car with OnPlayerText... - chneubeul - 08.08.2010

Hello

OnPlayerText
...

for(new i = 0; i < sizeof(VehicleNames); i++)
{
if(strfind(VehicleNames[i], vname, true) != -1)// if the script find our vehicle
{
new Float:PosX, Float:PosY, Float:PosZ, Float:Angle;
GetPlayerFacingAngle(playerid, Angle);
GetPlayerPos(playerid, PosX, PosY, PosZ);
CreateVehicle(i+400, PosX, PosY, PosZ, Angle, 0, 0,-1);
}
}

I think it's something like that
After, you must reflect over ^_^

Sorry for my Bad English