dialog dude
#1

How to put if a player is online or offline in a DIALOG_STYLE_TABLIST_HEADERS, that is, say "offline" and "online" when connected

new string[1000], xdxdxd[256], str[700], str2[40];
new string2[500];
new DBResult:result;
new DBResult:result2;
format(xdxdxd,sizeof(xdxdxd),"SELECT `Nick` FROM `Usuarios` ORDER BY (`SCORE` * 1) DESC limit 10");
result = db_query(BaseDeDatos,xdxdxd);

new color = (random(256) * 16777216) + (random(256) * 65536) + (random(256) * 256) + 255;

strcat(str, "{FFFFFF}ID\tNick\tScore\tEstado\n");
for(new a;a<db_num_rows(result);a++)
{
switch(Inf[a][rtopon])
{
case 0: tmp311 = "OFF";
case 1: tmp311 = "ON";
default: tmp311 = "OFF";
}
db_get_field(result,0,string,12;
format(xdxdxd,sizeof(xdxdxd),"SELECT `SCORE` FROM `Usuarios` WHERE `Nick` = '%s'",string);
result2 = db_query(BaseDeDatos,xdxdxd);
db_get_field(result2,0,string2,12;
format(str2,sizeof(str2),"%d\t{%06x}%s\t{FFFFFF}%s \t{FFFFFF}%s\n",a+1,color >>> 8,string,string2);
strcat(str, str2);
db_next_row(result);
db_free_result(result2);
Reply
#2

upppppppppppp
Reply
#3

Since you retrieve the player's name, you can use sscanf and format accordingly:
pawn Код:
new online_player;
...

// "string" stores the player's name
sscanf(string, "r", online_player);

...

// when formatting for the dialog..
format(..., "... %s ...", ..., online_player != INVALID_PLAYER_ID ? ("Online") : ("Offline"), ...);
And like I had told you in the past, select the score and player's name at the same query: https://sampforum.blast.hk/showthread.php?tid=618262
Reply
#4

thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)