[Tutorial] Simple Join/Leave msgs with reason
#1

Join/Leave Messages Tutorial

first , you have to define the colours we're going to use
pawn Код:
#include <a_samp>

#define COLOR_MAGENTA 0xFF00FFFF
#define COLOR_GREY 0xAFAFAFAA
Second , OnPlayerConnect
pawn Код:
public OnPlayerConnect(playerid)
{

    new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "[Join]: {eca3f7}%s joined the server", pname);
    SendClientMessageToAll(COLOR_MAGENTA, string);
    return 1;
}
new pname [MAX_PLAYER_NAME] is used in the (string) of (SendClientMessageToAll) to show the player's name
GetPlayerName is to get the logged in player name to be displayed to all players, the {eca3f7} is a colour nvm xD

3rd , the OnPlayerDisconnect function
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    switch(reason)
    {
        case 0: format(string, sizeof(string), "[Timout/Crashed]: %s left the server.", pname);
        case 1: format(string, sizeof(string), "[Quit]: %s left the server.", pname);
        case 2: format(string, sizeof(string), "[Kicked/Banned]: %s left the server.", pname);
    }
    SendClientMessageToAll(COLOR_GREY, string);
    return 1;

}
pname is already explained , switch&case is something nearly like if but a bit bigger , if u r gonna use them then ur case must start from 0 , otherwise it'll cause errors , in this switch&case we have only 3 cases , case 0 in case the player (Crashed) , case 1 in case the player quit or do /q , case 2 in case the player is kicked/banned by admin or anticheat/spam/advertise anything

hope its explained enough
Reply
#2

That is not a tutorial, It's not explained at all.
Reply
#3

Quote:
Originally Posted by Eth
Посмотреть сообщение
That is not a tutorial, It's not explained at all.
Sorry , it's my first tutorial post thread , editing .....
Reply
#4

Good editing . Well Explained + Rep for your first tutorial
Reply
#5

Explained good.

Good job and good luck in next tutorial!
Reply
#6

Quote:
Originally Posted by Eth
Посмотреть сообщение
That is not a tutorial, It's not explained at all.
Same thought,


It's me rbj, Zeus, go learn scripting :P
Reply
#7

Quote:
Originally Posted by Arastair
Посмотреть сообщение
Same thought,


It's me rbj, Zeus, go learn scripting :P
He edited it.
Reply
#8

Quote:
Originally Posted by Arastair
Посмотреть сообщение
Same thought,


It's me rbj, Zeus, go learn scripting :P
lol hey man , im not stopping to learn but i like to share what i know to those who dont know :P
Reply
#9

Quote:
Originally Posted by ItzRbj
Посмотреть сообщение
lol hey man , im not stopping to learn but i like to share what i know to those who dont know :P
But if you want my suggestion then you need to post a full Tutorial that will really help players
Reply
#10

Quote:
Originally Posted by Eth
Посмотреть сообщение
But if you want my suggestion then you need to post a full Tutorial that will really help players
i'll do it as soon as i get back home :3
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)