Vehicle spawn by name... help
#1

I have scripted a car spawner and a repair script by watching a tutorial on *******... and a vehicle spawns only if we type the vehicle ID.... Can u help me to make that script when we type the model name or my own name the vehicle will spawn?

Here is the code now i have already scripted...
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new idx;
	new cmd[256];

	cmd = strtok(cmdtext, idx);
  	if(strcmp(cmd, "/car", true) == 0)
	{
	new tmp[256], tmp2[256], tmp3[256];
	tmp = strtok(cmdtext, idx);
	tmp2 = strtok(cmdtext, idx);
	tmp3 = strtok(cmdtext, idx);

	new model = strval(tmp);
	new color1 = strval(tmp2);
	new color2 = strval(tmp3);
	
	if(!strlen(tmp))
	{
	SendClientMessage(playerid, COLOR_YELLOW, "You did not type a model id");
	return 1;
	}
	
	if(!strlen(tmp2))
	{
	SendClientMessage(playerid, COLOR_YELLOW, "You did not type a primary color id");
	return 1;
	}
	
	if(!strlen(tmp))
	if(!strlen(tmp3))
	{
	SendClientMessage(playerid, COLOR_YELLOW, "You did not type a secondary color id");
	return 1;
	}
	
	new Float:x, Float:y, Float:z, Float:a;
	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngle(playerid, a);
	
	CreateVehicle(model, x, y+2, z+1, a, color1, color2, -1);
	
	new string[128];
	format(string, sizeof(string), "You created a Vehicle Model: %d with ColorID1: %d and ColorID2: %d.", model, color1, color2);
	SendClientMessage(playerid, COLOR_YELLOW, string);
	return 1;
	}
	
	if(strcmp(cmd, "/repaircar", true) == 0)
	{
	if(!IsPlayerInAnyVehicle(playerid))
	{
	SendClientMessage(playerid, COLOR_YELLOW, "You need to be in a vehicle to do this command.");
	return 1;
	}
	
	new vehicleid = GetPlayerVehicleID(playerid);
	new string[128];
	format(string, sizeof(string), "You repaired vehicle Id: %d.", vehicleid);
	SendClientMessage(playerid, COLOR_YELLOW, string);
	RepairVehicle(vehicleid);
	return 1;
	}
Thanks.. and please help me soon!!!!!!!
Reply


Messages In This Thread
Vehicle spawn by name... help - by Captain_Mani - 09.09.2011, 09:35
Re: Vehicle spawn by name... help - by Davz*|*Criss - 09.09.2011, 09:42
Re: Vehicle spawn by name... help - by =WoR=Varth - 09.09.2011, 11:18
Re: Vehicle spawn by name... help - by Horrible - 09.09.2011, 11:25
Re: Vehicle spawn by name... help - by =WoR=Varth - 09.09.2011, 11:30
Re: Vehicle spawn by name... help - by Horrible - 09.09.2011, 11:32
Re: Vehicle spawn by name... help - by =WoR=Varth - 09.09.2011, 11:36

Forum Jump:


Users browsing this thread: 3 Guest(s)