join/kick/leave messages not in order
#1

I am using a text draw to show that players; leave/join/kick/time.. But they dont go in order? It kinda jumps around to where ever. I want the bottom message to be the newest. then the top to go away when a new bottom is added. Here is pictures;
In the first screen shot he got kicked but it showed it above the join. First screen shot
In the second he joins, but it replaces the kick with a join. Second screen shot
in the third he leaves, and it replaces his join message with a leave Third screen shot
here is the code:
pawn Код:
#define CONNECT_MESSAGES (5)

new Text:ConnectTextdraw[CONNECT_MESSAGES];
new CurrentIndex;

public OnFilterScriptInit()
{
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        ConnectTextdraw[i] = TextDrawCreate(496.000000, 253.000000 + (i * 10), "_");

        TextDrawBackgroundColor(ConnectTextdraw[i], 255);
        TextDrawFont(ConnectTextdraw[i], 1);
        TextDrawLetterSize(ConnectTextdraw[i], 0.2, 1.2);
        TextDrawColor(ConnectTextdraw[i], -1);
        TextDrawSetOutline(ConnectTextdraw[i], 1);
        TextDrawSetProportional(ConnectTextdraw[i], 1);
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    new playerName[MAX_PLAYER_NAME], string[64];
    GetPlayerName(playerid, playerName, sizeof(playerName));

    format(string, sizeof(string), "~g~join:~w~%s(%i)", playerName, playerid);

    TextDrawHideForAll(ConnectTextdraw[CurrentIndex]);
    TextDrawSetString(ConnectTextdraw[CurrentIndex], string);
    TextDrawShowForAll(ConnectTextdraw[CurrentIndex]);

    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        TextDrawShowForPlayer(playerid, ConnectTextdraw[i]);
    }

    return (CurrentIndex + 1 != CONNECT_MESSAGES) ? (CurrentIndex ++) : (CurrentIndex = 0);
}

public OnPlayerDisconnect(playerid, reason)
{
    new playerName[MAX_PLAYER_NAME], string[64];
    GetPlayerName(playerid, playerName, sizeof(playerName));

    format(string, sizeof(string), "~r~%s: ~w~%s(%i)", (reason == 0) ? ("TIME") : ((reason == 1) ? ("QUIT") : ("KICK")),playerName, playerid);

    TextDrawHideForAll(ConnectTextdraw[CurrentIndex]);
    TextDrawSetString(ConnectTextdraw[CurrentIndex], string);
    TextDrawShowForAll(ConnectTextdraw[CurrentIndex]);

    return (CurrentIndex + 1 != CONNECT_MESSAGES) ? (CurrentIndex ++) : (CurrentIndex = 0);
}

public OnGameModeExit()
{
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        TextDrawDestroy(ConnectTextdraw[i]);
    }
    return 1;
}
Reply
#2

Try this:

pawn Код:
#include <a_samp>
#define CONNECT_MESSAGES (5)

new Text:ConnectTextdraw[CONNECT_MESSAGES];
new CurrentStr[64];

public OnFilterScriptInit()
{
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        ConnectTextdraw[i] = TextDrawCreate(496.000000, 253.000000 + (i * 10), "_");

        TextDrawBackgroundColor(ConnectTextdraw[i], 255);
        TextDrawFont(ConnectTextdraw[i], 1);
        TextDrawLetterSize(ConnectTextdraw[i], 0.2, 1.2);
        TextDrawColor(ConnectTextdraw[i], -1);
        TextDrawSetOutline(ConnectTextdraw[i], 1);
        TextDrawSetProportional(ConnectTextdraw[i], 1);
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    new playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, sizeof(playerName));

    CurrentStr[0] = CurrentStr[1];
    CurrentStr[1] = CurrentStr[2];
    CurrentStr[2] = CurrentStr[3];
    CurrentStr[3] = CurrentStr[4];

    format(CurrentStr[4], sizeof(CurrentStr[]), "~g~join:~w~%s(%i)", playerName, playerid);
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        TextDrawSetString(ConnectTextdraw[i], CurrentStr[i]);
        TextDrawShowForPlayer(playerid, ConnectTextdraw[i]);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, sizeof(playerName));

    CurrentStr[0] = CurrentStr[1];
    CurrentStr[1] = CurrentStr[2];
    CurrentStr[2] = CurrentStr[3];
    CurrentStr[3] = CurrentStr[4];

    format(CurrentStr[4], sizeof(CurrentStr[]), "~r~%s: ~w~%s(%i)", (reason == 0) ? ("TIME") : ((reason == 1) ? ("QUIT") : ("KICK")),playerName, playerid);
    for(new i=0; i < CONNECT_MESSAGES; i++) TextDrawSetString(ConnectTextdraw[i], CurrentStr[i]);
    return 1;
}

public OnGameModeExit()
{
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        TextDrawDestroy(ConnectTextdraw[i]);
    }
    return 1;
}
Reply
#3

now they dont show at all. But i found out what its doing. Its starting from the top and going down the list. So the newest join/leave/kick/time starts at the top then goes down. I want to make it opposite of that
Reply
#4

I have loaded this as an FS and it works fine for me: (Latest is at bottom, oldest at top).

pawn Код:
#include <a_samp>
#define CONNECT_MESSAGES (5)

new Text:ConnectTextdraw[CONNECT_MESSAGES];
new CurrentStr[5][64];

