Raised This Month: $51 Target: $400
 12% 

skill calc


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
spiider
AlliedModders Donor
Join Date: Jan 2010
Old 03-07-2010 , 13:01   skill calc
Reply With Quote #1

hi, i'm new in amx and i'm try develop a basic skill calc with mysql, but is not working if someone can help.
PHP Code:
/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "pontos"
#define VERSION "1.0"
#define AUTHOR "author"

#define CVAR_CHHOST            "wwwreg_host"
#define CVAR_CHUSER            "wwwreg_user"
#define CVAR_CHPASS            "wwwreg_pass"
#define CVAR_CHDB            "wwwreg_db"
#define TABLE                "users"

//Stats
new skill[33
new 
CDeath[33//Death count
new CKill[33//Kill count
new CHSG[33//HS Giv
new CHST[33//HS Tak
new SpawnCount[33]

//Stats display
new    RankSkill[33//global rank by skill
new RankCSStats[33//global rank by csstats
new    RankCSServer[33//server rank by skill
new RankSkillServer[33//server rank by csstats
new PlayerLastAim[33]

new 
warmup_status
new live_status


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("DeathMsg""hook_death""a")
    
register_clcmd("say .skill""teste");
    
    
register_cvar(CVAR_CHHOST"***")
    
register_cvar(CVAR_CHUSER"****")
    
register_cvar(CVAR_CHPASS"****")
    
register_cvar(CVAR_CHDB"****")


    new 
Sql:sql
    
if (!connect(sql)) {
        
log_amx("Couldn't connect to SQL database at plugin_init! Pausing plugin.")
        
pause("a")
        return
    }
    
    else
        
server_print("[%s] Connected successfully to SQL database."PLUGIN)
    
dbi_close(sql)
    
warmup_status =  get_cvar_pointer "warmup" )
    
live_status get_cvar_pointer "live" )
}


public 
client_authorized(id) {
    if (
is_user_bot(id))
        return 
PLUGIN_CONTINUE
    
new pontos[32]    
    new 
authid[32]
    
get_user_authid(id,authid,31)
    new 
Sql:sql
    
if (!connect(sql))
        return 
false

    
const LONGER 128
    
new query[LONGER 1]

    
format(queryLONGER"SELECT `pontos` FROM users WHERE `steamid` = ^"%s^" LIMIT 1"authid)
    new 
Result:result dbi_query(sqlquery)
    

    
//Loop through the result set   
    
while (result && dbi_nextrow(result)>0) {
        new 
qry[32]
//Get the column/field called "keyname" from the result set
        
dbi_result(result"pontos"qry32)
       
set_user_info(id,"pontos",qry)
       
pontos qry;
       
    }
    
skill[id] = pontos[id];
    
dbi_close(sql)

    return 
PLUGIN_CONTINUE 
}

public 
hook_death ()
{
  
    if(
get_pcvar_num(live_status) == && get_pcvar_num(warmup_status) == || get_pcvar_num(live_status) == && get_pcvar_num(warmup_status) == 0)
    {
    new 
attacker read_data(1);
    new 
victim read_data(2);
    new 
attackerteam get_user_team(attacker);
    new 
victimteam get_user_team(victim);
    
    
    if((
attacker == victim) || (!attacker))
    {
        
skill[victim] -= 10;     
    }
    else 
    {
        
            
skill[attacker] += 10;   
            
skill[victim] -= 8;  
    }}
}
public 
client_disconnect(id
{
    new 
Arg[32]
    new 
steamid[32]
    
read_argv(1Arg32)

    if (
skill[id] < 100)
    {
        
skill[id] = 100;
    }
    
    new 
Sql:sql
    
if (!connect(sql))
        return 
false
    
const LONGER 128
    
new query[LONGER 1]
    
    
format(qpntLONGER"UPDATE `users` SET `pontos`=%i WHERE `steamid`=^"%s^""skill[id], steamid)
    
dbi_query(sqlqpnt)
    
dbi_close(sql)    
}

bool:connect(&Sql:sql) {
    const 
LEN 128
    
new host[LEN], user[LEN], pass[LEN], db[LEN], error_msg[LEN]

    
get_cvar_string(CVAR_CHHOSThostLEN 2)
    
get_cvar_string(CVAR_CHUSERuserLEN 2)
    
get_cvar_string(CVAR_CHPASSpassLEN 2)
    
get_cvar_string(CVAR_CHDBdbLEN 2)

    
sql dbi_connect(hostuserpassdberror_msgLEN 2)

    if (!
sql) {
        
log_amx("ERROR - Can't connect to SQL db: %s"error_msg)
        return 
false
    
}

    return 
true

warmup and live is for know if game is live and calc skill.

Last edited by spiider; 03-07-2010 at 13:17.
spiider is offline
Old 03-09-2010, 17:43
spiider
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
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 03:44.


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