[HELP] Freeze time
#1

Hello

I'm making some jobs for my RP server. My question is how to make that on player enter checkpoint server freeze him on xx seconds, for example 5?
Reply
#2

pawn Code:
TogglePlayerControllable 0     // freeze

TogglePlayerControllable 1   // unfreeze
Reply
#3

I know that... And I know to set timer... :/
But, how to freeze player, and after 5 seconds unfreeze him?
Reply
#4

Quote:
Originally Posted by Pooh7
View Post
I know that... And I know to set timer... :/
But, how to freeze player, and after 5 seconds unfreeze him?
No you don't know that.

1. Freeze player
pawn Code:
TogglePlayerControllable 0
2. Set the timer for 5 seconds.


3. Unfreeze player
pawn Code:
TogglePlayerControllable 1
Reply
#5

You'll need SetTimerEx if you want to freeze a specific player:

https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#6

From the forum:


Quote:
Originally Posted by Lorenc_
View Post
FreezeThenAutoUnfreeze(playerid, time)
Just freeze a player for a certain amount of time.
pawn Code:
FreezeThenAutoUnfreeze(playerid, time)// time is in Milliseconds, to make the player controllable again.
Whole code (add to fs or inc):
pawn Code:
stock FreezeThenAutoUnfreeze(playerid, time)
{
    TogglePlayerControllable(playerid, 0);
    SetTimerEx("UnfreezeBastard", time, false, "i", playerid);
}
forward UnfreezeBastard(playerid);
public UnfreezeBastard(playerid)
{
    TogglePlayerControllable(playerid, 1);
}
This is very basic, no bad comments lol.

Working... You can upgrade the function maybe by putting sounds and a gametext, just sayin
Link to the original topic http://forum.sa-mp.com/showthread.ph...rex#post769935
Reply
#7

wow awesome prooof
Reply
#8

Freezes the player for 5 seconds:
pawn Code:
#define SECONDS 5 // Define how many seconds you want a player to be frozen.
CMD:freezemefor5secs( playerid, params[ ] ) {
    TogglePlayerControllable( playerid, 0 );
    return SetTimerEx( "FreezeUnfreeze", SECONDS * 1000, 0, "i", playerid );
}

forward FreezeUnfreeze( playerid );
public FreezeUnfreeze( playerid ) {
    return TogglePlayerControllable( playerid, 1 );
}
If you really want a function (time in seconds):
pawn Code:
stock FreezePlayerForTime( playerid, time ) {
    TogglePlayerControllable( playerid, 0 );
    return SetTimerEx( "FreezeUnfreezeTimer", time * 1000, 0, "i", playerid );
}

forward FreezeUnfreezeTimer( playerid );
public FreezeUnfreezeTimer( playerid ) {
    return TogglePlayerControllable( playerid, 1 );
}
Example usage:
pawn Code:
FreezePlayerForTime( playerid, 5 ); // Freezes a player for 5 seconds.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)