countdown for near players
#3

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;

Reply


Messages In This Thread
countdown for near players - by Filbert - 18.05.2020, 00:31
Re: countdown for near players - by AzertyTheProgrammer - 18.05.2020, 00:58
Re: countdown for near players - by Ghazal - 18.05.2020, 01:25
Re: countdown for near players - by Filbert - 18.05.2020, 01:36
Re: countdown for near players - by Filbert - 19.05.2020, 19:40
Re: countdown for near players - by Grim_ - 19.05.2020, 23:25

Forum Jump:


Users browsing this thread: 1 Guest(s)