How can I create a list using textdraws?
#1

Hi guys, so I want to create a list using textdraws, I've already made the textdraws but I don't know how to start I want to do a list for how many vips are in the server and if a vip logs out he gets removed from the list but when he logs in he's in the list.

And I already searched ******, I didn't find anything that looks to how I want it.

Thanks for your time!
Reply
#2

This is what you looking for ?

CMD:viponlinemem(playerid, params[])
{
new szDialog[1024];
foreach(new i: Player)
{
if(PlayerInfo[i][pDonateRank] >= 1)
{
format(szDialog, sizeof(szDialog), "%s\n* %s (%d)", szDialog, GetPlayerNameEx(i), PlayerInfo[i][pDonateRank]);
}
}
ShowPlayerDialog(playerid, 1849, DIALOG_STYLE_LIST, "Online VIP Members", szDialog, "Skip", "");
return 1;
}
Reply
#3

Quote:
Originally Posted by TunisianoGamer
Посмотреть сообщение
This is what you looking for ?

CMD:viponlinemem(playerid, params[])
{
new szDialog[1024];
foreach(new i: Player)
{
if(PlayerInfo[i][pDonateRank] >= 1)
{
format(szDialog, sizeof(szDialog), "%s\n* %s (%d)", szDialog, GetPlayerNameEx(i), PlayerInfo[i][pDonateRank]);
}
}
ShowPlayerDialog(playerid, 1849, DIALOG_STYLE_LIST, "Online VIP Members", szDialog, "Skip", "");
return 1;
}
If I write textdraws several times, you're still stupid enough to give me a dialog, you've plagarized it too, idiot.

Obviously that wasen't what I meant.
Please only reply if you're here to help me.
Reply
#4

Bump.
Reply
#5

Well I can imagine right now how it should look, do you want just a list with the names under each other like

name1
name2
name3
...

But than is the question how long is the list, is it scrollable ? or what happens if more vips are online than space in the vip list
Reply
#6

Quote:
Originally Posted by Turn
Посмотреть сообщение
If I write textdraws several times, you're still stupid enough to give me a dialog, you've plagarized it too, idiot.
Obviously that wasen't what I meant.
Please only reply if you're here to help me.
No need to attack him like that, be glad he tried to help.

Ontopic: Just replace that ShowPlayerDialog from his code with TextDrawSetString.
Reply
#7

Create one textdraw where names will be showed. And my question is, is this textdraw display everytime or when player use command?
Код:
new String[256];
new PlayerName[MAX_PLAYER_NAME];
for(new A,B = GetMaxPlayers(); A < B; A++)
{
	if(IsPlayerConnected(A) && IsPlayerVip(A)) format(String,sizeof(String),"%s%s\n",String,PlayerName);
}
TextDrawSetString(TextDrawId,String);
Something like that.
Reply
#8

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
Well I can imagine right now how it should look, do you want just a list with the names under each other like

name1
name2
name3
...

But than is the question how long is the list, is it scrollable ? or what happens if more vips are online than space in the vip list
The list is 20 lines long, I've designed the textdraws to go under eachother by using ~n~, I tried putting twenty names too and it worked so no problem there, I just want to know how to put the names under eachother when vips login,

like First vip logs in to the server, it puts his name on the vip list textdraw, second logs in it puts him under the first vip third vip logs in it puts him under the second vip, and if the second vip logs out it simply removes him from the list and puts the third vip under the first vip so the list is organized again.

Quote:
Originally Posted by Schneider
Посмотреть сообщение
No need to attack him like that, be glad he tried to help.

Ontopic: Just replace that ShowPlayerDialog from his code with TextDrawSetString.
How was he trying to help? he copied a command he found on some script and pasted it here and then he's stupid enough to post it as a dialog, I clearly stated not to reply if you can't help so once again, fuck off.
Quote:
Originally Posted by Raweresh
Посмотреть сообщение
Create one textdraw where names will be showed. And my question is, is this textdraw display everytime or when player use command?
Код:
new String[256];
new PlayerName[MAX_PLAYER_NAME];
for(new A,B = GetMaxPlayers(); A < B; A++)
{
	if(IsPlayerConnected(A) && IsPlayerVip(A)) format(String,sizeof(String),"%s%s\n",String,PlayerName);
}
TextDrawSetString(TextDrawId,String);
Something like that.
This would definitely not work.
Reply
#9

Well than you should have some kind of an textdraw array
additionally we need a variable to store which vip is stored in each line
pawn Код:
enum eVipList {
    Text: vTID, // Textdrawid
    vPID // playerid
} // just an example variable
new gVipList[20][eVipList];
// I expect that you create the textdraw in OnGameModeInit, something like that
for(new i; i < 20; ++i) {
    // setting every position to INVALID_PLAYER_ID
    gVipText[i][vPID] = INVALID_PLAYER_ID;
    // the first textdraw (id 0) is the highest one in my example
    gVipText[i][vTID] = TextDrawCreate(50.0, 50.0 + i * 5.0, "_");
    // other textdraw functions to customize it
}
now we need two functions one to add and one to remove the player from it
pawn Код:
VipListAdd(playerid) {
    for(new idx; idx < sizeof gVipList; ++idx) {
        if(gVipList[idx][vPID] == INVALID_PLAYER_ID) {
            // we found a free spot
            new
                name[MAX_PLAYER_NAME]
            ;
            if(GetPlayerName(playerid, name, sizeof name)) {
                TextDrawSetString(gVipList[idx][vTID], name);
                gVipList[idx][vPID] = playerid;
                return true;
            }
            break;
        }
    }
    return false;
}

VipListRemove(playerid) {
    for(new idx; idx < sizeof gVipList; ++idx) {
        if(gVipList[idx][vPID] == playerid) {
            // we found the player in the list, now shuffle everyone up and update the names
            new
                name[MAX_PLAYER_NAME]
            ;
            do {
                if(GetPlayerName((gVipList[idx][vPID] = gVipList[idx + 1][vPID]), name, sizeof name) == 0) {
                    // we hit in INVALID PLAYER ID because it isn't connected
                    TextDrawSetString(gVipList[idx][vTID], "_");
                    return true;
                }
                TextDrawSetString(gVipList[idx][vTID], name);
            } while(++idx < (sizeof gVipList - 1));
            // if the list was full we set the last to invalid
            TextDrawSetString(gVipList[sizeof gVipList - 1][vTID], "_");
            gVipList[sizeof gVipList - 1][vPID] = INVALID_PLAYER_ID;
            return true;
        }
    }
    return false;
}
// OnPlayerConnect
if(IsPlayerVIP(playerid)) {
    VipListAdd(playerid);
}
// OnPlayerDisconnect
// we don't need to check if the player is a vip here because it only removes the player if he is on the list
// but it will prevent useless function calls
if(IsPlayerVIP(playerid)) {
    VipListRemove(playerid);
}
Reply
#10

Nero, it dosen't work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)