SendClientMessage Error
#1

i'm having a little problem with a command i've created

my problem is that even though the player is in range when using the command, it still says they're not in range.

(the command works as intended but it's just that it still sends the error message even though they're in range)



pic:

PHP код:
COMMAND:cargo(playerid,params[])
{
    if(
pInfo[playerid][pCargo] == 1) return SendClientMessage(playeridRED"Already Delivering Cargo!");
    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) == 519)
     {
          new 
Float:X;
        new 
Float:Y;
        new 
Float:Z;
        
GetPlayerPos(playeridXYZ);
        if(
IsPlayerInRangeOfPoint(playerid500.01761.4497,-2494.3818,13.5547)) // LS LOC
        
{
        
pInfo[playerid][pCargo] = 1;
        
pInfo[playerid][pCargoM] = 0;
        
pInfo[playerid][pCargoD] = 3;
        
TextDrawShowForPlayer(playeridCargoTD);
        
TextDrawShowForPlayer(playeridCargoLoc[playerid]);
        
SendClientMessage(playeridYELLOW"Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!");
        
Streamer_AppendArrayData(STREAMER_TYPE_CPCheckpoint[193], E_STREAMER_PLAYER_IDplayerid);
           new 
str[48];
        
format(str,sizeof(str),"~b~~h~Location: ~g~Los Santos Airport");
        
TextDrawSetString(CargoLoc[playerid], str);
        
SendClientMessage(playeridYELLOW"Load Cargo from Los Santos Airport for Delivery!");
        }
        if(
IsPlayerInRangeOfPoint(playerid500.0, -1397.5881,-284.6473,26.2160)) // SF LOC
        
{
        
pInfo[playerid][pCargo] = 1;
        
pInfo[playerid][pCargoM] = 0;
        
pInfo[playerid][pCargoD] = 3;
        
TextDrawShowForPlayer(playeridCargoTD);
        
TextDrawShowForPlayer(playeridCargoLoc[playerid]);
        
SendClientMessage(playeridYELLOW"Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!");
        
Streamer_AppendArrayData(STREAMER_TYPE_CPCheckpoint[194], E_STREAMER_PLAYER_IDplayerid);
           new 
str[48];
        
format(str,sizeof(str),"~b~~h~Location: ~g~San Fierro Airport");
        
TextDrawSetString(CargoLoc[playerid], str);
        
SendClientMessage(playeridYELLOW"Load Cargo from San Fierro Airport for Delivery!");
        }
        if(
IsPlayerInRangeOfPoint(playerid500.01473.1907,1507.4999,10.8203)) // LV LOC
        
{
        
pInfo[playerid][pCargo] = 1;
        
pInfo[playerid][pCargoM] = 0;
        
pInfo[playerid][pCargoD] = 3;
        
TextDrawShowForPlayer(playeridCargoTD);
        
TextDrawShowForPlayer(playeridCargoLoc[playerid]);
        
SendClientMessage(playeridYELLOW"Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!");
        
Streamer_AppendArrayData(STREAMER_TYPE_CPCheckpoint[195], E_STREAMER_PLAYER_IDplayerid);
           new 
str[48];
        
format(str,sizeof(str),"~b~~h~Location: ~g~Las Venturas Airport");
        
TextDrawSetString(CargoLoc[playerid], str);
        
SendClientMessage(playeridYELLOW"Load Cargo from Las Venturas Airport for Delivery!");
        }
        if(
IsPlayerInRangeOfPoint(playerid500.0164.0293,2494.4155,16.4844)) // ABAND LOC
        
{
        
pInfo[playerid][pCargo] = 1;
        
pInfo[playerid][pCargoM] = 0;
        
pInfo[playerid][pCargoD] = 3;
        
TextDrawShowForPlayer(playeridCargoTD);
        
TextDrawShowForPlayer(playeridCargoLoc[playerid]);
        
SendClientMessage(playeridYELLOW"Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!");
        
Streamer_AppendArrayData(STREAMER_TYPE_CPCheckpoint[196], E_STREAMER_PLAYER_IDplayerid);
           new 
str[48];
        
format(str,sizeof(str),"~b~~h~Location: ~g~Abandoned Airport");
        
TextDrawSetString(CargoLoc[playerid], str);
        
SendClientMessage(playeridYELLOW"Load Cargo from Abandoned Airport for Delivery!");
        }
        else return 
SendClientMessage(playeridRED"You can only start a Cargo Mission at an Airport!");
    }
    else return 
SendClientMessage(playeridRED,"You Must be in a Shamal to Start this Job!");
    return 
