25.11.2009, 00:07
Hi, I have been trying to make a function which searches my mysql database looking for the last registered player,
So far I have,
@ onplayerconnect I have,
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.
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.