SA-MP Forums Archive
Mysql function problem, mGetLastRegistered(); - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Mysql function problem, mGetLastRegistered(); (/showthread.php?tid=110172)



Mysql function problem, mGetLastRegistered(); - mini-d - 25.11.2009

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.


Re: Mysql function problem, mGetLastRegistered(); - ExoSanty - 25.11.2009

ORDER BY `id ` ?


Re: Mysql function problem, mGetLastRegistered(); - mini-d - 25.11.2009

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


Re: Mysql function problem, mGetLastRegistered(); - GTA967 - 25.11.2009

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


Re: Mysql function problem, mGetLastRegistered(); - SoeH - 25.11.2009

Why you poste here?



Re: Mysql function problem, mGetLastRegistered(); - GTA967 - 25.11.2009

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


Re: Mysql function problem, mGetLastRegistered(); - mini-d - 25.11.2009

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