Raised This Month: $ Target: $400
 0% 

Problem with SQL...


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
AceDude
Junior Member
Join Date: Jul 2006
Location: Wroclaw, Poland
Old 10-14-2007 , 15:15   Problem with SQL...
Reply With Quote #1

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(PLUGINVERSIONAUTHOR)
    
    
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"host64)
    
get_cvar_string("amx_sql_user"username32)
    
get_cvar_string("amx_sql_pass"password32)
    
get_cvar_string("amx_sql_db"dbname32)
    
    
dbc dbi_connect(hostusernamepassworddbnameerror32)
    
    if (
dbc SQL_OK)
        
client_print(1print_chat"[AMXX] SQL Connection Failed ")
}

public 
clcmd_fullupdate() {
    return 
PLUGIN_HANDLED_MAIN
}
 
public 
event_restart_attempt() {
    new 
players[32], num
    get_players
(playersnum"a")
    for (new 
inum; ++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(idsteamid34)
   
    new 
sql[255]
    
format(sql,254,"SELECT * FROM amx_csn_users WHERE steam_id = '%s'"steamid)
    
    new 
Result:res dbi_query(dbcsql)
     
    if(!
res)
    {
        
client_print(1print_chat"[AMXX] Blad bazy danych")
    }
    
    while(
dbi_nextrow(Result))
            {
            
plr_points[id] = dbi_result(Result,"points")
        }
    
    
client_print(1print_chat"[AMXX] Na serwer wlazl ktoz ze steamid %s, ma id (%i) oraz %s2 bonusowych punktow"steamididplr_points[id])
}
 
// this function is called on player spawn
public event_player_spawn(id) {
    new 
BONUSKASA id*100
    cs_set_user_money
(idcs_get_user_money(id) + BONUSKASA)
    
client_print(1print_chat"[AMXX] SPAWN: NOWA RUNDA | Jestes zajebisty i dostajesz $%d"BONUSKASA)

__________________
If you need English->Polish translation, PM me.
AceDude is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode