Some errors with GetClosestPlayer
#1

C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(1533) : warning 219: local variable "Range" shadows a variable at a preceding level
C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(1535) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(1540) : error 017: undefined symbol "GetDistanceBetweenPoints"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

PHP код:
CMD:respawn(playeridparams[])
{
   if(
connected[playerid] == true) return GameTextForPlayer(playerid"~r~Spawn First"50005);
   if(
GetPVarInt(playerid,"CMDABUSE")>GetTickCount())return SendClientMessage(playerid,-1,"{c3c3c3}(INFO) You need to wait 10 seconds before using /respawn again!");
   
Killed[playerid] = 0;
   
SetPVarInt(playerid,"CMDABUSE",GetTickCount()+10000); // anti abuse measurements
   
new interiorID GetPlayerInterior(playerid);
   new 
Float:health;
   
GetPlayerHealth(playerid,health);
   if(
interiorID == 10) return SendClientMessage(playerid, -1"{c3c3c3}You can't use /respawn while in lobby, type /back first!"); // checking if player is in /lobby before typing /respawn
   
if(health 90)
   {
        
RespawnNearby(playerid15.0);
        
SpawnPlayer(playerid);
        
SendClientMessage(playerid, -1"{c3c3c3}(INFO) You have respawned!");
        
PlayerTotalKills[playerid] = 0;
        
Killed[playerid] = 0;
   }
   else
   {
      
SendClientMessage(playerid, -1"{c3c3c3}(INFO) Atleast 90hp is required in order to respawn.");
   }
   return 
1;

PHP код:
stock RespawnNearby(playerid,Float:limit)
{
    new 
Float:x1Float:y1Float:z1Float:x2Float:y2Float:z2;
    
GetPlayerPos(playerid,x1,y1,z1);
    new 
Float:Range 3.0;
    new 
id = -1;
    foreach(
Player,i)
    {
        if(
playerid != i)
        {
            
GetPlayerPos(i,x2,y2,z2);
            new 
Float:Dist GetDistanceBetweenPoints(x1,y1,z1,x2,y2,z2); 
            if(
floatcmp(Range,Dist) == && floatcmp(limit,Range) == 1)
            {
                
Range Dist;
                
id i;
            }
        }
    }
    return 
id;

Line 1533:

PHP код:
new Float:Range 3.0
Line 1535:

PHP код:
foreach(Player,i
Line: 1540

PHP код:
new Float:Dist GetDistanceBetweenPoints(x1,y1,z1,x2,y2,z2); 
Reply
#2

First 2 warnings occur because you already defined them above somewhere above your code. Just rename range to pRange and further edit it.
Use IsPlayerInRange, instead off get distance.
Reply
#3

C:\Users\Wallen\Desktop\LS DM\gamemodes\DBv1.pwn(1540) : error 017: undefined symbol "IsPlayerInRange"
Reply
#4

https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Reply
#5

This looks like won't help me as i'am looking for the command to respawn to the nearby players, i already got the random spawn positions, he must take one of these random positions to one closest to the players.
Reply
#6

well I dont understand what do u want
Reply
#7

Above init:
PHP код:
forward Float:GetDistanceBetweenPlayers(p1,p2); 
Below your code.
PHP код:
public Float:GetDistanceBetweenPlayers(p1,p2)
{
    new 
Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if (!
IsPlayerConnected(p1) || !IsPlayerConnected(p2))
    {
        return -
1.00;
    }
    
GetPlayerPos(p1,x1,y1,z1);
    
GetPlayerPos(p2,x2,y2,z2);
    return 
floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)