SA-MP Forums Archive
Player clock switch - 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: Player clock switch (/showthread.php?tid=418300)



Player clock switch - HeLiOn_PrImE - 24.02.2013

So I found the function to toggle the player clock on or off:
Код:
public OnPlayerConnect(playerid)
{
    TogglePlayerClock(playerid, 1); // Show the clock
    return 1;
}
Is there a way make this affect all players by one command?
To type /playerclockon and the clock would be enabled for all.
/playerclockoff and it would be disabled.


Re: Player clock switch - TheOnlyRealFuzzy - 24.02.2013

Loop through the players and toggle it on/off.

Код:
for(new i = 0; i < MAX_PLAYERS; i++)
		{
		    if(IsPlayerConnected(i))
		    {
		    	TogglePlayerClock(i, 0); //or 1
		    }
		}



Re: Player clock switch - Patrick - 24.02.2013

Yes i agree with TheOnlyRealFuzzy Loop it through all players try this command.

you must have #include <zcmd> or you can convert it to what every command proccesor you are using

try this

pawn Код:
//Turn the Clock on for all connected players
CMD:playerclockon(playerid, params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            TogglePlayerClock(i, 1);
        }
    }
    return 1;
}

//Turn the Clock off for all connected players
CMD:playerclockon(playerid, params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            TogglePlayerClock(i, 0);
        }
    }
    return 1;
}



Re: Player clock switch - HeLiOn_PrImE - 26.02.2013

thx, guys, I'lll try it