Change car color at spec place
#1

I have this code
Код:
#include <a_samp>
#include <gl_common>
#define COLOR_GREEN 0x33AA33AA
#define COLOR_RED 0xAA3333AA
#define FILTERSCRIPT

public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[128], idx;
	cmd = strtok(cmdtext, idx);
	if (strcmp("/carcolor", cmd, true) == 0)
	{
	  new Color1[128];
	  new Color2[128];
	  new currentveh;
	  Color1 = strtok(cmdtext, idx);
	  Color2 = strrest(cmdtext, idx);
	  currentveh = GetPlayerVehicleID(playerid);
	  if (strval(Color1) > 255)
	  {
	    SendClientMessage(playerid, COLOR_RED, "Invalid Color ID 1");
	    return 1;
   	}
   	if (strval(Color2) > 255)
   	{
   	  SendClientMessage(playerid, COLOR_RED, "Invalid Color ID 2");
	    return 1;
   	}
   	else
   	{
	  	ChangeVehicleColor(currentveh, strval(Color1), strval(Color2));
	  	return 1;
  	}
 	}
 	return 0;
}
and i want to add
Код:
	  {
 		if(PlayerAtPos(15.0, playerid, 2382.0005,231.7945,26.6032))
		{
and
Код:
   	else
   	{
   	  SendClientMessage(playerid, COLOR_RED, "You are not at the service garage!");
	  	return 1;
  	}
But it got error how ever were i put it. any ideas?
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[128], idx;
    cmd = strtok(cmdtext, idx);
    if (strcmp("/carcolor", cmd, true) == 0)
    {
        if(PlayerAtPos(15.0, playerid, 2382.0005,231.7945,26.6032))
        {
            new Color1[128];
            new Color2[128];
            new currentveh;
            Color1 = strtok(cmdtext, idx);
            Color2 = strrest(cmdtext, idx);
            currentveh = GetPlayerVehicleID(playerid);
            if (strval(Color1) > 255)
            {
                SendClientMessage(playerid, COLOR_RED, "Invalid Color ID 1");
                return 1;
            }
            if (strval(Color2) > 255)
            {
                SendClientMessage(playerid, COLOR_RED, "Invalid Color ID 2");
                return 1;
            }
            else
            {
                ChangeVehicleColor(currentveh, strval(Color1), strval(Color2));
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "You are not at the service garage!");
            return 1;
        }
    }
    return 0;
}
Reply
#3

Quote:
Originally Posted by MadeMan
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[128], idx;
    cmd = strtok(cmdtext, idx);
    if (strcmp("/carcolor", cmd, true) == 0)
    {
        if(PlayerAtPos(15.0, playerid, 2382.0005,231.7945,26.6032))
        {
            new Color1[128];
            new Color2[128];
            new currentveh;
            Color1 = strtok(cmdtext, idx);
            Color2 = strrest(cmdtext, idx);
            currentveh = GetPlayerVehicleID(playerid);
            if (strval(Color1) > 255)
            {
                SendClientMessage(playerid, COLOR_RED, "Invalid Color ID 1");
                return 1;
            }
            if (strval(Color2) > 255)
            {
                SendClientMessage(playerid, COLOR_RED, "Invalid Color ID 2");
                return 1;
            }
            else
            {
                ChangeVehicleColor(currentveh, strval(Color1), strval(Color2));
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "You are not at the service garage!");
            return 1;
        }
    }
    return 0;
}
Thanks! but i got a warning
Код:
warning 206: redundant test: constant expression is non-zero
on
Код:
if(PlayerAtPos(15.0, playerid, 2382.0005,231.7945,26.6032))
Reply
#4

pawn Код:
if(PlayerAtPos(15.0, playerid, 2382.0005,231.7945,26.6032))
replace it with

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 15.0, 2382.0005,231.7945,26.6032))
Reply
#5

Quote:
Originally Posted by MadeMan
pawn Код:
if(PlayerAtPos(15.0, playerid, 2382.0005,231.7945,26.6032))
replace it with

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 15.0, 2382.0005,231.7945,26.6032))
Thanks! works perfekt
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)