Checking Pause Screen
#1

I want to check if a player pressed the escape button and he is paused to avoid damage.

Would it work if I set his health - 1. If his I check his health after that and it hasn't changed, does that mean he is paused?

Thanks and any other suggestions would work.
Reply
#2

A good idea is, to set OnPlayerUpdate a variable value to 1.

Now, create a timer every second (1000 ms), and lower the defined value by 1.
Check on that timer if the value is zero (if it's decreased), if so, he paused for one second.

This is because OnPlayerUpdate is not called when the player pauses, therefore the value is not set to 1 anymore and can decrease (timers are still executed).

But for a more efficent way use the OnPlayerPause include.
Reply
#3

Quote:
Originally Posted by admantis
Посмотреть сообщение
A good idea is, to set OnPlayerUpdate a variable value to 1.

Now, create a timer every second (1000 ms), and lower the defined value by 1.
Check on that timer if the value is zero (if it's decreased), if so, he paused for one second.

This is because OnPlayerUpdate is not called when the player pauses, therefore the value is not set to 1 anymore and can decrease (timers are still executed).

But for a more efficent way use the OnPlayerPause include.
I tried that include and it didn't work good. I found this though (credits to ev0lutionnn):

pawn Код:
new lastupdate[MAX_PLAYERS];
public OnPlayerUpdate(playerid) {
  lastupdate[playerid] = GetTickCount();
  return 1;
}
pawn Код:
if(GetTickCount() > (lastupdate[playerid]+2000))
pawn Код:
#define IsPlayerPaused(%1) GetTickCount() > (lastupdate[%1]+2000)
That works great! Thanks anyways :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)