SA-MP Forums Archive
Why - 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: Why (/showthread.php?tid=583161)



Why - Mariciuc223 - 26.07.2015

Код:
CMD:water(playerid, params[])
{
	for(new i=0; i<sizeof(WaterPos); i++)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 2, WaterPos[i][0], WaterPos[i][1], WaterPos[i][2]))
	    {
	        new Float:health = GetPlayerHealth(playerid, health);
	        
	        if(health == 100.0)
	            return SendClientMessage(playerid, FactColor[11], "You already have 100 health !");
	            
	        SetPlayerHealth(playerid, 100.0);
	        SendClientMessage(playerid, FactColor[11], "You have been fully healed !");
		}
		else if(!IsPlayerInRangeOfPoint(playerid, 2, WaterPos[i][0], WaterPos[i][1], WaterPos[i][2]))
  			return SendClientMessage(playerid, FactColor[11], "You are not at the right place !");
	}
        
	return 1;
}
Why when i'm in range of that point it say to me "You are not at the right place" ? (Sometime it give me heal, sometime just that stupid message ... when it give me health spam my chat with ""You are not at the right place !" i-1 times ...


Re: Why - Vince - 26.07.2015

Do you know how a loop works and what return does? Never return or break inside a loop unless you explicitly want to break it; i.e. when you have established that they are in fact in range. You can't possibly know if a player is not in range of any of those points before you have checked all of them.


Re: Why - SoFahim - 26.07.2015

First show us . WaterPos[i][] main lines. I mean points.


Re: Why - Mariciuc223 - 26.07.2015

So , i need to check if i = sizeof(myarray) ? before to do what i wanna do ? That you say ? hmm i will try when i will update my actual version of gamemode


Re: Why - Mariciuc223 - 26.07.2015

Quote:
Originally Posted by SoFahim
Посмотреть сообщение
First show us . WaterPos[i][] main lines. I mean points.

Second,
PHP код:
return SendClientMessage(playeridFactColor[11], "You are not at the right place !");
    } 
Why did you put return SendClientMassage? you can use only SendClientMassage

Third Did you define FactColor[11] perfectly?

fourth Nevermind forgot !
Lol .. Sure i do right with FactColor

Код:
new const FactColor[] =
{
	0xFFE4C4FF, 0x0000FFFF, 0x7B68EE0FF, 0x00008BFF, 0xF9526BFF,
	0x778899FF, 0xFFF46EFF, 0x008000FF, 0x800080FF, 0xFFFF00FF,
	0x00FFFFFF, 0xFFA343FF, 0x00FF00FF, 0xFF69B4FF, 0x660000FF
};
That are water locations:

Код:
new Float:WaterPos[][] =
{
	{ 252.1506,111.4887,1003.2188 },
	{ 270.2978,186.2076,1008.1719 },
	{ 249.6548,196.7341,1008.1719 },
	{ 257.9287,196.7354,1008.1719 },
	{ 229.1164,155.1423,1003.0234 },
	{ 227.3604,143.4446,1003.0234 },
	{ 231.3758,180.2250,1003.0313 },
	{ 227.3651,184.3604,1003.0313 },
	{ 1496.2740,1304.3014,1093.2891 },
	{ 1249.1284,5.7868,1008.2578 },
	{ 754.9944,-40.5415,1000.5859 }
};
but you don't need them anyway (i think)


Re: Why - SoFahim - 26.07.2015

Where is Float:range . I mean if(IsPlayerInRangeOfPoint(playerid, range, 0 , 0, 0))

You didn't put the range. thats the problem. That mean . Only in that coords can take the cmd


AW: Why - Macronix - 26.07.2015

Try this:

Код:
CMD:water(playerid, params[])
{
	for(new i = 0; i < sizeof(WaterPos); i++)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 2.0, WaterPos[i][0], WaterPos[i][1], WaterPos[i][2]))
	    {
	        new Float:health = GetPlayerHealth(playerid, health);

	        if(health == 100.0) return SendClientMessage(playerid, FactColor[11], "You already have 100 health !");

	        SetPlayerHealth(playerid, 100.0);
	        SendClientMessage(playerid, FactColor[11], "You have been fully healed !");
	        return 1;
	    }
	}
	return SendClientMessage(playerid, FactColor[11], "You are not at the right place !");
}

new Float:WaterPos[11][3] =
{
	{ 252.1506,111.4887,1003.2188 },
	{ 270.2978,186.2076,1008.1719 },
	{ 249.6548,196.7341,1008.1719 },
	{ 257.9287,196.7354,1008.1719 },
	{ 229.1164,155.1423,1003.0234 },
	{ 227.3604,143.4446,1003.0234 },
	{ 231.3758,180.2250,1003.0313 },
	{ 227.3651,184.3604,1003.0313 },
	{ 1496.2740,1304.3014,1093.2891 },
	{ 1249.1284,5.7868,1008.2578 },
	{ 754.9944,-40.5415,1000.5859 }
};



Re: AW: Why - Mariciuc223 - 26.07.2015

Quote:
Originally Posted by Macronix
Посмотреть сообщение
Try this:

Код:
CMD:water(playerid, params[])
{
	for(new i = 0; i < sizeof(WaterPos); i++)
	{
	    if(IsPlayerInRangeOfPoint(playerid, 2.0, WaterPos[i][0], WaterPos[i][1], WaterPos[i][2]))
	    {
	        new Float:health = GetPlayerHealth(playerid, health);

	        if(health == 100.0) return SendClientMessage(playerid, FactColor[11], "You already have 100 health !");

	        SetPlayerHealth(playerid, 100.0);
	        SendClientMessage(playerid, FactColor[11], "You have been fully healed !");
	        return 1;
	    }
	}
	return SendClientMessage(playerid, FactColor[11], "You are not at the right place !");
}

new Float:WaterPos[11][3] =
{
	{ 252.1506,111.4887,1003.2188 },
	{ 270.2978,186.2076,1008.1719 },
	{ 249.6548,196.7341,1008.1719 },
	{ 257.9287,196.7354,1008.1719 },
	{ 229.1164,155.1423,1003.0234 },
	{ 227.3604,143.4446,1003.0234 },
	{ 231.3758,180.2250,1003.0313 },
	{ 227.3651,184.3604,1003.0313 },
	{ 1496.2740,1304.3014,1093.2891 },
	{ 1249.1284,5.7868,1008.2578 },
	{ 754.9944,-40.5415,1000.5859 }
};
Worked , thanks ..