What is the problem?
#6

Quote:
Originally Posted by Daynox12
Посмотреть сообщение
PHP код:
stock Float:GetDistanceBetweenPoints(Float:rx1,Float:ry1,Float:rz1,Float:rx2,Float:ry2,Float:rz2)
{
    return 
floatadd(floatadd(floatsqroot(floatpower(floatsub(rx1rx2), 2)), floatsqroot(floatpower(floatsub(ry1ry2), 2))), floatsqroot(floatpower(floatsub(rz1rz2), 2)));
}
stock GetClosestPlayer(playeridFloat:limit)
{
    new 
Float:x1Float:y1Float:z1Float:x2Float:y2Float:z2Float:Distid INVALID_PLAYER_ID;
    
GetPlayerPos(playerid,x1,y1,z1);
    for(new 
0MAX_PLAYERSi++)
    {
        if(!
IsPlayerConnected(i)) continue;
        if(
== playerid) continue;
        
GetPlayerPos(ix2y2z2);
        
Dist GetDistanceBetweenPoints(x1y1z1x2y2z2);
        if(
Dist limit || id == INVALID_PLAYER_ID)
        {
            
limit Dist;
            
id i;
        }
    }
    return 
id;

It's the function
As expected when the code doesn't find a player in range of your limit, it will return INVALID_PLAYER_ID, so basically add this code after the new victimid = GetClosestPlayer(playerid, 2.0);:
pawn Код:
if(victimid == INVALID_PLAYER_ID)  return 1;
Should fix that.
Reply


Messages In This Thread
What is the problem? - by Daynox12 - 02.06.2018, 19:24
Re: What is the problem? - by HoNEYKISS - 02.06.2018, 19:31
Re: What is the problem? - by Cell_ - 02.06.2018, 19:43
Re: What is the problem? - by Daynox12 - 02.06.2018, 19:43
Re: What is the problem? - by Daynox12 - 02.06.2018, 19:59
Re: What is the problem? - by Cell_ - 02.06.2018, 20:10
Re: What is the problem? - by Daynox12 - 02.06.2018, 20:12
Re: What is the problem? - by Daynox12 - 02.06.2018, 21:37
Re: What is the problem? - by Cell_ - 02.06.2018, 22:03
Re: What is the problem? - by GTLS - 03.06.2018, 06:11

Forum Jump:


Users browsing this thread: 1 Guest(s)