Hice una pequeсa funciуn, no sй si sirva, no puedo compilarlo desde esta PC, pero al fin si no sirve te podrнa servir para guiarte.
pawn Код:
ObtenerEntero(tabla[], fila[], comparador[])
{
new
query[2*sizeof(tabla)+sizeof(fila)+sizeof(comparador)+50], temp[sizeof(fila)+1];
format(query, sizeof(query), "SELECT %s FROM %s WHERE %s = '%s'", fila, tabla, fila, comparador);
if(mysql_query(query)){
mysql_fetch_field_row(temp, fila); return ((mysql_num_rows() > 0) ? (strval(temp)) : (0));
}
}
La funcion puedes utilizarla por ejemplo:
pawn Код:
new
nombre[MAX_PLAYER_NAME];
GetPlayerName(playerid, nombre, sizeof(nombre));
ObtenerEntero("users", "nivel", nombre);
pawn Код:
CMD:niveloff(playerid, params[])
{
new
jugador[MAX_PLAYER_NAME];
if(sscanf(params, "s[MAX_PLAYER_NAME]", jugador))
return 1; // el comando no se ejecuto correctamente
new
query[128];
format(query, sizeof(query), "SELECT nombre FROM users WHERE nombre = '%s'", mysql_real_escape_string(jugador));
if(mysql_query(query))
{
if(mysql_num_rows() > 0)
{
new string[128];
format(string, sizeof(string), "El jugador %s es nivel %d", jugador, ObtenerEntero("users", "nivel", jugador));
SendClientMessage(playerid, -1, string);
}
else
{
// El nombre no esta registrado.
}
}
return 1;
}
pero mбs bien fнjate como se compone la funciуn