SA-MP Forums Archive
Freeze everyone. - 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: Freeze everyone. (/showthread.php?tid=402582)



Freeze everyone. - siemka321 - 27.12.2012

Is there a possible way to freeze every player? Because I made a timer and when it goes out it just freezes the first player. Same goes with playing sound. When the timer goes out it should freeze every player and play a sound, but it only freezes and plays a sound for 1 player.


Re: Freeze everyone. - DaRk_RaiN - 27.12.2012

pawn Код:
if (strcmp("/freezeall", cmdtext, true, 10) == 0)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
        if(IsPlayerConnected(i)&& i != playerid)
        {
        TogglePlayerControllable(i,0);
        }
        }
For rcon admin only
pawn Код:
if (strcmp("/freezeall", cmdtext, true, 10) == 0)
    {
       if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,-1,"Bitch please, you ain't admin");
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
        if(IsPlayerConnected(i)&& i != playerid)
        {
        TogglePlayerControllable(i,0);
        }
        }



Re: Freeze everyone. - siemka321 - 27.12.2012

Doesn't work for me, I also tried doing a timer too. But I don't need it as a command. How do I make it that after the timer goes off, everyone freezes and a sound will play?


Re: Freeze everyone. - DaRk_RaiN - 27.12.2012

Well if you tested it alone ofcouse it won't work i because i != playerid that won't freeze the only that used the command.
For the timer thing i didn't get the point explain more, you want a timer to go off but how will it go off?after you type a command?


Re: Freeze everyone. - siemka321 - 27.12.2012

Oh, I didn't realize that it won't work alone. The timer is in OnGameModeInit, the timer goes off and the GameTextForAll draws and stuff, but I also need a sound to play and everyone should freeze. I'm going to try with a friend now. Thanks for the help by the way.


Re: Freeze everyone. - mineralo - 27.12.2012

pawn Код:
SetTimer("FreezeAll",10000,1);
forward FreezeAll();
public FreezeAll()
{
for(new i = 0; i < MAX_PLAYERS; i++)
        {
        if(IsPlayerConnected(i))
        {
        TogglePlayerControllable(i,0);
        }}
        return 1;
}
put the timer on gamemode, this function will ONLY freeze everyone in game every 10 seconds, you can check time or to add other stuff


Re: Freeze everyone. - siemka321 - 27.12.2012

Thanks. It works. But now I have another problem. My gamemode has 2 teams: RED and BLUE. In the timer, I want the RED team to be teleported into a specific location and BLUE team has to be teleported into another place too. Using the same code doesn't work obviously. Tried doing it myself but didn't work.


Re: Freeze everyone. - mineralo - 27.12.2012

could you show how you use teams id?


Re: Freeze everyone. - siemka321 - 27.12.2012

https://sampforum.blast.hk/showthread.php?tid=339785
I used this tutorial.


Re: Freeze everyone. - DXM - 27.12.2012

Код:
freezeTeam(team, bool:freeze = true, seconds_to_unfreeze = 5000) { // freeze = true, unfreeze = false

	for (new i = GetMaxPlayers()-1; i >= 0; i--) {
	
		if (GetPlayerTeam(i) == team) 
			TogglePlayerControllable(i, freeze);
	}
	
	if (freeze) SetTimerEx("_unfreezeTeam", seconds_to_unfreeze, false, "i", team);
}


forward _unfreezeTeam(team);
public _unfreezeTeam(team) {

	for (new i = GetMaxPlayers()-1; i >= 0; i--) {
	
		if (GetPlayerTeam(i) == team) 
			TogglePlayerControllable(i, false);
	}
	
	return 1;
}