OnPlayerPause detection! -
FireCat - 01.08.2012
Introduction
Hello guys (and dugi)!
This is a release, which I got the idea from
this topic.
So I re-scripted it and made it more efficient.
Script
It checks every 5 seconds if the player is paused.
There are 2 callbacks.
public OnPlayerPause(playerid)
public OnPlayerUnpause(playerid)
(you need to forward them)
Instalation
Under OnGameModeInit put:
And OnPlayerConnect put:
pawn Код:
OPP_OnPlayerConnect(playerid)
Video
[ame]http://www.youtube.com/watch?v=4jk3aiO24b8[/ame]
Re: OnPlayerPause detection! -
Larceny - 01.08.2012
You could use ******'s hooking method to be simpler the use.
Good job burned cat.
Re: OnPlayerPause detection! -
FireCat - 01.08.2012
Quote:
Originally Posted by RuiGy
You could use ****** hooking method to be simpler the use.
Good job burned cat.
|
Hahaha thank you :P
Re: OnPlayerPause detection! -
Littlehelper - 01.08.2012
Pink pause menu.
OT: nice.
Re: OnPlayerPause detection! -
Kar - 01.08.2012
I don't see your need for all those timers and health stuff?
pawn Код:
new PlayerUpdate[MAX_PLAYERS char], // less than 255 players, change it yourself if needed..
Paused[MAX_PLAYERS];
forward OnPlayerPause(playerid);
forward OnPlayerUnPause(playerid);
forward IsPlayerPaused(playerid);
public IsPlayerPaused(playerid) return Paused[playerid];
public OnPlayerUpdate(playerid)
{
if(PlayerUpdate{playerid} >= 2)
{
Paused[playerid] = 0;
CallRemoteFunction("OnPlayerUnPause", "i", playerid);
}
PlayerUpdate{playerid} = 0;
return 1;
}
public OnPlayerPause(playerid)
{
printf("[System] - %s(%d) Has Paused", Playername(playerid), playerid);
return 1;
}
public OnPlayerUnPause(playerid)
{
printf("[System] - %s(%d) Has Unpaused", Playername(playerid), playerid);
return 1;
}
// in a preferably 1 second timer
if(PlayerUpdate{i} < 2)
{
PlayerUpdate{i}++;
}
else
{
if(Paused[i] != 1)
{
CallRemoteFunction("OnPlayerPause", "i", i);
Paused[i] = 1;
}
}
Re: OnPlayerPause detection! -
FireCat - 01.08.2012
Quote:
Originally Posted by Kar
pawn Код:
PlayerUpdate[MAX_PLAYERS char], // less than 255 players, change it yourself if needed.. Paused[MAX_PLAYERS];
forward OnPlayerPause(playerid); forward OnPlayerUnPause(playerid); forward IsPlayerPaused(playerid);
//1 second timer
if(PlayerUpdate{i} < 2) { PlayerUpdate{i}++; } else { if(Paused[i] != 1) { CallRemoteFunction("OnPlayerPause", "i", i); Paused[i] = 1; } }
public OnPlayerUpdate(playerid) { if(PlayerUpdate{playerid} >= 2) { Paused[playerid] = 0; CallRemoteFunction("OnPlayerUnPause", "i", playerid); } PlayerUpdate{playerid} = 0; return 1; }
public OnPlayerPause(playerid) { printf("[System] - %s(%d) Has Paused", Playername(playerid), playerid); return 1; }
public OnPlayerUnPause(playerid) { printf("[System] - %s(%d) Has Unpaused", Playername(playerid), playerid); return 1; }
|
Why don't you go around all SA-MP forums and copy paste all the codes of "OnPlayerPause" detections too?
They all work!
Re: OnPlayerPause detection! -
Maxips2 - 01.08.2012
Very nice.
Btw a suggestion, maybe check if foreach is included and use it in the players loop?
Re: OnPlayerPause detection! -
Kar - 01.08.2012
Quote:
Originally Posted by FireCat
Why don't you go around all SA-MP forums and copy paste all the codes of "OnPlayerPause" detections too?
They all work!
|
No, my internet chipped so I couldn't edit it. Anyway... I don't see your use in "CheckPlayerHealth" yours is less efficient.. and I made that one...
Also your randomly changing players health? what if they are 0.1 from deathmatching and your code kills them huh? (1.5 second timer..)
You seriously want to discriminate, i'll point out even more bad stuff.
You should hook your callbacks ;\
I MEAN YOUR SERIOUSLY MAKING 1000 TIMERS FOR 1000 PLAYERS, UNDERSTAND


??
and for(new i; i != GetMaxPlayers();i++) ... don't call GetMaxPlayers() every time
Re: OnPlayerPause detection! -
Lorenc_ - 01.08.2012
You forgot to hook your callbacks.
Re: OnPlayerPause detection! -
FireCat - 01.08.2012
Quote:
Originally Posted by Lorenc_
You forgot to hook your callbacks.
|
What do you mean?
(damn)
Re: OnPlayerPause detection! -
Rudy_ - 01.08.2012
Waw
pastebin don't work for me
www.paste.ubuntu.com pl0x?
Re: OnPlayerPause detection! -
TheArcher - 02.08.2012
5000ms to detect if a player pauses? LOL and hook your callbacks
Re: OnPlayerPause detection! -
FireCat - 02.08.2012
Quote:
Originally Posted by TheArcher
5000ms to detect if a player pauses? LOL and hook your callbacks
|
Works perfect as it is.
If that amount of time bothers you, then change it.
Re: OnPlayerPause detection! -
TheArcher - 02.08.2012
Quote:
Originally Posted by FireCat
Works perfect as it is.
If that amount of time bothers you, then change it.
|
Its not the best way but however, good job just for the effort
Re: OnPlayerPause detection! -
Kiets - 02.08.2012
Quote:
Originally Posted by TheArcher
5000ms to detect if a player pauses? LOL and hook your callbacks
|
I think it is ok to use 5 seconds. People who are aiming or who are entering/exiting vehicles (not sure about vehicles) don't send OnPlayerUpdate, so it is not really 100% working.