What is faster??? - 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: What is faster??? (
/showthread.php?tid=590654)
What is faster??? -
DusanInfinity - 02.10.2015
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;
}
Re: What is faster??? -
Aliassassin123456 - 02.10.2015
Natives are faster than the pawn code, so IsPlayerInRangeOfPoint is faster.
Re: What is faster??? -
DusanInfinity - 02.10.2015
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..)