HELP.. Data Mysql to var function
#1

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

Код:
forward MysqlCargarDato(playerid, var[]);
I have this enum for the vars

Код:
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];
Here is OnPlayerSpawn foor SendClientMessage

Код:
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;
}
And now my mysql function..

Код:
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();
}
I supose u will help me, thx a lot and bleess!!
Reply


Messages In This Thread
HELP.. Data Mysql to var function - by Zafire1410 - 04.08.2010, 23:56
Re: HELP.. Data Mysql to var function - by Zafire1410 - 05.08.2010, 01:35
Re: HELP.. Data Mysql to var function - by Johndaonee - 05.08.2010, 05:35
Re: HELP.. Data Mysql to var function - by Zafire1410 - 05.08.2010, 14:17
Re: HELP.. Data Mysql to var function - by Kar - 05.08.2010, 14:18
Re: HELP.. Data Mysql to var function - by Zafire1410 - 05.08.2010, 14:28

Forum Jump:


Users browsing this thread: 2 Guest(s)