Raised This Month: $ Target: $400
 0% 

[MySQL] - Stats plugin doesn't work... :(


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
matthew16
Junior Member
Join Date: Dec 2013
Old 01-07-2014 , 13:01   [MySQL] - Stats plugin doesn't work... :(
Reply With Quote #1

Why don't work this?
it was like when in game press 'TAB' and show a lot of info
(I'm newbie in pawn scripting)

PHP Code:
#include <amxmodx>
#include <sqlx>
#include <geoip>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN "N/A"
#define VERSION "1.0"
#define AUTHOR "N/A"

#define CONNECT "connect.."

/*
CREATE TABLE IF NOT EXISTS `score` (
  `id` int(11) NOT NULL auto_increment,
  `team` varchar(255) default NULL,
  `playerName` varchar(255) default NULL,
  `score` int(11) default NULL,
  `deaths` int(11) default NULL,
  `country` int(11) default NULL,
  `status` int(11) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

*/

new Handle:g_SqlTuple
// ------------------

new GlobalID[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event"DeathMsg""event""a" );
    
RegisterHamHam_Spawn"player""fwdPlayerSpawn"); 
    
set_task(5.0"CheckStatus"___"b")
}
public 
plugin_cfg()
{
    
g_SqlTuple SQL_MakeDbTuple("host""user""pass""database")
}
public 
client_disconnect(id){
    
//MySQL
    
new ErrorCode;
    new 
Error[512]
    new 
Handle:SqlConnection SQL_Connect(g_SqlTupleErrorCodeError511)
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"DELETE FROM score WHERE id='%d'"GlobalID[id])
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(QueryError511)
        
set_fail_state(Error)
    }
    
SQL_FreeHandle(Query)
    
SQL_FreeHandle(SqlConnection)
    
//MySQL
    
return PLUGIN_CONTINUE
}
public 
client_connect(id)
{
    
GlobalID[id] = random(1500) * random(1500
    
    new 
ErrorCode;
    new 
Error[512]
    new 
Handle:SqlConnection SQL_Connect(g_SqlTupleErrorCodeError511)
    
    new 
ip[18]
    
get_user_ip(id,ip,17,1)
    
    new 
name[64]
    new 
country[46]
    
    
get_user_name idname63);
    
geoip_country ipcountry45 );
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"INSERT INTO `score` (`playerName`, `team`, `score`, `deaths`, `county`, `status`) VALUES (^"%s^", ^"-^", ^"-^", ^"-^", ^"%s^", ^"%s^");"namecountryCONNECT)
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(QueryError511)
        
set_fail_state(Error)
    }
    
SQL_FreeHandle(Query)
    
SQL_FreeHandle(SqlConnection)    
}    

public 
event()
{
    new 
Killer read_data);
    new 
Victim read_data)
    
    new 
Kills[33], Deaths[33];
    
    
Kills[Killer]++
    
Deaths[Victim]++
    
    
//MySQL
    
new ErrorCode;
    new 
Error[512]
    new 
Handle:SqlConnection SQL_Connect(g_SqlTupleErrorCodeError511)
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"UPDATE score SET score='%d', deaths='%d' WHERE id='%d'"Kills[Killer], Deaths[Victim], GlobalID[Killer])
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(QueryError511)
        
set_fail_state(Error)
    }
    
SQL_FreeHandle(Query)
    
SQL_FreeHandle(SqlConnection)
    
//MySQL
    
return PLUGIN_CONTINUE
}
public 
fwdPlayerSpawn(id)  {    
    if(
cs_get_user_team(id) == CS_TEAM_CT)
    {
        
CT(id);
    }
    else if(
cs_get_user_team(id) == CS_TEAM_T)
    {
        
TT(id);
    } else {
        
SPEC(id);
    }
    return 
PLUGIN_CONTINUE 
}
public 
CT(id){
    
//MySQL
    
new ErrorCode;
    new 
Error[512]
    new 
Handle:SqlConnection SQL_Connect(g_SqlTupleErrorCodeError511)
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"UPDATE score SET team='ct' WHERE id='%d'"GlobalID[id])
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(QueryError511)
        
set_fail_state(Error)
    }
    
SQL_FreeHandle(Query)
    
SQL_FreeHandle(SqlConnection)
    
//MySQL
    
return PLUGIN_CONTINUE
}
public 
TT(id){
    
//MySQL
    
new ErrorCode;
    new 
Error[512]
    new 
Handle:SqlConnection SQL_Connect(g_SqlTupleErrorCodeError511)
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"UPDATE score SET team='tt' WHERE id='%d'"GlobalID[id])
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(QueryError511)
        
set_fail_state(Error)
    }
    
SQL_FreeHandle(Query)
    
SQL_FreeHandle(SqlConnection)
    
//MySQL
    
return PLUGIN_CONTINUE
}
public 
SPEC(id){
    
//MySQL
    
new ErrorCode;
    new 
Error[512]
    new 
Handle:SqlConnection SQL_Connect(g_SqlTupleErrorCodeError511)
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"UPDATE score SET team='spec' WHERE id='%d'"GlobalID[id])
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(QueryError511)
        
set_fail_state(Error)
    }
    
SQL_FreeHandle(Query)
    
SQL_FreeHandle(SqlConnection)
    
//MySQL
    
return PLUGIN_CONTINUE
}
public 
CheckStatus(id){
    if(
is_user_alive(id))
    {
        
ALIVE(id);
    } else {
        
DEATH(id);
    }
}
public 
ALIVE(id){
    
//MySQL
    
new ErrorCode;
    new 
Error[512]
    new 
Handle:SqlConnection SQL_Connect(g_SqlTupleErrorCodeError511)
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"UPDATE score SET status='1' WHERE id='%d'"GlobalID[id])
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(QueryError511)
        
set_fail_state(Error)
    }
    
SQL_FreeHandle(Query)
    
SQL_FreeHandle(SqlConnection)
    
//MySQL
    
return PLUGIN_CONTINUE
}
public 
DEATH(id){
    
//MySQL
    
new ErrorCode;
    new 
Error[512]
    new 
Handle:SqlConnection SQL_Connect(g_SqlTupleErrorCodeError511)
    
    new 
Handle:Query SQL_PrepareQuery(SqlConnection"UPDATE score SET status='0' WHERE id='%d'"GlobalID[id])
    if(!
SQL_Execute(Query))
    {
        
SQL_QueryError(QueryError511)
        
set_fail_state(Error)
    }
    
SQL_FreeHandle(Query)
    
SQL_FreeHandle(SqlConnection)
    
//MySQL
    
return PLUGIN_CONTINUE

matthew16 is offline
 



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


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