[Include] OnPlayerPause detection!
#1

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:
pawn Код:
OPP_OnGameModeInit()
And OnPlayerConnect put:
pawn Код:
OPP_OnPlayerConnect(playerid)
Video
[ame]http://www.youtube.com/watch?v=4jk3aiO24b8[/ame]
Reply
#2

You could use ******'s hooking method to be simpler the use.
Good job burned cat.
Reply
#3

Quote:
Originally Posted by RuiGy
Посмотреть сообщение
You could use ****** hooking method to be simpler the use.
Good job burned cat.
Hahaha thank you :P
Reply
#4

Pink pause menu.
OT: nice.
Reply
#5

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

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

Very nice.

Btw a suggestion, maybe check if foreach is included and use it in the players loop?
Reply
#8

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

You forgot to hook your callbacks.
Reply
#10

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
You forgot to hook your callbacks.
What do you mean?
(damn)
Reply
#11

Waw pastebin don't work for me
www.paste.ubuntu.com pl0x?
Reply
#12

5000ms to detect if a player pauses? LOL and hook your callbacks
Reply
#13

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

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

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


Forum Jump:


Users browsing this thread: 3 Guest(s)