Raised This Month: $ Target: $400
 0% 

[HELP]starting health with sql


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 01-03-2008 , 06:22   Re: [HELP]starting health with sql
Reply With Quote #4

i rec you get the cvar values frome amx_mysql cvars or something instead what i did.
//make new ones..
Code:
 
#include <amxmodx> 
#include <fun> 
#include <dbi>
 
new Sql:dbc
new Result:result
 
new health[33]
 
public plugin_init() 
{ 
 register_plugin("Start Health" , "0.1" , "Allenwr" ) 
 register_event("ResetHUD","hud","b") 
 register_clcmd("fullupdate","update",ADMIN_ALL,"") 
 //mysql
 sql_init()
 register_cvar("nick_mysql_host","127.0.0.1",FCVAR_PROTECTED)
 register_cvar("nick_mysql_user","root",FCVAR_PROTECTED)
 register_cvar("nick_mysql_pass","",FCVAR_PROTECTED)
 register_cvar("nick_mysql_db","users",FCVAR_PROTECTED)
} 
public update(id) 
{ 
 return PLUGIN_HANDLED 
} 
public hud(id) 
{ 
 set_user_health(id, health[id]) 
}  
public client_connect(id)
{
 new query[256],HP[32],authid[32]
 get_user_authid(id,authid,31)
 format(query,255,"SELECT Health FROM users WHERE SteamID='%s'",authid)
 result = dbi_query(dbc,query)
 if(dbi_nextrow(result) > 0)
 {
  dbi_field(result,1,HP,31)
  health[id] = str_to_num(HP)
 } 
 else{
 
  dbi_free_result(result)
 }
}
public sql_init()
{
 new host[64], username[33], password[32], dbname[32], error[32]
 get_cvar_string("nick_mysql_host",host,64) 
 get_cvar_string("nick_mysql_user",username,32) 
 get_cvar_string("nick_mysql_pass",password,32) 
 get_cvar_string("nick_mysql_db",dbname,32)
 dbc = dbi_connect(host,username,password,dbname,error,32)
 if (dbc == SQL_FAILED)
 {
  server_print("[Plugin] Could Not Connect To SQL Database^n")
 
 }
 else
 {
  server_print("[Plugin] Connected To SQL, Have A Nice Day!^n")
 }
}

Last edited by fxfighter; 01-03-2008 at 06:25.
fxfighter is offline
Send a message via MSN to fxfighter
 



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 11:10.


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