21.03.2009, 04:56
K, so i just made my own command to get a field from a users row in the database.
But it crashes my server using it in the command:
It crashes somewhere in the MySQLGetPlayerInt command because it does not print that last line into the command prompt.
Код:
public MySQLGetPlayerInt(playerid,field[]) { new name[28],query[1024],line[1024],fieldval[1024],destination[64]; GetPlayerName(playerid,name,sizeof(name)); format(query,sizeof(query),"SELECT * FROM `users` WHERE username='%s'",name); samp_mysql_query(query); samp_mysql_store_result(); samp_mysql_fetch_row(line); samp_mysql_get_field(field,destination); format(fieldval,sizeof(fieldval),"%% ",destination); new Int = strval(fieldval); printf("Username: %s. Field: %s. Value: %%",name,fieldval,Int); return Int; }
Код:
if(strcmp(cmd,"/adminlevel",true)==0) { format(string,sizeof(string),"%d",MySQLGetPlayerInt(playerid,"adminlevel")); new result; result = strval(string); format(string,sizeof(string),"%%",result); SendClientMessage(playerid,COLOR_LIME,string); return 1; }