View Single Post
Old 18/05/2020, 01:36 AM   #4
Filbert
Huge Clucker
 
Join Date: May 2016
Posts: 251
Reputation: 1
Default Re: countdown for near players

Quote:
Originally Posted by Ghazal View Post
You can have something like this or just loop all connected players and check if they're in range with the countdown issuer using IsPlayerInRangeOfPoint by getting the issuer's position and comparing it to other players
PHP Code:
forward Float:GetDistanceBetweenPlayers(p1,p2);
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));
}
public 
countdown()
{
    for(new 
i=0i<MAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i) && GetDistanceBetweenPlayers(playeridi) < 100.0// your range
        
{
            if(
CountDown == 6GameTextForAll("~p~Starting..."10006);

            
CountDown--;
            if(
CountDown == 0)
            {
                
GameTextForAll("~g~GO~ r~!"10006);
                
CountDown = -1;
                for(new 
0MAX_PLAYERSi++) {
                    
TogglePlayerControllable(itrue);
                    
PlayerPlaySound(i10570.00.00.0);
                }
                return 
0;
            }
            else
            {
                new 
text[7]; format(textsizeof(text), "~w~%d"CountDown);
                for(new 
0MAX_PLAYERSi++) {
                    
PlayerPlaySound(i10560.00.00.0);
                    
TogglePlayerControllable(ifalse);
                }
                 
GameTextForAll(text10006);
            }
            
SetTimer("countdown"10000);
        }
    }
    return 
0;

Is there an example map of, 100.0 range or 200.0 range?
Filbert is offline   Reply With Quote