Mysql function problem, mGetLastRegistered();
#1

Hi, I have been trying to make a function which searches my mysql database looking for the last registered player,

So far I have,

pawn Код:
stock mGetLastRegistered()
{
    new tmp[24]="\0";
    if(mCheckConnection()) {
    mysql_query("SELECT * FROM `players` ORDER BY id DESC LIMIT 1");
    mysql_store_result();
    if(mysql_num_rows()) {
        new playername[24];
        new resultline[1024];
        mysql_fetch_row(resultline);
      mysql_fetch_field_row(playername,"playername");
        mysql_free_result();
        strcpy(tmp,playername,24);
        }
    }
    return tmp;
}

@ onplayerconnect I have,

pawn Код:
format(vps,sizeof(vps),"This server has a total of %d registered users, our latest registered player is %s",mGetRegistered(),mGetLastRegistered());
  SendClientMessage(playerid,ChangeNameColour,vps);

Though with this function when I join the server, all mysql related things do not work, I have tryed everything but no success.

I'm using G-Stylezz mysql plugin, can anyone fix this function for me please.
Reply
#2

ORDER BY `id ` ?
Reply
#3

I just tried that and still doesn't work, Thanks for trying anyway, any further help is appreciated.
Reply
#4

in your OnGameModeInit put
Код:
mysql_debug(1);
before your connect code and it will create sql log in the server dir named "mysql_log.txt" it should log the error there
Reply
#5

Why you poste here?
Reply
#6

Quote:
Originally Posted by SoeH
Why you poste here?
he wants help with his script in the "Scripting Discussion"
Reply
#7

Quote:
Originally Posted by GTA967
in your OnGameModeInit put
Код:
mysql_debug(1);
before your connect code and it will create sql log in the server dir named "mysql_log.txt" it should log the error there
Nothing was showing up in the mysql.log, However I did find the problem, I had the wrong version of "strcpy"

And thanks for trying
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)