AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Mysql help (https://forums.alliedmods.net/showthread.php?t=293566)

Loupu. 02-04-2017 06:11

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
{
    
Name33 ],
    
AuthID34 ],
    
Kills,
    
Deaths,
    
Aces
}

new 
g_Vault;
new 
g_PlayerDataMAXPLAYERS ][ PlayerData ];
new 
g_pAceKills;
new 
bool:g_bIsBotMAXPLAYERS ];

//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_authorizedid )
{
    if ( !( 
g_bIsBotid ] = !!( is_user_botid ) || is_user_hltvid ) ) ) )
    {
        new 
s_Query[128]
        
get_user_authidid g_PlayerDataid ][ AuthID ] , charsmaxg_PlayerData[][ AuthID ] ) );
        
get_user_nameid g_PlayerDataid ][ Name ] , charsmaxg_PlayerData[][ AuthID ] ) );
        
        
format(s_Querycharsmax(s_Query), "SELECT aces FROM aces WHERE name='%s'"g_PlayerDataid ][ Name ]);
        
SQL_ThreadQuery(g_h_Sql"Handle_Query"s_Query);
    }
}

public 
EventDeathMsg( )
{
    new 
iKiller read_data);
    new 
iVictim read_data);
    
    
CheckAceiVictim );
    
    if( 
iKiller && iKiller != iVictim && cs_get_user_teamiKiller ) != cs_get_user_teamiVictim ) )
    {
        if (
g_b_Connected_SQL
        {
        new 
Handle:h_Querys_Name[32],g_Ace[33], s_Error[128]
        
        
get_user_name(ids_Namecharsmax(s_Name))
        }
        
g_iFragsiKiller ]++;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
CheckAceid )
{
    if( 
g_iFragsid ] >= )
    {
        
g_Ace[id]++;
        
DidAceid );
    }
    
    
g_iFragsid ] = 0;
}

public 
DidAceid )
{
    new 
iReturn PLUGIN_CONTINUE;
    
    
ExecuteForwardiForward iReturn id g_iFragsid ] );
    
    if( 
iReturn == PLUGIN_HANDLED || iReturn == PLUGIN_HANDLED_MAIN )
    {
        return 
PLUGIN_HANDLED;
    }
    
    
client_print(0print_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)




All times are GMT -4. The time now is 20:43.

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