car color
#1

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;

Reply
#2

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
Reply
#3

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;
}
Reply
#4

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

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
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)