Raised This Month: $ Target: $400
 0% 

[HELP]starting health with sql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dxteam
Senior Member
Join Date: Dec 2005
Old 12-28-2007 , 17:20   [HELP]starting health with sql
Reply With Quote #1

how to set starting health from database?
look for code:
PHP Code:
#include <amxmodx>
#include <fun>

#define PLUGIN "Start Health"
#define VERSION "0.1"
#define AUTHOR "Allenwr"

new health

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("ResetHUD","hud","b")
    
register_clcmd("fullupdate","update",ADMIN_ALL,"")
    
health register_cvar("sv_starthealth","100")
}

public 
update(id) {
    return 
PLUGIN_HANDLED
}

public 
hud(id) {
    
set_user_health(idget_pcvar_num(health))

dxteam is offline
Send a message via ICQ to dxteam
Wilson [29th ID]
Veteran Member
Join Date: Nov 2005
Location: London
Old 12-28-2007 , 22:46   Re: [HELP]starting health with sql
Reply With Quote #2

Seeeaaarch
__________________

Day of Defeat AMXX Community

FakeMeta Research . Voice Proximity . Advanced Deploy . Technician
Wilson [29th ID] is offline
Send a message via ICQ to Wilson [29th ID] Send a message via AIM to Wilson [29th ID] Send a message via MSN to Wilson [29th ID] Send a message via Yahoo to Wilson [29th ID]
dxteam
Senior Member
Join Date: Dec 2005
Old 01-02-2008 , 17:13   Re: [HELP]starting health with sql
Reply With Quote #3

Help with script please ))
dxteam is offline
Send a message via ICQ to dxteam
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
dxteam
Senior Member
Join Date: Dec 2005
Old 01-05-2008 , 16:58   Re: [HELP]starting health with sql
Reply With Quote #5

when i join to server i die.
Please solve the problem.
dxteam is offline
Send a message via ICQ to dxteam
fxfighter
Veteran Member
Join Date: Feb 2007
Location: Trollhättan
Old 01-05-2008 , 17:05   Re: [HELP]starting health with sql
Reply With Quote #6

when someone joins the server we load thare health frome mysql in to an array.
If we arent able to retrive a value it will be 0 so when we set thare health on spawn they shuld die.
It will be solve by adding a value into your database that i belive is the answer.
Else replace our load event frome connect to client_authorized
And you shuld add a condtion before we set thare health so we wont set hp if its 0.

Last edited by fxfighter; 01-05-2008 at 17:08.
fxfighter is offline
Send a message via MSN to fxfighter
dxteam
Senior Member
Join Date: Dec 2005
Old 01-05-2008 , 17:19   Re: [HELP]starting health with sql
Reply With Quote #7

i don`t speak english good.
Please say what i need to make,that player don`t die
dxteam is offline
Send a message via ICQ to dxteam
Drak
Veteran Member
Join Date: Jul 2005
Old 01-06-2008 , 01:38   Re: [HELP]starting health with sql
Reply With Quote #8

Quote:
Originally Posted by dxteam View Post
i don`t speak english good.
Please say what i need to make,that player don`t die
Learn better... No wait. Learn English.
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Reply



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