public OnFilterScriptInit()
{
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        ConnectTextdraw[i] = TextDrawCreate(496.000000, 253.000000 + (i * 10), "_");

        TextDrawBackgroundColor(ConnectTextdraw[i], 255);
        TextDrawFont(ConnectTextdraw[i], 1);
        TextDrawLetterSize(ConnectTextdraw[i], 0.2, 1.2);
        TextDrawColor(ConnectTextdraw[i], -1);
        TextDrawSetOutline(ConnectTextdraw[i], 1);
        TextDrawSetProportional(ConnectTextdraw[i], 1);
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    new playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, sizeof(playerName));

    CurrentStr[0] = CurrentStr[1];
    CurrentStr[1] = CurrentStr[2];
    CurrentStr[2] = CurrentStr[3];
    CurrentStr[3] = CurrentStr[4];

    format(CurrentStr[4], sizeof(CurrentStr[]), "~g~join:~w~%s(%i)", playerName, playerid);
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        TextDrawSetString(ConnectTextdraw[i], CurrentStr[i]);
        TextDrawShowForPlayer(playerid, ConnectTextdraw[i]);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, sizeof(playerName));

    CurrentStr[0] = CurrentStr[1];
    CurrentStr[1] = CurrentStr[2];
    CurrentStr[2] = CurrentStr[3];
    CurrentStr[3] = CurrentStr[4];

    format(CurrentStr[4], sizeof(CurrentStr[]), "~r~%s: ~w~%s(%i)", (reason == 0) ? ("TIME") : ((reason == 1) ? ("QUIT") : ("KICK")),playerName, playerid);
    for(new i=0; i < CONNECT_MESSAGES; i++) TextDrawSetString(ConnectTextdraw[i], CurrentStr[i]);
    return 1;
}

public OnGameModeExit()
{
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        TextDrawDestroy(ConnectTextdraw[i]);
    }
    return 1;
}
Reply
#5

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
pname[MAX_PLAYER_NAME], string[39 MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    switch(
reason)
    {
        case 
0format(stringsizeof(string), "%s left the server [crash]."pname);
        case 
1format(stringsizeof(string), "%s left the server [/q]."pname);
        case 
2format(stringsizeof(string), "%s left the server [kick/ban]"pname);
    }
    
SendClientMessageToAll(0xFFFFFFAAstring);
    return 
1;

it works on my server perfectly!
Reply
#6

Quote:
Originally Posted by ProdrifterX
Посмотреть сообщение
PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
pname[MAX_PLAYER_NAME], string[39 MAX_PLAYER_NAME];
    
GetPlayerName(playeridpnamesizeof(pname));
    switch(
reason)
    {
        case 
0format(stringsizeof(string), "%s left the server [crash]."pname);
        case 
1format(stringsizeof(string), "%s left the server [/q]."pname);
        case 
2format(stringsizeof(string), "%s left the server [kick/ban]"pname);
    }
    
SendClientMessageToAll(0xFFFFFFAAstring);
    return 
1;

it works on my server perfectly!
thats not a text draw.
Reply
#7

Quote:
Originally Posted by Jeffry
Посмотреть сообщение
I have loaded this as an FS and it works fine for me: (Latest is at bottom, oldest at top).

pawn Код:
#include <a_samp>
#define CONNECT_MESSAGES (5)

new Text:ConnectTextdraw[CONNECT_MESSAGES];
new CurrentStr[5][64];

public OnFilterScriptInit()
{
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        ConnectTextdraw[i] = TextDrawCreate(496.000000, 253.000000 + (i * 10), "_");

        TextDrawBackgroundColor(ConnectTextdraw[i], 255);
        TextDrawFont(ConnectTextdraw[i], 1);
        TextDrawLetterSize(ConnectTextdraw[i], 0.2, 1.2);
        TextDrawColor(ConnectTextdraw[i], -1);
        TextDrawSetOutline(ConnectTextdraw[i], 1);
        TextDrawSetProportional(ConnectTextdraw[i], 1);
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    new playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, sizeof(playerName));

    CurrentStr[0] = CurrentStr[1];
    CurrentStr[1] = CurrentStr[2];
    CurrentStr[2] = CurrentStr[3];
    CurrentStr[3] = CurrentStr[4];

    format(CurrentStr[4], sizeof(CurrentStr[]), "~g~join:~w~%s(%i)", playerName, playerid);
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        TextDrawSetString(ConnectTextdraw[i], CurrentStr[i]);
        TextDrawShowForPlayer(playerid, ConnectTextdraw[i]);
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new playerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playerName, sizeof(playerName));

    CurrentStr[0] = CurrentStr[1];
    CurrentStr[1] = CurrentStr[2];
    CurrentStr[2] = CurrentStr[3];
    CurrentStr[3] = CurrentStr[4];

    format(CurrentStr[4], sizeof(CurrentStr[]), "~r~%s: ~w~%s(%i)", (reason == 0) ? ("TIME") : ((reason == 1) ? ("QUIT") : ("KICK")),playerName, playerid);
    for(new i=0; i < CONNECT_MESSAGES; i++) TextDrawSetString(ConnectTextdraw[i], CurrentStr[i]);
    return 1;
}

public OnGameModeExit()
{
    for(new i=0; i < CONNECT_MESSAGES; i++)
    {
        TextDrawDestroy(ConnectTextdraw[i]);
    }
    return 1;
}
Thanks!
Reply
#8

Quote:
Originally Posted by googamalugafoo
Посмотреть сообщение
Thanks!
No problem, and have a Merry Christmas.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)