1;

Reply
#2

Just use else statement:
PHP код:
COMMAND:cargo(playerid,params[])
{
    if(
pInfo[playerid][pCargo] == 1) return SendClientMessage(playeridRED"Already Delivering Cargo!");
    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 519) return SendClientMessage(playeridRED,"You Must be in a Shamal to Start this Job!");
    
    if(
IsPlayerInRangeOfPoint(playerid500.01761.4497,-2494.3818,13.5547)) // LS LOC
    
{
        
pInfo[playerid][pCargo] = 1;
        
pInfo[playerid][pCargoM] = 0;
        
pInfo[playerid][pCargoD] = 3;
        
TextDrawShowForPlayer(playeridCargoTD);
        
TextDrawShowForPlayer(playeridCargoLoc[playerid]);
        
SendClientMessage(playeridYELLOW"Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!");
        
Streamer_AppendArrayData(STREAMER_TYPE_CPCheckpoint[193], E_STREAMER_PLAYER_IDplayerid);
        new 
str[48];
        
format(str,sizeof(str),"~b~~h~Location: ~g~Los Santos Airport");
        
TextDrawSetString(CargoLoc[playerid], str);
        
SendClientMessage(playeridYELLOW"Load Cargo from Los Santos Airport for Delivery!");
    }
    else if(
IsPlayerInRangeOfPoint(playerid500.0, -1397.5881,-284.6473,26.2160)) // SF LOC
    
{
        
pInfo[playerid][pCargo] = 1;
        
pInfo[playerid][pCargoM] = 0;
        
pInfo[playerid][pCargoD] = 3;
        
TextDrawShowForPlayer(playeridCargoTD);
        
TextDrawShowForPlayer(playeridCargoLoc[playerid]);
        
SendClientMessage(playeridYELLOW"Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!");
        
Streamer_AppendArrayData(STREAMER_TYPE_CPCheckpoint[194], E_STREAMER_PLAYER_IDplayerid);
        new 
str[48];
        
format(str,sizeof(str),"~b~~h~Location: ~g~San Fierro Airport");
        
TextDrawSetString(CargoLoc[playerid], str);
        
SendClientMessage(playeridYELLOW"Load Cargo from San Fierro Airport for Delivery!");
    }
    else if(
IsPlayerInRangeOfPoint(playerid500.01473.1907,1507.4999,10.8203)) // LV LOC
    
{
        
pInfo[playerid][pCargo] = 1;
        
pInfo[playerid][pCargoM] = 0;
        
pInfo[playerid][pCargoD] = 3;
        
TextDrawShowForPlayer(playeridCargoTD);
        
TextDrawShowForPlayer(playeridCargoLoc[playerid]);
        
SendClientMessage(playeridYELLOW"Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!");
        
Streamer_AppendArrayData(STREAMER_TYPE_CPCheckpoint[195], E_STREAMER_PLAYER_IDplayerid);
        new 
str[48];
        
format(str,sizeof(str),"~b~~h~Location: ~g~Las Venturas Airport");
        
TextDrawSetString(CargoLoc[playerid], str);
        
SendClientMessage(playeridYELLOW"Load Cargo from Las Venturas Airport for Delivery!");
    }
    else if(
IsPlayerInRangeOfPoint(playerid500.0164.0293,2494.4155,16.4844)) // ABAND LOC
    
{
        
pInfo[playerid][pCargo] = 1;
        
pInfo[playerid][pCargoM] = 0;
        
pInfo[playerid][pCargoD] = 3;
        
TextDrawShowForPlayer(playeridCargoTD);
        
TextDrawShowForPlayer(playeridCargoLoc[playerid]);
        
SendClientMessage(playeridYELLOW"Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!");
        
Streamer_AppendArrayData(STREAMER_TYPE_CPCheckpoint[196], E_STREAMER_PLAYER_IDplayerid);
        new 
str[48];
        
format(str,sizeof(str),"~b~~h~Location: ~g~Abandoned Airport");
        
TextDrawSetString(CargoLoc[playerid], str);
        
SendClientMessage(playeridYELLOW"Load Cargo from Abandoned Airport for Delivery!");
    }
    else 
SendClientMessage(playeridRED"You can only start a Cargo Mission at an Airport!");
    return 
1;

Reply
#3

Will work now:

