AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP]starting health with sql (https://forums.alliedmods.net/showthread.php?t=64971)

dxteam 12-28-2007 17:20

[HELP]starting health with sql
 
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))



Wilson [29th ID] 12-28-2007 22:46

Re: [HELP]starting health with sql
 
Seeeaaarch

dxteam 01-02-2008 17:13

Re: [HELP]starting health with sql
 
Help with script please ))

fxfighter 01-03-2008 06:22

Re: [HELP]starting health with sql
 
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")
 }
}


dxteam 01-05-2008 16:58

Re: [HELP]starting health with sql
 
when i join to server i die.
Please solve the problem.

fxfighter 01-05-2008 17:05

Re: [HELP]starting health with sql
 
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.

dxteam 01-05-2008 17:19

Re: [HELP]starting health with sql
 
i don`t speak english good.
Please say what i need to make,that player don`t die

Drak 01-06-2008 01:38

Re: [HELP]starting health with sql
 
Quote:

Originally Posted by dxteam (Post 570595)
i don`t speak english good.
Please say what i need to make,that player don`t die

Learn better... No wait. Learn English.


All times are GMT -4. The time now is 11:10.

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