Freeze everyone.
#1

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.
Reply
#2

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);
        }
        }
Reply
#3

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?
Reply
#4

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?
Reply
#5

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.
Reply
#6

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
Reply
#7

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.
Reply
#8

could you show how you use teams id?
Reply
#9

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

Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)