[Include] Advanced disconnect(leave) messages
#1

Im here for a long time and without any release :/ so lets relese something :P

What does it used for?
-Its a small and simple include that will hook to OnPlayerDisconnect and modify reason variable
[NOTE]These include is only for GameMode!

pawn Код:
#define REASON_CRASH        0 //Timed out
#define REASON_LEAVE        1 //Left normally (/q or ESC menu and quit)
#define REASON_KICK         2 //Kicked
#define REASON_BAN          3 //Banned
#define REASON_RECONNECT    4 //Custom reconnect function

I also added 2 custom functions
pawn Код:
native ReconnectPlayer(playerid);
native CrashPlayer(playerid);
Here is example how to use it (for newbies)
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new pName[MAX_PLAYER_NAME], StringMessage[128];
GetPlayerName(playerid, pName, sizeof(pName));
switch(reason)
{
    case REASON_CRASH: format(StringMessage, sizeof(StringMessage), "%s["embed_white"%i"embed_orange"]"embed_white" Has left the server! "embed_orange"[CRASH]",pName[playerid], playerid);
    case REASON_LEAVE: format(StringMessage, sizeof(StringMessage), "%s["embed_white"%i"embed_orange"]"embed_white" Has left the server! "embed_orange"[LEAVING]",pName[playerid], playerid);
    case REASON_KICK: format(StringMessage, sizeof(StringMessage), "%s["embed_white"%i"embed_orange"]"embed_white" Has left the server! "embed_orange"[KICK]",pName[playerid], playerid);
    case REASON_BAN: format(StringMessage, sizeof(StringMessage), "%s["embed_white"%i"embed_orange"]"embed_white" Has left the server! "embed_orange"[BAN]",pName[playerid], playerid);
    case REASON_RECONNECT: format(StringMessage, sizeof(StringMessage), "%s["embed_white"%i"embed_orange"]"embed_white" Has left the server! "embed_orange"[RECONNECT]",pName[playerid], playerid);
}
SendClientMessageToAll(0xFF0000AA, StringMessage);

}
If you find any bugs report them here
If you have any questions feel free ask

[Image: images?q=tbn:ANd9GcSHvLZnFsEUob40ZhwQyDn..._lSO5Bi4Tg]

Mirrors are welcome (PM me and i will add it)
Reply
#2

Looks nice, althout its easy! (:
Reply
#3

Its really cool.But one bug.

When any player leaves(Normal) it stays REASON_RECONNECT.Fix that.
Reply
#4

Quote:
Originally Posted by FireCat
Посмотреть сообщение
Looks nice, althout its easy! (:
For me and you yes but not for everyone :/
By the way i didnt see any server have disconnect reasons that makes difference between Kick and Ban (they all have Kick/Ban as reason)

Quote:
Originally Posted by MrEdinLaw
Посмотреть сообщение
Its really cool.But one bug.

When any player leaves(Normal) it stays REASON_RECONNECT.Fix that.
Everything is ok dont get confused with code.
Its create a new integer variable for each player (since its empty its 0)
When player ask for reconnect it will be set to 1 and on player disconnect if its 1 it will be reset to 0 no mater did player left before client asked to reconnect.
Reply
#5

GREAT WORK
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)