SA-MP Forums Archive
car color - 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)
+--- Thread: car color (/showthread.php?tid=545655)



car color - BoU3A - 09.11.2014

Hello i have this command to change the vehicle color its work fine but i want if the player didnt type the color2 it will just change the color1 how can i do that

PHP код:
CMD:vc(playerid,params[])
{
  new 
color1color2;
  if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Red,"UnKnwon Command! Type /cmds");
  if(
sscanf(params"dd",color1,color2)) return SendClientMessage(playerid,Red,"Change vehicle color: /vc <color1> <color2>");
  if(
IsPlayerInAnyVehicle(playerid))
  {
    
ChangeVehicleColor(GetPlayerVehicleID(playerid),color1,color2);
  }
  else
  {
    
SendClientMessage(playerid,Red,"You are not in vehicle");
  }
  return 
1;




Re: car color - dazman14 - 09.11.2014

Quote:
Originally Posted by BoU3A
Посмотреть сообщение
Hello i have this command to change the vehicle color its work fine but i want if the player didnt type the color2 it will just change the color1 how can i do that

PHP код:
CMD:vc(playerid,params[])
{
  new 
color1color2;
  if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Red,"UnKnwon Command! Type /cmds");
  if(
sscanf(params"dd",color1,color2)) return SendClientMessage(playerid,Red,"Change vehicle color: /vc <color1> <color2>");
  if(
IsPlayerInAnyVehicle(playerid))
  {
    
ChangeVehicleColor(GetPlayerVehicleID(playerid),color1,color2);
  }
  else
  {
    
SendClientMessage(playerid,Red,"You are not in vehicle");
  }
  return 
1;


i miss read your post. The only way to detect colours of a vehicle would be using :
https://sampforum.blast.hk/showthread.php?tid=235398

then you can get the colour and change it still but keep the current colour2


Re: car color - HY - 09.11.2014

pawn Код:
CMD:vc(playerid,params[])
{
  new color1, color2;
  new vehicle = GetPlayerVehicleID(playerid);
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Red,"UnKnwon Command! Type /cmds");
  if(sscanf(params, "dd",color1,color2)) return SendClientMessage(playerid,Red,"Change vehicle color: /vc <color1> <color2>");
  if(IsPlayerInAnyVehicle(playerid))
  {
    ChangeVehicleColor(vehicle,color1,color2);
  }
  else
  {
    SendClientMessage(playerid,Red,"You are not in vehicle");
  }
  return 1;
}



Re: car color - BoU3A - 09.11.2014

i want if i leave color2 emptry it will change just the first color


Re: car color - dazman14 - 09.11.2014

Quote:
Originally Posted by BoU3A
Посмотреть сообщение
i want if i leave color2 emptry it will change just the first color
use below code but also get this include (https://sampforum.blast.hk/showthread.php?tid=235398) and add it to pawno include folder and then include it in your script via #include
Код:
CMD:vc(playerid,params[])
{
	new color1 = 0, color2 = 0;
	new c1, c2;
	if(!IsPlayerInAnyVehicle(playerid))
	{
		SendClientMessage(playerid,Red,"You are not in vehicle");
		return 1;
	}
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Red,"UnKnwon Command! Type /cmds");
	if(sscanf(params, "dd",color1,color2))
	GetVehicleColor(GetPlayerVehicleID(playerid), c1, c2);
	if(color2 == 0)
	{
	ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, c2);
	}
	if(color1 == 0)
	ChangeVehicleColor(GetPlayerVehicleID(playerid), c1, color2);
	}
        if(color1 >= 1 && color2 >= 1){
         ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
        }
	return 1;
}
The above code will check if color1 was entered or color 2 enabling you to only change 1 or the other


Re: car color - DavidBilla - 09.11.2014

PHP код:
CMD:vc(playerid,params[])
{
  new 
color1color2;
  if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,Red,"UnKnwon Command! Type /cmds");
  if(
sscanf(params"dD(-1)",color1,color2)) return SendClientMessage(playerid,Red,"Change vehicle color: /vc <color1> <color2>");
  if(
IsPlayerInAnyVehicle(playerid))
  {
    
ChangeVehicleColor(GetPlayerVehicleID(playerid),color1,color2);
  }
  else
  {
    
SendClientMessage(playerid,Red,"You are not in vehicle");
  }
  return 
1;

This will set color 2 to -1 if player don't specify it