Connect and Disconnect textdraw box.
#4

Код:
new PlayerText:I_text[MAX_PLAYERS] = {PlayerText:INVALID_TEXT_DRAW, ...};
new I_timer[MAX_PLAYERS];

stock I_textShow(playerid, color, text[], time)
{
    if(I_timer[playerid] != 0){
    if(I_text[playerid] != PlayerText:INVALID_TEXT_DRAW){
    PlayerTextDrawDestroy(playerid, I_text[playerid]);
    I_text[playerid] = PlayerText:INVALID_TEXT_DRAW;}
    KillTimer(I_timer[playerid]);}
    I_text[playerid] = CreatePlayerTextDraw(playerid, 635.000000, 422.750122, text);
    PlayerTextDrawLetterSize(playerid, I_text[playerid], 0.400000, 1.600000);
    PlayerTextDrawAlignment(playerid, I_text[playerid], 3);
    PlayerTextDrawColor(playerid, I_text[playerid], color);
    PlayerTextDrawSetOutline(playerid, I_text[playerid], 1);
    PlayerTextDrawShow(playerid, I_text[playerid]);
    I_timer[playerid] = SetTimerEx("I_timer_", time, false, "i", playerid);
    return 1;
}

forward I_timer_(playerid);
public I_timer_(playerid)
{
    if(!IsPlayerConnected(playerid)) return 1;
    if(I_text[playerid] != PlayerText:INVALID_TEXT_DRAW){
    PlayerTextDrawDestroy(playerid, I_text[playerid]);
    I_text[playerid] = PlayerText:INVALID_TEXT_DRAW;}
    I_timer[playerid] = 0;
    return 1;
}

stock pname(playerid)
{
    new name[24];
    if(IsPlayerConnected(playerid)){
    GetPlayerName(playerid, name, sizeof(name));}
    return name;
}

public OnPlayerConnect(playerid)
{
    new str[128];
    format(str, sizeof(str), "[JOIN] %s has joined the server.", pname(playerid));
    new HPID = GetPlayerPoolSize();
    for(new i=0; i <= HPID; i++){
    if(IsPlayerConnected(i)){
    I_textShow(i, 0x00FF00FF, str, 5000);}}
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new DisconnectReason[3][] =
    {
        "Timeout/Crash",
        "Quit",
        "Kick/Ban"
    };
    new str[128];
    format(str, sizeof(str), "[LEAVE] %s has left the server (%s).", pname(playerid), DisconnectReason[reason]);
    new HPID = GetPlayerPoolSize();
    for(new i=0; i <= HPID; i++){
    if(IsPlayerConnected(i)){
    I_textShow(i, 0xFF0000FF, str, 5000);}}
    return 1;
}
Reply


Messages In This Thread
Connect and Disconnect textdraw box. - by iAssassin - 10.06.2016, 10:02
Re: Connect and Disconnect textdraw box. - by justjamie - 10.06.2016, 10:59
Re: Connect and Disconnect textdraw box. - by iAssassin - 10.06.2016, 11:50
Re: Connect and Disconnect textdraw box. - by Adeon - 10.06.2016, 13:34
Re: Connect and Disconnect textdraw box. - by iAssassin - 10.06.2016, 14:11
Re: Connect and Disconnect textdraw box. - by iAssassin - 11.06.2016, 18:17

Forum Jump:


Users browsing this thread: 3 Guest(s)