Need vehicles spawn command
#1

Can someone create the /v command for me?
I can't find ik anywhere, and if i use Simon's Debug filterscripts then my gamemode commands aren't working.

I hope someone can post the /v command, Just the /v command and nothing else,
Please tell to hoe to put it in my Gamemode.

Greetz, Jeffrey.
Reply
#2

put this under "public onplayercommandtext"

Код:
	if(strcmp(cmd, "/v", true) == 0) // can type /v carname/model
	{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ORANGE, "Error: Use /v model name/ ID");
				return 1;
			}
			new car = GetVehicleModelIDFromName(tmp);
			DestroyVehicle(car);
			if (car == -1)
			{
			  car = strval(tmp);
				if(car < 400 || car > 611) return SendClientMessage(playerid, RED, "ERROR: vehicle id must between 400 -611");
			}

			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ORANGE, "ERROR: /veh [modelname/id] [color1] [color2]");
				return 1;
			}
			new color1 = strval(tmp);

			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ORANGE, "ERROR: /veh [modelname/id] [color1] [color2]");
				return 1;
			}
			new color2 = strval(tmp);
			
			new Float:X,Float:Y,Float:Z,Float:A;
			GetPlayerPos(playerid, X,Y,Z);
			GetPlayerFacingAngle(playerid, A);
			X += (5 * floatsin(-A, degrees));
			Y += (5 * floatcos(-A, degrees));
			new carid = CreateVehicle(car, X,Y,Z, 0.0, color1, color2, 600000000);
			PutPlayerInVehicle(playerid, car, 0);
			
		}
Reply
#3

Couple of problems with that.
  • GetVehicleModelIDFromName isn't in his GameMode so it will return an "Undefined Function" error
  • It looks likes you're destroying a vehicle who's vehicleid is the same as the modelid the player types in, which will result in unwanted actions
  • You create the vehicle with the variable 'carid' but put the player into the vehicle with the variable 'car' which is a modelid, and not a veihcleid.
Reply
#4

Hmm... Can someone post/make a filterscript with the /v command only?
Reply
#5

Quote:
Originally Posted by Joe Staff
Couple of problems with that.
  • GetVehicleModelIDFromName isn't in his GameMode so it will return an "Undefined Function" error
  • It looks likes you're destroying a vehicle who's vehicleid is the same as the modelid the player types in, which will result in unwanted actions
  • You create the vehicle with the variable 'carid' but put the player into the vehicle with the variable 'car' which is a modelid, and not a veihcleid.
I was about to mention that, I'll fix it to make it work with ID's only.
Код:
	if(strcmp(cmd, "/v", true) == 0) // can type /v carname/model
	{
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ORANGE, "Error: Use /v model name/ ID");
				return 1;
			}
			new car;
			if (car >= 611 || car <= 400)
			{
			  car = strval(tmp);
				if(car < 400 || car > 611) return SendClientMessage(playerid, RED, "ERROR: vehicle id must between 400 -611");
			}

			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ORANGE, "ERROR: /veh [id] [color1] [color2]");
				return 1;
			}
			new color1 = strval(tmp);

			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, ORANGE, "ERROR: /veh [id] [color1] [color2]");
				return 1;
			}
			new color2 = strval(tmp);
			
			new Float:X,Float:Y,Float:Z,Float:A;
			GetPlayerPos(playerid, X,Y,Z);
			GetPlayerFacingAngle(playerid, A);
			new carid = CreateVehicle(car, X,Y,Z, A, color1, color2, 600000000);
			PutPlayerInVehicle(playerid, carid, 0);
			
		}
Reply
#6

How can i add only admins lv 4+ can spawn it?
Im using Carlito's Roleplay,
Normaly i use
Код:
if (PlayerInfo[playerid][pAdmin] >= 4)
But i don't know where to add it.
Reply
#7

pawn Код:
if(strcmp(cmdtext, "/v", true) == 0)
{
  if(PlayerInfo[playerid][pAdmin] >= 4)
  {
    blah blah blah...
    return 1;
  }
  else
  SendClientMessage(playerid, somecolor, "something");
  return 1;
}
Reply
#8

if(strcmp(cmd, "/v", true) == 0) // can type /v carname/model
{
if (PlayerInfo[playerid][pAdmin] >= 4)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "Error: Use /v model name/ ID");
return 1;
}
new car;
if (car >= 611 || car <= 400)
{
car = strval(tmp);
if(car < 400 || car > 611) return SendClientMessage(playerid, RED, "ERROR: vehicle id must between 400 -611");
}

tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "ERROR: /veh [id] [color1] [color2]");
return 1;
}
new color1 = strval(tmp);

tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "ERROR: /veh [id] [color1] [color2]");
return 1;
}
new color2 = strval(tmp);

new Float:X,Float:Y,Float:Z,Float:A;
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid, A);
new carid = CreateVehicle(car, X,Y,Z, A, color1, color2, 600000000);
PutPlayerInVehicle(playerid, carid, 0);

}
}
Reply
#9

Quote:
Originally Posted by [mad
MLK (sampx-hosting.co.cc) ]
if(strcmp(cmd, "/v", true) == 0) // can type /v carname/model
{
if (PlayerInfo[playerid][pAdmin] >= 4)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "Error: Use /v model name/ ID");
return 1;
}
new car;
if (car >= 611 || car <= 400)
{
car = strval(tmp);
if(car < 400 || car > 611) return SendClientMessage(playerid, RED, "ERROR: vehicle id must between 400 -611");
}

tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "ERROR: /veh [id] [color1] [color2]");
return 1;
}
new color1 = strval(tmp);

tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, ORANGE, "ERROR: /veh [id] [color1] [color2]");
return 1;
}
new color2 = strval(tmp);

new Float:X,Float:Y,Float:Z,Float:A;
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid, A);
new carid = CreateVehicle(car, X,Y,Z, A, color1, color2, 600000000);
PutPlayerInVehicle(playerid, carid, 0);

}
}
If you did it like that, everyone would be able to spawn a vehicle. Because you didn't return anything at the end where it should be returned if the player isn't an admin with a higher level than 4.
Reply
#10

Erm.. Can someone create the whole code?
With Admin lv 4 please.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)