Spawning Vehicle help
#1

Code:
CMD:myveh(playerid, params[])
{
	if(GetPVarInt(playerid, "Admin") >= 7)
	{
		if(GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
		if(IsPlayerConnected(playerid))
		{
			if(isnull(params))
			{
 				SCM(playerid, COLOR_ERROR, "USAGE: /myveh [name]");
				SCM(playerid, COLOR_GREY, "Available names: Sabre, FBITruck");
				return 1;
			}
			if(strcmp(params,"Sabre",true) == 0)
			{
				//
	   	 	}
		 	if(strcmp(params,"FBITruck",true) == 0)
			{
				//
			}
		}
 	}
	else SendClientMessage(playerid, COLOR_ERROR, "You do not have access to this command!");
	return 1;
}
How do I make this command to work like /myveh [name] [color1] [color2]
Reply
#2

You need the "sscanf" library. (https://sampforum.blast.hk/showthread.php?tid=570927)

Code:
CMD:myveh(playerid, params[])
{
	if(GetPVarInt(playerid, "Admin") >= 7)
	{
		if(GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
		if(IsPlayerConnected(playerid))
		{
			new modelid, color1, color2;
			if(sscanf(params, "ddd", modelid, color1, color2)) SendClientMessage(playerid, COLOR_WHITE, "Usage: /myveh [modelid] [color1] [color2]");
			// Here you'll start working with the variables (Functions and everything)
		}
 	}
	else SendClientMessage(playerid, COLOR_ERROR, "You do not have access to this command!");
	return 1;
}
Reply
#3

Yeah but I want the player can choose the vehicle.
Code:
 	SCM(playerid, COLOR_ERROR, "USAGE: /myveh [name] [color1] [color2]");
	SCM(playerid, COLOR_GREY, "Available names: Sabre, FBITruck");
Reply
#4

then

Code:
CMD:myveh(playerid, params[])
{
	if(GetPVarInt(playerid, "Admin") >= 7)
	{
		if(GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "You must be logged in to use this.");
		if(IsPlayerConnected(playerid))
		{
			new modelname[20], color1, color2;
			if(sscanf(params, "s[20]dd", modelname, color1, color2)) SendClientMessage(playerid, COLOR_WHITE, "Usage: /myveh [modelid] [color1] [color2]");
			
			if(!strcmp(modelname, "Rancher", true))
			{
				// Spawn a rancher here.
			}

			//and so on with the other names u wanna add.
		}
 	}
	else SendClientMessage(playerid, COLOR_ERROR, "You do not have access to this command!");
	return 1;
}
Reply
#5

Fixed?
Reply
#6

Yeah, thank you
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)