What is faster???
#1

Im optimizing my script, and i have 1 question.

What is better of these 3 ways?

1. way

Код:
IsPlayerInRangeOfPoint(playerid, Float:range, Float:x, Float:y, Float:z)
2. way

Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:temp1posx, Float:temp1posy, Float:temp1posz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		temp1posx = (oldposx -x);
		temp1posy = (oldposy -y);
		temp1posz = (oldposz -z);
		if (((temp1posx < radi) && (temp1posx > -radi)) && ((temp1posy < radi) && (temp1posy > -radi)) && ((temp1posz < radi) && (temp1posz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}
3. way

Код:
public PlayerToPointStripped(Float:radi, playerid, Float:x, Float:y, Float:z, Float:curx, Float:cury, Float:curz)
{
    if(IsPlayerConnected(playerid))
	{
		new Float:temp1posx, Float:temp1posy, Float:temp1posz;
		temp1posx = (curx -x);
		temp1posy = (cury -y);
		temp1posz = (curz -z);
		if (((temp1posx < radi) && (temp1posx > -radi)) && ((temp1posy < radi) && (temp1posy > -radi)) && ((temp1posz < radi) && (temp1posz > -radi))) return 1;
	}
	return 0;
}
Reply
#2

Natives are faster than the pawn code, so IsPlayerInRangeOfPoint is faster.
Reply
#3

It will optimize my script too much or

In one function, i have about 50 checks for player position(if is player to point, it will teleport him to interior..)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)