Mysql help
Hi, i have a plugin that announce on server when a layer made 5 kills in a rounds without Dying. Now i decided that i want to register every ace in a mysql database. Problem is that i'm really noob in mysql... So i tried something, logical i got the point but practical i have no idea how to make it work.. Can someone help me please? Want to register in a database the name of the player and the amount of the aces(5 kills in a round without dying). Here is my sma
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <csx>
#include <hamsandwich>
const MAXPLAYERS = 32;
enum PlayerData
{
Name[ 33 ],
AuthID[ 34 ],
Kills,
Deaths,
Aces
}
new g_Vault;
new g_PlayerData[ MAXPLAYERS + 1 ][ PlayerData ];
new g_pAceKills;
new bool:g_bIsBot[ MAXPLAYERS + 1 ];
//MYSQL CONNECTIONs
new Handle:g_h_Sql
public plugin_init()
{
register_plugin("aces", "0.1", "unknown")
register_clcmd("say /ace", "cmdAce", 0, "- display ace top")
// EVENTS
register_event( "DeathMsg", "EventDeathMsg", "a" );
g_h_Sql = SQL_MakeDbTuple("127.0.0.1", "user13728", "pass", "user13728")
}
public client_authorized( id )
{
if ( !( g_bIsBot[ id ] = !!( is_user_bot( id ) || is_user_hltv( id ) ) ) )
{
new s_Query[128]
get_user_authid( id , g_PlayerData[ id ][ AuthID ] , charsmax( g_PlayerData[][ AuthID ] ) );
get_user_name( id , g_PlayerData[ id ][ Name ] , charsmax( g_PlayerData[][ AuthID ] ) );
format(s_Query, charsmax(s_Query), "SELECT aces FROM aces WHERE name='%s'", g_PlayerData[ id ][ Name ]);
SQL_ThreadQuery(g_h_Sql, "Handle_Query", s_Query);
}
}
public EventDeathMsg( )
{
new iKiller = read_data( 1 );
new iVictim = read_data( 2 );
CheckAce( iVictim );
if( iKiller && iKiller != iVictim && cs_get_user_team( iKiller ) != cs_get_user_team( iVictim ) )
{
if (g_b_Connected_SQL)
{
new Handle:h_Query, s_Name[32],g_Ace[33], s_Error[128]
get_user_name(id, s_Name, charsmax(s_Name))
}
g_iFrags[ iKiller ]++;
}
return PLUGIN_CONTINUE;
}
public CheckAce( id )
{
if( g_iFrags[ id ] >= 5 )
{
g_Ace[id]++;
DidAce( id );
}
g_iFrags[ id ] = 0;
}
public DidAce( id )
{
new iReturn = PLUGIN_CONTINUE;
ExecuteForward( iForward , iReturn , id , g_iFrags[ id ] );
if( iReturn == PLUGIN_HANDLED || iReturn == PLUGIN_HANDLED_MAIN )
{
return PLUGIN_HANDLED;
}
client_print(0, print_chat," %s did an ACE.", g_PlayersName[id]);
return PLUGIN_HANDLED;
}
public plugin_end()
{
SQL_FreeHandle(g_h_Sql_Connect)
SQL_FreeHandle(g_h_Sql)
}
|