[Help] Vehicle Spawning with name
#1

Hello guys, I'm trying to script a function to spawn a vehicle by name or id, but I can't get it to work. (Logic fail?)

I have all the vehicle names defined in an array (vehNames), followed by this code to get the ID of the vehicle

Код:
stock GetVehicleModelFromName(const vname[])
{
	for(new i = 0; i < 211; i++)
	{
		if(strfind(vehNames[i], vname, true) != -1) //Finds vehicle id from array
		{
			return i + 400; //Returns corresponding vehicle ID to vehicle name from the array
		}
	}
	return -1;
}
Here's the command I tried

Код:
CMD:v(playerid, params[])
{
		new vString[21];
		new vId;
		
	
	    vId = GetVehicleModelFromName(vString); //Gives the function vString, the array to hold the vehicle name to search the array, stores return value (vehicle ID) in vId
		
		new Float:x, Float:y, Float:z;
		new Float:FacingAngle;
		if(isnull(params))
		{
		    SendClientMessage(playerid, RED, "You did not input a parameter");
		}
                else
                {
		GetPlayerPos(playerid, x, y, z);
		GetPlayerFacingAngle(playerid, FacingAngle);
		CreateVehicle(vId, x, y, z, FacingAngle, -1, -1, 60);
                }
	        return 1;
}
Commented is my logic on how this works, can someone help me figure out where my logic fail is?
Reply


Messages In This Thread
[Help] Vehicle Spawning with name - by Placebo - 28.03.2011, 21:42
Re: [Help] Vehicle Spawning with name - by Tee - 28.03.2011, 21:57
Re: [Help] Vehicle Spawning with name - by Backwardsman97 - 28.03.2011, 22:00
Re: [Help] Vehicle Spawning with name - by Placebo - 28.03.2011, 22:13
Re: [Help] Vehicle Spawning with name - by Backwardsman97 - 28.03.2011, 22:18
Re: [Help] Vehicle Spawning with name - by Placebo - 28.03.2011, 22:22
Re: [Help] Vehicle Spawning with name - by Backwardsman97 - 28.03.2011, 22:36
Re: [Help] Vehicle Spawning with name - by Placebo - 28.03.2011, 22:45

Forum Jump:


Users browsing this thread: 1 Guest(s)