Problem with SQL...
This error is killing me. I have tried to make query in ~5 diffrent ways, but its always same (invalid handle).
Code:
L 10/14/2007 - 21:07:18: [MySQL] Invalid DBI result handle 2
L 10/14/2007 - 21:07:18: [AMXX] Displaying debug trace (plugin "csn-sql.amxx")
L 10/14/2007 - 21:07:18: [AMXX] Run time error 10: native error (native "dbi_nextrow")
L 10/14/2007 - 21:07:18: [AMXX] [0] csn-sql.sma::client_putinserver (line 112)
Code listing:
PHP Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <dbi>
#define MAX_PLAYERS 32
new bool:g_restart_attempt[MAX_PLAYERS + 1] new Sql:dbc new plr_points[32]
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_event("ResetHUD", "event_hud_reset", "be") register_clcmd("fullupdate", "clcmd_fullupdate") register_event("TextMsg", "event_restart_attempt", "a", "2=#Game_will_restart_in") sql_init() }
public sql_init() { new host[64], username[32], password[32], dbname[32], error[32] get_cvar_string("amx_sql_host", host, 64) get_cvar_string("amx_sql_user", username, 32) get_cvar_string("amx_sql_pass", password, 32) get_cvar_string("amx_sql_db", dbname, 32) dbc = dbi_connect(host, username, password, dbname, error, 32) if (dbc < SQL_OK) client_print(1, print_chat, "[AMXX] SQL Connection Failed ") }
public clcmd_fullupdate() { return PLUGIN_HANDLED_MAIN } public event_restart_attempt() { new players[32], num get_players(players, num, "a") for (new i; i < num; ++i) g_restart_attempt[players[i]] = true } public event_hud_reset(id) { if (g_restart_attempt[id]) { g_restart_attempt[id] = false return } event_player_spawn(id) }
public client_putinserver(id) { new steamid[35] get_user_authid(id, steamid, 34) new sql[255] format(sql,254,"SELECT * FROM amx_csn_users WHERE steam_id = '%s'", steamid) new Result:res = dbi_query(dbc, sql) if(!res) { client_print(1, print_chat, "[AMXX] Blad bazy danych") } while(dbi_nextrow(Result)) { plr_points[id] = dbi_result(Result,"points") } client_print(1, print_chat, "[AMXX] Na serwer wlazl ktoz ze steamid %s, ma id (%i) oraz %s2 bonusowych punktow", steamid, id, plr_points[id]) } // this function is called on player spawn public event_player_spawn(id) { new BONUSKASA = id*100 cs_set_user_money(id, cs_get_user_money(id) + BONUSKASA) client_print(1, print_chat, "[AMXX] SPAWN: NOWA RUNDA | Jestes zajebisty i dostajesz $%d", BONUSKASA) }
|