Accounts registered textdraw help!
#1

Hello guys!
Recently I created a textdraw that when the player connects shows how many accounts are registered,how many are banned and how many clans have been created.But I my problem is that i can't really make it useable,so it shows the real values.(The real count of registered player,etc.)I'm using MySQL r33.
Please show me an example how can i make them so they show the last registered players` Key`,and then i'll make the rest!
Thanks!
Reply
#2

Make a global variable and increase the amount of that variable ++ , update the textdraw string on each command like ban , register example
pawn Код:
new globalvariable;//at the top.
CMD:ban(playerid,params[])
{
    globalvariable ++;
    new string[60];
    format(string,sizeof(string),"There are %d banned players",globalvariable);
    TextDrawSetString(example, string);
    TextDrawShowForPlayer(playerid, example);  
    return 1;
}
Also you've to do the same on each register , if you're using dialogs you have to do that OnDialogResponse callback , if you are using command like /login , /register just incease the variable. hope you understand me.
Reply
#3

But i want to do something like the textdraw to read these informations from the database..So that number of registered players for example to be read from the database..
Sorry for my english..
Reply
#4

Someone?
Reply
#5

I didn't test this, but something similar should do:

pawn Код:
mysql_tquery(connectionHandle, "SELECT (SELECT COUNT(*) FROM `users`) AS `user_count`, (SELECT COUNT(*) FROM `bans`) AS `ban_count`", "mysql_GetServerStats", "");

public mysql_GetServerStats()
{
    if(cache_get_row_count())
    {
        new users = cache_get_field_content_int(0, "user_count");
        new bans = cache_get_field_content_int(0, "ban_count");
       
        new td_string[64];
        format(td_string, sizeof(td_string), "Registered users: %d~n~Bans: %d", user_count, ban_count);
        TextDrawSetString(textdraw_id, td_string);
    }
    return 1;
}
Reply
#6

Thanks,but where shall I add them?
Reply
#7

Please somebody tell me!
Reply
#8

Sorry for 3x post,but it's important!
Where shall I put that code?
pawn Код:
mysql_tquery(connectionHandle, "SELECT (SELECT COUNT(*) FROM `users`) AS `user_count`, (SELECT COUNT(*) FROM `bans`) AS `ban_count`", "mysql_GetServerStats", "");

public mysql_GetServerStats()
{
    if(cache_get_row_count())
    {
        new users = cache_get_field_content_int(0, "user_count");
        new bans = cache_get_field_content_int(0, "ban_count");
       
        new td_string[64];
        format(td_string, sizeof(td_string), "Registered users: %d~n~Bans: %d", user_count, ban_count);
        TextDrawSetString(textdraw_id, td_string);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)