AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [help plz] tag mismatch (https://forums.alliedmods.net/showthread.php?t=85959)

aTei 02-18-2009 11:50

[help plz] tag mismatch
 
DB:
1st colum - steamid
2nd - hp

Plugin must:
if player steamid exist in DB he get hp

Sma
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <dbi>
#include <fun>

new Sql:g_SqlConnection
new g_Error[512]



public 
plugin_init() {
    
register_plugin("Donate HP SQL","0.1","aTei")
    
    new 
Host[64],User[64],Pass[64],Db[64]
    
get_cvar_string("amx_sql_host",Host,63)
    
get_cvar_string("amx_sql_user",User,63)
    
get_cvar_string("amx_sql_pass",Pass,63)
    
get_cvar_string("amx_sql_db",Db,63)
   
    
g_SqlConnection dbi_connect(Host,User,Pass,Db,g_Error,511)
    if(
g_SqlConnection SQL_OK)
       
set_fail_state(g_Error)

    if (!
g_SqlConnection)
    {
       
console_print(0,"[Donate HP] Can't connect to DB!")
    }
       
    
dbi_query(g_SqlConnection,"CREATE TABLE IF NOT EXISTS donate_hp (steamid text,hp INT(11))")
}


public 
client_putinserver (id){
    new 
steamid[38]
    
get_user_authid(idsteamid37)
    new 
result dbi_query(g_SqlConnection"SELECT * FROM donate_hp WHERE steamid = '%s'"steamid);
    if (
result){
       new 
db_hp dbi_field(result,2)
       
set_user_health(iddb_hp)    
    }
    return 
PLUGIN_CONTINUE


Errors
Compiler
PHP Code:

//// donate_hp.sma
// F:\servers\files\amxmodx 1.8.1\addons\amx
arning 213tag mismatch
// F:\servers\files\amxmodx 1.8.1\addons\amx
arning 213tag mismatch
// Header size:            364 bytes
// Code size:              980 bytes
// Data size:             2908 bytes
// Stack/heap size:      16384 bytes; estima
)
// Total requirements:   20636 bytes
//
// 2 Warnings.
// Done.
//
// Compilation Time: 0,58 sec 

Server
PHP Code:

L 02/18/2009 19:12:36: [AMXXPlugin ("donate_hp.amxx"is setting itself as f
ailed
.
L 02/18/2009 19:12:36: [AMXXPlugin saysAccess denied for user 'root'@'loca
lhost' 
(using passwordNO)
L 02/18/2009 19:12:36: [AMXXRun time error 1 (plugin "donate_hp.amxx") - for
ced exit 

Help plz :cry:

YamiKaitou 02-18-2009 12:25

Re: [help plz] tag mismatch
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <dbi>
#include <fun>

new Sql:g_SqlConnection
new g_Error[512]



public 
plugin_init() {
    
register_plugin("Donate HP SQL","0.1","aTei")
    
    new 
Host[64],User[64],Pass[64],Db[64]
    
get_cvar_string("amx_sql_host",Host,63)
    
get_cvar_string("amx_sql_user",User,63)
    
get_cvar_string("amx_sql_pass",Pass,63)
    
get_cvar_string("amx_sql_db",Db,63)
   
    
g_SqlConnection dbi_connect(Host,User,Pass,Db,g_Error,511)
    if(
g_SqlConnection SQL_OK)
       
set_fail_state(g_Error)

    if (!
g_SqlConnection)
    {
       
console_print(0,"[Donate HP] Can't connect to DB!")
    }
       
    
dbi_query(g_SqlConnection,"CREATE TABLE IF NOT EXISTS donate_hp (steamid text,hp INT(11))")
}


public 
client_putinserver (id){
    new 
steamid[38]
    
get_user_authid(idsteamid37)
    new 
Result:result dbi_query(g_SqlConnection"SELECT * FROM donate_hp WHERE steamid = '%s'"steamid);
    if (
result != RESULT_FAILED){
       new 
db_hp dbi_field(result,2)
       
set_user_health(iddb_hp)    
    }
    return 
PLUGIN_CONTINUE


Compiles with no warnings now

The run-time error you are getting is because your connection details are incorrect. I would also recommend using SQLx and PCVARs

Dr.G 02-18-2009 12:45

Re: [help plz] tag mismatch
 
hehe yea sqlx is better it would be something like this i think NOT TESTED

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#include <fun>
new Host[64],User[64],Pass[64],Db[64]
new 
error[256], errorcode
new Handle:sql_makedbtuple
new Handle:sql_connect
public plugin_init() 
{
 
register_plugin("Donate HP SQL","0.1","aTei")
 
 
 
get_cvar_string("amx_sql_host",Host,63)
 
get_cvar_string("amx_sql_user",User,63)
 
get_cvar_string("amx_sql_pass",Pass,63)
 
get_cvar_string("amx_sql_db",Db,63)
 
 
 
sql_makedbtuple SQL_MakeDbTuple(Host,User,Pass,Db)
 
sql_connect SQL_Connect(sql_makedbtupleerrorcodeerror255)
 
 
 if (!
sql_connect)
 {
  
log_amx("[Donate HP]Error (%d): %s"errorcodeerror)
  
set_fail_state("[Donate HP] Can't connect to DB!")
  
console_print(0,"[Donate HP]Error (%d): %s"errorcodeerror)
  return 
PLUGIN_HANDLED
 
}
 
 new 
Handle:query SQL_PrepareQuery(sql_connect,"CREATE TABLE IF NOT EXISTS donate_hp (steamid text,hp INT(11))")
 
SQL_Execute(query)
 
 
SQL_FreeHandle(query)
 return 
PLUGIN_HANDLED
}
 
public 
client_putinserver (id)
{
 new 
steamid[38]
 new 
result
 get_user_authid
(idsteamid37)
 
 new 
Handle:query SQL_PrepareQuery(sql_connect"SELECT * FROM donate_hp WHERE steamid = '%s'"steamid)
 
SQL_Execute(query)
 
 if (
SQL_MoreResults(query))
 
 
result SQL_ReadResult(query2)
 
 
SQL_FreeHandle(query)
 
 if(
result 0)
 {
  new 
db_hp SQL_ReadResult(query2)
  
set_user_health(iddb_hp)    
 }
 return 
PLUGIN_CONTINUE



aTei 02-18-2009 16:16

Re: [help plz] tag mismatch
 
YamiKaitou working - ok
Dr.G - also working good
really thx


All times are GMT -4. The time now is 17:00.

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