Код:
COMMAND:cargo(playerid,params[]) 
{ 
    if(pInfo[playerid][pCargo] == 1) 
		return SendClientMessage(playerid, RED, "Already Delivering Cargo!"); 
		
	if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 519) 
	{ 
		new Float:X; 
        new Float:Y; 
        new Float:Z; 
        GetPlayerPos(playerid, X, Y, Z); 
        if(IsPlayerInRangeOfPoint(playerid, 500.0, 1761.4497,-2494.3818,13.5547)) // LS LOC 
        { 
			pInfo[playerid][pCargo] = 1; 
			pInfo[playerid][pCargoM] = 0; 
			pInfo[playerid][pCargoD] = 3; 
			TextDrawShowForPlayer(playerid, CargoTD); 
			TextDrawShowForPlayer(playerid, CargoLoc[playerid]); 
			SendClientMessage(playerid, YELLOW, "Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!"); 
			Streamer_AppendArrayData(STREAMER_TYPE_CP, Checkpoint[193], E_STREAMER_PLAYER_ID, playerid); 
			new str[48];
			format(str,sizeof(str),"~b~~h~Location: ~g~Los Santos Airport"); 
			TextDrawSetString(CargoLoc[playerid], str); 
			SendClientMessage(playerid, YELLOW, "Load Cargo from Los Santos Airport for Delivery!"); 
        } 
        else if(IsPlayerInRangeOfPoint(playerid, 500.0, -1397.5881,-284.6473,26.2160)) // SF LOC 
        { 
			pInfo[playerid][pCargo] = 1; 
			pInfo[playerid][pCargoM] = 0; 
			pInfo[playerid][pCargoD] = 3; 
			TextDrawShowForPlayer(playerid, CargoTD); 
			TextDrawShowForPlayer(playerid, CargoLoc[playerid]); 
			SendClientMessage(playerid, YELLOW, "Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!"); 
			Streamer_AppendArrayData(STREAMER_TYPE_CP, Checkpoint[194], E_STREAMER_PLAYER_ID, playerid); 
           new str[48]; 
			format(str,sizeof(str),"~b~~h~Location: ~g~San Fierro Airport"); 
			TextDrawSetString(CargoLoc[playerid], str); 
			SendClientMessage(playerid, YELLOW, "Load Cargo from San Fierro Airport for Delivery!"); 
        } 
        else if(IsPlayerInRangeOfPoint(playerid, 500.0, 1473.1907,1507.4999,10.8203)) // LV LOC 
        { 
			pInfo[playerid][pCargo] = 1; 
			pInfo[playerid][pCargoM] = 0; 
			pInfo[playerid][pCargoD] = 3; 
			TextDrawShowForPlayer(playerid, CargoTD); 
			TextDrawShowForPlayer(playerid, CargoLoc[playerid]); 
			SendClientMessage(playerid, YELLOW, "Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!"); 
			Streamer_AppendArrayData(STREAMER_TYPE_CP, Checkpoint[195], E_STREAMER_PLAYER_ID, playerid); 
			new str[48]; 
			format(str,sizeof(str),"~b~~h~Location: ~g~Las Venturas Airport"); 
			TextDrawSetString(CargoLoc[playerid], str); 
			SendClientMessage(playerid, YELLOW, "Load Cargo from Las Venturas Airport for Delivery!"); 
        } 
        else if(IsPlayerInRangeOfPoint(playerid, 500.0, 164.0293,2494.4155,16.4844)) // ABAND LOC 
        { 
			pInfo[playerid][pCargo] = 1; 
			pInfo[playerid][pCargoM] = 0; 
			pInfo[playerid][pCargoD] = 3; 
			TextDrawShowForPlayer(playerid, CargoTD); 
			TextDrawShowForPlayer(playerid, CargoLoc[playerid]); 
			SendClientMessage(playerid, YELLOW, "Cargo Delivery: Load and Deliver Cargo to and from Airports all around San Andreas!"); 
			Streamer_AppendArrayData(STREAMER_TYPE_CP, Checkpoint[196], E_STREAMER_PLAYER_ID, playerid); 
			new str[48]; 
			format(str,sizeof(str),"~b~~h~Location: ~g~Abandoned Airport"); 
			TextDrawSetString(CargoLoc[playerid], str); 
			SendClientMessage(playerid, YELLOW, "Load Cargo from Abandoned Airport for Delivery!"); 
        } 
        else 
			SendClientMessage(playerid, RED, "You can only start a Cargo Mission at an Airport!"); 
    } 
    else 
		SendClientMessage(playerid, RED,"You Must be in a Shamal to Start this Job!"); 
    
	return 1; 
}
Reply
#4

thanks for the help once again Konst, my problem is solved. rep+

also thanks anyways Ralfie, i figured that out from Konstantino's post.

else and if statements confuse me at times :/
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)