04.08.2010, 23:56
Hi, i am scripting a roleplay gamemode.. i create a function to take data from mysql and store it in a variable but that doesnt works for me.. it supose to SendClientMessage "Your Sex: 2" but it said "Your Sex: 0".. here is my code..
Forward for the function
I have this enum for the vars
Here is OnPlayerSpawn foor SendClientMessage
And now my mysql function..
I supose u will help me, thx a lot and bleess!!
Forward for the function
Код:
forward MysqlCargarDato(playerid, var[]);
Код:
enum playeri { id, nombre[30], pass[30], cedula, edad, sexo, nivel, dinero, trabajo, lic1, lic2, lic3, lic4, lic5, admin, phone, banco, skin, px, py, pz, vida, armor, spawned } new pinfo[MAX_PLAYERS][playeri];
Код:
public OnPlayerSpawn(playerid) { new texto[128]; SetPlayerInterior(playerid,0); MysqlCargarDato(playerid, "sexo"); format(texto, sizeof(texto), "Your Sex: %i", pinfo[playerid][sexo]); SendClientMessage(playerid, COLOR_LIGHTBLUE, texto); return 1; }
Код:
public MysqlCargarDato(playerid, var[]) { new variable[128]; new query[128]; new pnombre[MAX_PLAYER_NAME]; GetPlayerName(playerid, pnombre, sizeof(pnombre)); format(query, sizeof(query), "SELECT %s FROM `jugadores` WHERE nombre='%s'", var, pnombre); format(variable, sizeof(variable), "pinfo[playerid][%s]", var); mysql_query(query); mysql_store_result(); mysql_fetch_row(variable); mysql_free_result(); }