Plugin MYSQL inserare date.

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
User avatar
The Kalu
eXtream Mod
eXtream Mod
Posts: 12364
Joined: 09 Oct 2010, 11:39
Detinator Steam: Da
Reputatie: Fost membru Club eXtreamCS (6 luni)
Nume anterior: Terra
Has thanked: 199 times
Been thanked: 339 times

26 Mar 2020, 14:25

Plugin Cerut: Statistici
Descriere (adica ce face el mai exact):
Serverul impune conditii strict HLDS/REHLDS?: HLDS
Ai cautat pluginul?(daca da, precizeaza cum): Nu
Necesita mod special?: Nu

Am nevoie de un plugin care sa insereze intr-un tabel urmatoarele date:

- steamid
- steam nickname
- frags
- deaths
- money
- last seen online (doar la deconectare sa ii insereze timpul)

SQL

Code: Select all

INSERT INTO player (steamid, nickname, frags, deaths, money, last_seen_online) VALUES ();
Doar o data inserarea, daca exista deja sa nu il mai adauge.

La fraguri, morti si bani sa memoreze cati face pe runda si la sfarsit de runda sa ii adauge in campul fraguri, morti si bani, adica sa ii adune deci va rula alta interogare in db separat doar pentru bani.
Aici sa bage la fiecare sfarsit de runda!

Code: Select all

UPDATE player SET frags =, deaths = , money = , last_seen_online =  WHERE steamdid;
Inca o chestie, daca are gag/mute sa nu ii adauge nimic timp de 1 zi ca si cum ar avea un fel de cooldown.

Multumesc!
Luckarena.com
User avatar
EnTeR_
Membru, skill +1
Membru, skill +1
Posts: 454
Joined: 13 Sep 2014, 15:36
Detinator Steam: Da
Fond eXtream: 0
Been thanked: 3 times

26 Mar 2020, 18:19

Banuiesc ca vrei sa faci ceva pe steam only, altfel nu o sa-ti mearga cum trebuie salvarea pe steamid. Anyway, testeaza asta si spune-mi daca sunt probleme.
| Afiseaza codul
#include <   amxmodx   >
#include <   cstrike   >
#include <    sqlx     >

#pragma tabsize 0;

new SQL_TABLE [ ] = "users_stats";

new iFrags [33], iDeaths [33], iMoney [33], iLastConnected [33] [32], PlayerAuthID [33] [32], PlayerName [33] [32],

Handle: iSqlTuple, SQLHost [32], SQLUser [32], SQLPassword [32], SQLDatabase [32], cSqlHost, cSqlUser,

cSqlPassword, cSqlDatabase, MaxPlayers;

public plugin_init (  )
{
    register_event ( "DeathMsg", "EventDeathMsg", "a" );
    
    register_logevent ( "leRoundEnd", 2, "1=Round_End" );

    cSqlHost = register_cvar ( "sql_host", "host" );
    
    cSqlUser = register_cvar ( "sql_user", "user" );
    
    cSqlPassword = register_cvar ( "sql_password", "pw" );
    
    cSqlDatabase = register_cvar ( "sql_database", "db" );

    MaxPlayers = get_maxplayers (  );
}

public plugin_cfg (  ) 
{
        get_pcvar_string ( cSqlHost, SQLHost, charsmax ( SQLHost ) );
    
        get_pcvar_string ( cSqlUser, SQLUser, charsmax ( SQLUser ) );
    
        get_pcvar_string ( cSqlPassword, SQLPassword, charsmax ( SQLPassword ) );
    
        get_pcvar_string ( cSqlDatabase, SQLDatabase, charsmax ( SQLDatabase ) );

        iSqlTuple = SQL_MakeDbTuple ( SQLHost, SQLUser, SQLPassword, SQLDatabase );
    
        static Query [10048], Len;
        
        Len += formatex ( Query [Len], charsmax ( Query ), "CREATE TABLE IF NOT EXISTS `%s`", SQL_TABLE );
    
        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "(`steamid` varchar(32) NOT NULL, " );
    
        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`nickname` varchar(32) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`frags` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`deaths` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`money` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`last_seen_online` varchar(32) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY)" );
    
        SQL_ThreadQuery ( iSqlTuple, "CreateTableThread", Query );
}

public CreateTableThread ( FailState, Handle:Query, Error [ ], Errcode, Data [ ], DataSize, Float:Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED )
    {
        set_fail_state ( "[SQL] Query Error" );
    }
    
    if ( Errcode )
    {
        log_amx ( "[SQL] Error: %s", Error );
    }
}

public LoadData ( id ) 
{
    static Query [10048], Data [1];
    
    Data [0] = id;
    
    formatex ( Query, charsmax ( Query ), "SELECT * FROM `%s` WHERE steamid = ^"%s^";", SQL_TABLE, PlayerAuthID [id] );
    
    SQL_ThreadQuery ( iSqlTuple, "QuerySelectData", Query, Data, 1 );
}

public QuerySelectData ( FailState, Handle: Query, Error [ ], Errcode, Data [ ], DataSize, Float: Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED )  
    {
        log_amx ( "[SQL] %s", Error );
        
        return;
    }
    else 
    {
        new id = Data [0];
        
        if ( SQL_NumRows ( Query ) < 1 ) 
        {
            new Query [256];
 
            formatex ( Query, charsmax ( Query ), "INSERT INTO `%s` (`steamid`,`nickname`,`frags`,`deaths`,`money`,`last_seen_online`) VALUES (^"%s^",^"%s^",^"0^",^"0^",^"0^",^"N/A^");", SQL_TABLE, PlayerAuthID [id], PlayerName [id] );

            SQL_ThreadQuery ( iSqlTuple, "QuerySetData", Query );

        }
        else
        {
            iFrags [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "frags" ) );

            iDeaths [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "deaths" ) );

            iMoney [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "money" ) );

        }
    }
}

public SaveData ( id )
{
    new Query [256], sQuery [3000];
    
    formatex ( Query, charsmax ( Query ), "UPDATE `%s` SET ", SQL_TABLE );
    
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "nickname = ^"%s^", ", PlayerName [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "frags = ^"%i^", ", iFrags [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "deaths = ^"%i^", ", iDeaths [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "money = ^"%i^", ", iMoney [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "last_seen_online = ^"%s^" WHERE steamid = ^"%s^";", iLastConnected [id], PlayerAuthID [id] );
    
        add ( sQuery, charsmax ( sQuery ), Query );
        
    SQL_ThreadQuery ( iSqlTuple, "QuerySetData", sQuery );
}


public QuerySetData ( FailState, Handle: Query, Error [ ], Errcode, Data [ ], DataSize, Float:Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED ) 
    {
        log_amx ( "[SQL] %s", Error );
        
        return;
    }
}

public client_putinserver ( id )
{
    get_user_name ( id, PlayerName [id], charsmax ( PlayerName [ ] ) );

    get_user_authid ( id, PlayerAuthID [id], charsmax ( PlayerAuthID [ ] ) );

    iFrags [id] = 0;

    iDeaths [id] = 0;

    iMoney [id] = 0;

    iLastConnected [id] = "N/A";
    
    LoadData ( id );
}


public client_disconnect ( id )
{
    iMoney [id] += cs_get_user_money ( id );

    new iTime [32];

    get_time ( "%m/%d/%Y - %H:%M:%S", iTime, charsmax ( iTime ) )
  
    copy ( iLastConnected [id], charsmax ( iLastConnected [ ] ), iTime )

    SaveData ( id );
}

public EventDeathMsg (  )
{
    new Killer = read_data ( 1 );
    
    new Victim = read_data ( 2 );
    
    if ( !is_user_alive ( Killer ) || Killer == Victim || get_user_team ( Killer ) == get_user_team ( Victim ) ) 

        return

    iFrags [Killer] ++;

    iDeaths [Victim] ++;
}

public leRoundEnd (  )
{
     for ( new i = 1; i <= MaxPlayers; i ++ )
    {
        if ( is_user_connected ( i ) )
        {
            iMoney  += cs_get_user_money ( i );

            SaveData ( i );
        }
    }
}

public plugin_end (  ) SQL_FreeHandle ( iSqlTuple );
Discord: EyeKon#3230
User avatar
The Kalu
eXtream Mod
eXtream Mod
Posts: 12364
Joined: 09 Oct 2010, 11:39
Detinator Steam: Da
Reputatie: Fost membru Club eXtreamCS (6 luni)
Nume anterior: Terra
Has thanked: 199 times
Been thanked: 339 times

26 Mar 2020, 19:47

EnTeR_ wrote:
26 Mar 2020, 18:19
Banuiesc ca vrei sa faci ceva pe steam only, altfel nu o sa-ti mearga cum trebuie salvarea pe steamid. Anyway, testeaza asta si spune-mi daca sunt probleme.
| Afiseaza codul
#include <   amxmodx   >
#include <   cstrike   >
#include <    sqlx     >

#pragma tabsize 0;

new SQL_TABLE [ ] = "users_stats";

new iFrags [33], iDeaths [33], iMoney [33], iLastConnected [33] [32], PlayerAuthID [33] [32], PlayerName [33] [32],

Handle: iSqlTuple, SQLHost [32], SQLUser [32], SQLPassword [32], SQLDatabase [32], cSqlHost, cSqlUser,

cSqlPassword, cSqlDatabase, MaxPlayers;

public plugin_init (  )
{
    register_event ( "DeathMsg", "EventDeathMsg", "a" );
    
    register_logevent ( "leRoundEnd", 2, "1=Round_End" );

    cSqlHost = register_cvar ( "sql_host", "host" );
    
    cSqlUser = register_cvar ( "sql_user", "user" );
    
    cSqlPassword = register_cvar ( "sql_password", "pw" );
    
    cSqlDatabase = register_cvar ( "sql_database", "db" );

    MaxPlayers = get_maxplayers (  );
}

public plugin_cfg (  ) 
{
        get_pcvar_string ( cSqlHost, SQLHost, charsmax ( SQLHost ) );
    
        get_pcvar_string ( cSqlUser, SQLUser, charsmax ( SQLUser ) );
    
        get_pcvar_string ( cSqlPassword, SQLPassword, charsmax ( SQLPassword ) );
    
        get_pcvar_string ( cSqlDatabase, SQLDatabase, charsmax ( SQLDatabase ) );

        iSqlTuple = SQL_MakeDbTuple ( SQLHost, SQLUser, SQLPassword, SQLDatabase );
    
        static Query [10048], Len;
        
        Len += formatex ( Query [Len], charsmax ( Query ), "CREATE TABLE IF NOT EXISTS `%s`", SQL_TABLE );
    
        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "(`steamid` varchar(32) NOT NULL, " );
    
        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`nickname` varchar(32) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`frags` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`deaths` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`money` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`last_seen_online` varchar(32) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY)" );
    
        SQL_ThreadQuery ( iSqlTuple, "CreateTableThread", Query );
}

public CreateTableThread ( FailState, Handle:Query, Error [ ], Errcode, Data [ ], DataSize, Float:Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED )
    {
        set_fail_state ( "[SQL] Query Error" );
    }
    
    if ( Errcode )
    {
        log_amx ( "[SQL] Error: %s", Error );
    }
}

public LoadData ( id ) 
{
    static Query [10048], Data [1];
    
    Data [0] = id;
    
    formatex ( Query, charsmax ( Query ), "SELECT * FROM `%s` WHERE steamid = ^"%s^";", SQL_TABLE, PlayerAuthID [id] );
    
    SQL_ThreadQuery ( iSqlTuple, "QuerySelectData", Query, Data, 1 );
}

public QuerySelectData ( FailState, Handle: Query, Error [ ], Errcode, Data [ ], DataSize, Float: Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED )  
    {
        log_amx ( "[SQL] %s", Error );
        
        return;
    }
    else 
    {
        new id = Data [0];
        
        if ( SQL_NumRows ( Query ) < 1 ) 
        {
            new Query [256];
 
            formatex ( Query, charsmax ( Query ), "INSERT INTO `%s` (`steamid`,`nickname`,`frags`,`deaths`,`money`,`last_seen_online`) VALUES (^"%s^",^"%s^",^"0^",^"0^",^"0^",^"N/A^");", SQL_TABLE, PlayerAuthID [id], PlayerName [id] );

            SQL_ThreadQuery ( iSqlTuple, "QuerySetData", Query );

        }
        else
        {
            iFrags [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "frags" ) );

            iDeaths [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "deaths" ) );

            iMoney [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "money" ) );

        }
    }
}

public SaveData ( id )
{
    new Query [256], sQuery [3000];
    
    formatex ( Query, charsmax ( Query ), "UPDATE `%s` SET ", SQL_TABLE );
    
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "nickname = ^"%s^", ", PlayerName [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "frags = ^"%i^", ", iFrags [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "deaths = ^"%i^", ", iDeaths [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "money = ^"%i^", ", iMoney [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "last_seen_online = ^"%s^" WHERE steamid = ^"%s^";", iLastConnected [id], PlayerAuthID [id] );
    
        add ( sQuery, charsmax ( sQuery ), Query );
        
    SQL_ThreadQuery ( iSqlTuple, "QuerySetData", sQuery );
}


public QuerySetData ( FailState, Handle: Query, Error [ ], Errcode, Data [ ], DataSize, Float:Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED ) 
    {
        log_amx ( "[SQL] %s", Error );
        
        return;
    }
}

public client_putinserver ( id )
{
    get_user_name ( id, PlayerName [id], charsmax ( PlayerName [ ] ) );

    get_user_authid ( id, PlayerAuthID [id], charsmax ( PlayerAuthID [ ] ) );

    iFrags [id] = 0;

    iDeaths [id] = 0;

    iMoney [id] = 0;

    iLastConnected [id] = "N/A";
    
    LoadData ( id );
}


public client_disconnect ( id )
{
    iMoney [id] += cs_get_user_money ( id );

    new iTime [32];

    get_time ( "%m/%d/%Y - %H:%M:%S", iTime, charsmax ( iTime ) )
  
    copy ( iLastConnected [id], charsmax ( iLastConnected [ ] ), iTime )

    SaveData ( id );
}

public EventDeathMsg (  )
{
    new Killer = read_data ( 1 );
    
    new Victim = read_data ( 2 );
    
    if ( !is_user_alive ( Killer ) || Killer == Victim || get_user_team ( Killer ) == get_user_team ( Victim ) ) 

        return

    iFrags [Killer] ++;

    iDeaths [Victim] ++;
}

public leRoundEnd (  )
{
     for ( new i = 1; i <= MaxPlayers; i ++ )
    {
        if ( is_user_connected ( i ) )
        {
            iMoney  += cs_get_user_money ( i );

            SaveData ( i );
        }
    }
}

public plugin_end (  ) SQL_FreeHandle ( iSqlTuple );


Multumesc de raspuns si solutie, totusi observ ca compilerul de la freakz nu mai exista.Cu ce il pot compila?
User avatar
EnTeR_
Membru, skill +1
Membru, skill +1
Posts: 454
Joined: 13 Sep 2014, 15:36
Detinator Steam: Da
Fond eXtream: 0
Been thanked: 3 times

26 Mar 2020, 20:28

The Kalu wrote:
26 Mar 2020, 19:47
EnTeR_ wrote:
26 Mar 2020, 18:19
Banuiesc ca vrei sa faci ceva pe steam only, altfel nu o sa-ti mearga cum trebuie salvarea pe steamid. Anyway, testeaza asta si spune-mi daca sunt probleme.
| Afiseaza codul
#include <   amxmodx   >
#include <   cstrike   >
#include <    sqlx     >

#pragma tabsize 0;

new SQL_TABLE [ ] = "users_stats";

new iFrags [33], iDeaths [33], iMoney [33], iLastConnected [33] [32], PlayerAuthID [33] [32], PlayerName [33] [32],

Handle: iSqlTuple, SQLHost [32], SQLUser [32], SQLPassword [32], SQLDatabase [32], cSqlHost, cSqlUser,

cSqlPassword, cSqlDatabase, MaxPlayers;

public plugin_init (  )
{
    register_event ( "DeathMsg", "EventDeathMsg", "a" );
    
    register_logevent ( "leRoundEnd", 2, "1=Round_End" );

    cSqlHost = register_cvar ( "sql_host", "host" );
    
    cSqlUser = register_cvar ( "sql_user", "user" );
    
    cSqlPassword = register_cvar ( "sql_password", "pw" );
    
    cSqlDatabase = register_cvar ( "sql_database", "db" );

    MaxPlayers = get_maxplayers (  );
}

public plugin_cfg (  ) 
{
        get_pcvar_string ( cSqlHost, SQLHost, charsmax ( SQLHost ) );
    
        get_pcvar_string ( cSqlUser, SQLUser, charsmax ( SQLUser ) );
    
        get_pcvar_string ( cSqlPassword, SQLPassword, charsmax ( SQLPassword ) );
    
        get_pcvar_string ( cSqlDatabase, SQLDatabase, charsmax ( SQLDatabase ) );

        iSqlTuple = SQL_MakeDbTuple ( SQLHost, SQLUser, SQLPassword, SQLDatabase );
    
        static Query [10048], Len;
        
        Len += formatex ( Query [Len], charsmax ( Query ), "CREATE TABLE IF NOT EXISTS `%s`", SQL_TABLE );
    
        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "(`steamid` varchar(32) NOT NULL, " );
    
        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`nickname` varchar(32) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`frags` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`deaths` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`money` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`last_seen_online` varchar(32) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY)" );
    
        SQL_ThreadQuery ( iSqlTuple, "CreateTableThread", Query );
}

public CreateTableThread ( FailState, Handle:Query, Error [ ], Errcode, Data [ ], DataSize, Float:Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED )
    {
        set_fail_state ( "[SQL] Query Error" );
    }
    
    if ( Errcode )
    {
        log_amx ( "[SQL] Error: %s", Error );
    }
}

public LoadData ( id ) 
{
    static Query [10048], Data [1];
    
    Data [0] = id;
    
    formatex ( Query, charsmax ( Query ), "SELECT * FROM `%s` WHERE steamid = ^"%s^";", SQL_TABLE, PlayerAuthID [id] );
    
    SQL_ThreadQuery ( iSqlTuple, "QuerySelectData", Query, Data, 1 );
}

public QuerySelectData ( FailState, Handle: Query, Error [ ], Errcode, Data [ ], DataSize, Float: Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED )  
    {
        log_amx ( "[SQL] %s", Error );
        
        return;
    }
    else 
    {
        new id = Data [0];
        
        if ( SQL_NumRows ( Query ) < 1 ) 
        {
            new Query [256];
 
            formatex ( Query, charsmax ( Query ), "INSERT INTO `%s` (`steamid`,`nickname`,`frags`,`deaths`,`money`,`last_seen_online`) VALUES (^"%s^",^"%s^",^"0^",^"0^",^"0^",^"N/A^");", SQL_TABLE, PlayerAuthID [id], PlayerName [id] );

            SQL_ThreadQuery ( iSqlTuple, "QuerySetData", Query );

        }
        else
        {
            iFrags [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "frags" ) );

            iDeaths [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "deaths" ) );

            iMoney [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "money" ) );

        }
    }
}

public SaveData ( id )
{
    new Query [256], sQuery [3000];
    
    formatex ( Query, charsmax ( Query ), "UPDATE `%s` SET ", SQL_TABLE );
    
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "nickname = ^"%s^", ", PlayerName [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "frags = ^"%i^", ", iFrags [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "deaths = ^"%i^", ", iDeaths [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "money = ^"%i^", ", iMoney [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "last_seen_online = ^"%s^" WHERE steamid = ^"%s^";", iLastConnected [id], PlayerAuthID [id] );
    
        add ( sQuery, charsmax ( sQuery ), Query );
        
    SQL_ThreadQuery ( iSqlTuple, "QuerySetData", sQuery );
}


public QuerySetData ( FailState, Handle: Query, Error [ ], Errcode, Data [ ], DataSize, Float:Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED ) 
    {
        log_amx ( "[SQL] %s", Error );
        
        return;
    }
}

public client_putinserver ( id )
{
    get_user_name ( id, PlayerName [id], charsmax ( PlayerName [ ] ) );

    get_user_authid ( id, PlayerAuthID [id], charsmax ( PlayerAuthID [ ] ) );

    iFrags [id] = 0;

    iDeaths [id] = 0;

    iMoney [id] = 0;

    iLastConnected [id] = "N/A";
    
    LoadData ( id );
}


public client_disconnect ( id )
{
    iMoney [id] += cs_get_user_money ( id );

    new iTime [32];

    get_time ( "%m/%d/%Y - %H:%M:%S", iTime, charsmax ( iTime ) )
  
    copy ( iLastConnected [id], charsmax ( iLastConnected [ ] ), iTime )

    SaveData ( id );
}

public EventDeathMsg (  )
{
    new Killer = read_data ( 1 );
    
    new Victim = read_data ( 2 );
    
    if ( !is_user_alive ( Killer ) || Killer == Victim || get_user_team ( Killer ) == get_user_team ( Victim ) ) 

        return

    iFrags [Killer] ++;

    iDeaths [Victim] ++;
}

public leRoundEnd (  )
{
     for ( new i = 1; i <= MaxPlayers; i ++ )
    {
        if ( is_user_connected ( i ) )
        {
            iMoney  += cs_get_user_money ( i );

            SaveData ( i );
        }
    }
}

public plugin_end (  ) SQL_FreeHandle ( iSqlTuple );


Multumesc de raspuns si solutie, totusi observ ca compilerul de la freakz nu mai exista.Cu ce il pot compila?


Compilezi local. Daca nu ai compiler, este unul in acest addons default: addon-uri/addon-default-amxx-1-8-2-3-t187339.html. Descarci versiunea pentru windows si ai acolo tot ce iti trebuie.
Discord: EyeKon#3230
User avatar
DevilBoy.eXe
Moderator ajutator
Moderator ajutator
Posts: 1442
Joined: 05 Jun 2016, 22:04
Detinator Steam: Da
Detinator server CS: GO.WARED.RO
SteamID: DevilBoy_eXe
Reputatie: Moderator ajutator
Fond eXtream: -1
Location: beyond the time
Has thanked: 9 times
Been thanked: 30 times
Contact:

26 Mar 2020, 20:58

EnTeR_ wrote:
26 Mar 2020, 20:28
The Kalu wrote:
26 Mar 2020, 19:47
EnTeR_ wrote:
26 Mar 2020, 18:19
Banuiesc ca vrei sa faci ceva pe steam only, altfel nu o sa-ti mearga cum trebuie salvarea pe steamid. Anyway, testeaza asta si spune-mi daca sunt probleme.
| Afiseaza codul
#include <   amxmodx   >
#include <   cstrike   >
#include <    sqlx     >

#pragma tabsize 0;

new SQL_TABLE [ ] = "users_stats";

new iFrags [33], iDeaths [33], iMoney [33], iLastConnected [33] [32], PlayerAuthID [33] [32], PlayerName [33] [32],

Handle: iSqlTuple, SQLHost [32], SQLUser [32], SQLPassword [32], SQLDatabase [32], cSqlHost, cSqlUser,

cSqlPassword, cSqlDatabase, MaxPlayers;

public plugin_init (  )
{
    register_event ( "DeathMsg", "EventDeathMsg", "a" );
    
    register_logevent ( "leRoundEnd", 2, "1=Round_End" );

    cSqlHost = register_cvar ( "sql_host", "host" );
    
    cSqlUser = register_cvar ( "sql_user", "user" );
    
    cSqlPassword = register_cvar ( "sql_password", "pw" );
    
    cSqlDatabase = register_cvar ( "sql_database", "db" );

    MaxPlayers = get_maxplayers (  );
}

public plugin_cfg (  ) 
{
        get_pcvar_string ( cSqlHost, SQLHost, charsmax ( SQLHost ) );
    
        get_pcvar_string ( cSqlUser, SQLUser, charsmax ( SQLUser ) );
    
        get_pcvar_string ( cSqlPassword, SQLPassword, charsmax ( SQLPassword ) );
    
        get_pcvar_string ( cSqlDatabase, SQLDatabase, charsmax ( SQLDatabase ) );

        iSqlTuple = SQL_MakeDbTuple ( SQLHost, SQLUser, SQLPassword, SQLDatabase );
    
        static Query [10048], Len;
        
        Len += formatex ( Query [Len], charsmax ( Query ), "CREATE TABLE IF NOT EXISTS `%s`", SQL_TABLE );
    
        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "(`steamid` varchar(32) NOT NULL, " );
    
        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`nickname` varchar(32) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`frags` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`deaths` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`money` int(11) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`last_seen_online` varchar(32) NOT NULL,");

        Len += formatex ( Query [Len], charsmax ( Query ) - Len, "`ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY)" );
    
        SQL_ThreadQuery ( iSqlTuple, "CreateTableThread", Query );
}

public CreateTableThread ( FailState, Handle:Query, Error [ ], Errcode, Data [ ], DataSize, Float:Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED )
    {
        set_fail_state ( "[SQL] Query Error" );
    }
    
    if ( Errcode )
    {
        log_amx ( "[SQL] Error: %s", Error );
    }
}

public LoadData ( id ) 
{
    static Query [10048], Data [1];
    
    Data [0] = id;
    
    formatex ( Query, charsmax ( Query ), "SELECT * FROM `%s` WHERE steamid = ^"%s^";", SQL_TABLE, PlayerAuthID [id] );
    
    SQL_ThreadQuery ( iSqlTuple, "QuerySelectData", Query, Data, 1 );
}

public QuerySelectData ( FailState, Handle: Query, Error [ ], Errcode, Data [ ], DataSize, Float: Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED )  
    {
        log_amx ( "[SQL] %s", Error );
        
        return;
    }
    else 
    {
        new id = Data [0];
        
        if ( SQL_NumRows ( Query ) < 1 ) 
        {
            new Query [256];
 
            formatex ( Query, charsmax ( Query ), "INSERT INTO `%s` (`steamid`,`nickname`,`frags`,`deaths`,`money`,`last_seen_online`) VALUES (^"%s^",^"%s^",^"0^",^"0^",^"0^",^"N/A^");", SQL_TABLE, PlayerAuthID [id], PlayerName [id] );

            SQL_ThreadQuery ( iSqlTuple, "QuerySetData", Query );

        }
        else
        {
            iFrags [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "frags" ) );

            iDeaths [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "deaths" ) );

            iMoney [id] = SQL_ReadResult ( Query, SQL_FieldNameToNum ( Query, "money" ) );

        }
    }
}

public SaveData ( id )
{
    new Query [256], sQuery [3000];
    
    formatex ( Query, charsmax ( Query ), "UPDATE `%s` SET ", SQL_TABLE );
    
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "nickname = ^"%s^", ", PlayerName [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "frags = ^"%i^", ", iFrags [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "deaths = ^"%i^", ", iDeaths [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "money = ^"%i^", ", iMoney [id] );
        
        add ( sQuery, charsmax ( sQuery ), Query );

    formatex ( Query, charsmax ( Query ), "last_seen_online = ^"%s^" WHERE steamid = ^"%s^";", iLastConnected [id], PlayerAuthID [id] );
    
        add ( sQuery, charsmax ( sQuery ), Query );
        
    SQL_ThreadQuery ( iSqlTuple, "QuerySetData", sQuery );
}


public QuerySetData ( FailState, Handle: Query, Error [ ], Errcode, Data [ ], DataSize, Float:Queuetime ) 
{
    if ( FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED ) 
    {
        log_amx ( "[SQL] %s", Error );
        
        return;
    }
}

public client_putinserver ( id )
{
    get_user_name ( id, PlayerName [id], charsmax ( PlayerName [ ] ) );

    get_user_authid ( id, PlayerAuthID [id], charsmax ( PlayerAuthID [ ] ) );

    iFrags [id] = 0;

    iDeaths [id] = 0;

    iMoney [id] = 0;

    iLastConnected [id] = "N/A";
    
    LoadData ( id );
}


public client_disconnect ( id )
{
    iMoney [id] += cs_get_user_money ( id );

    new iTime [32];

    get_time ( "%m/%d/%Y - %H:%M:%S", iTime, charsmax ( iTime ) )
  
    copy ( iLastConnected [id], charsmax ( iLastConnected [ ] ), iTime )

    SaveData ( id );
}

public EventDeathMsg (  )
{
    new Killer = read_data ( 1 );
    
    new Victim = read_data ( 2 );
    
    if ( !is_user_alive ( Killer ) || Killer == Victim || get_user_team ( Killer ) == get_user_team ( Victim ) ) 

        return

    iFrags [Killer] ++;

    iDeaths [Victim] ++;
}

public leRoundEnd (  )
{
     for ( new i = 1; i <= MaxPlayers; i ++ )
    {
        if ( is_user_connected ( i ) )
        {
            iMoney  += cs_get_user_money ( i );

            SaveData ( i );
        }
    }
}

public plugin_end (  ) SQL_FreeHandle ( iSqlTuple );


Multumesc de raspuns si solutie, totusi observ ca compilerul de la freakz nu mai exista.Cu ce il pot compila?


Compilezi local. Daca nu ai compiler, este unul in acest addons default: addon-uri/addon-default-amxx-1-8-2-3-t187339.html. Descarci versiunea pentru windows si ai acolo tot ce iti trebuie.


Sau asta topic365704.html, contine doar compilerul
Image
User avatar
The Kalu
eXtream Mod
eXtream Mod
Posts: 12364
Joined: 09 Oct 2010, 11:39
Detinator Steam: Da
Reputatie: Fost membru Club eXtreamCS (6 luni)
Nume anterior: Terra
Has thanked: 199 times
Been thanked: 339 times

26 Mar 2020, 22:47

Code: Select all

C:\Users\steel\Desktop\1.10 - build 5390\sql_table.sma(216) : error 023: array assignment must be simple assignment

Code: Select all

public leRoundEnd (  )
{
     for ( new i = 1; i <= MaxPlayers; i ++ )
    {
        if ( is_user_connected ( i ) )
        {
            iMoney  += cs_get_user_money ( i );

            SaveData ( i );
        }
    }
}

rezolvat, cred.Am adaugat id jucator

Code: Select all

public leRoundEnd ( id )
{

     for ( new i = 1; i <= MaxPlayers; i ++ )
    {
        if ( is_user_connected ( i ) )
        {
            iMoney[id]  += cs_get_user_money ( i );

            SaveData ( i );
        }
    }
}
zLowCS
Membru, skill 0
Membru, skill 0
Posts: 30
Joined: 28 Jan 2017, 12:20
Detinator Steam: Da
Fond eXtream: 0
Has thanked: 1 time
Contact:

26 Mar 2020, 22:49

Pentru loose indentation , foloseste
#pragma tabelsize 0
User avatar
EnTeR_
Membru, skill +1
Membru, skill +1
Posts: 454
Joined: 13 Sep 2014, 15:36
Detinator Steam: Da
Fond eXtream: 0
Been thanked: 3 times

26 Mar 2020, 23:01

E de la forum, inlocuieste iMoney += cs_get_user_money ( i ); cu iMoney [ i ] += cs_get_user_money ( i );
Discord: EyeKon#3230
User avatar
The Kalu
eXtream Mod
eXtream Mod
Posts: 12364
Joined: 09 Oct 2010, 11:39
Detinator Steam: Da
Reputatie: Fost membru Club eXtreamCS (6 luni)
Nume anterior: Terra
Has thanked: 199 times
Been thanked: 339 times

26 Mar 2020, 23:02

EnTeR_ wrote:
26 Mar 2020, 23:01
E de la forum, inlocuieste iMoney += cs_get_user_money ( i ); cu iMoney [ i ] += cs_get_user_money ( i );
Eu pusesem id, trebuie i in loop.Solved :*
User avatar
The Kalu
eXtream Mod
eXtream Mod
Posts: 12364
Joined: 09 Oct 2010, 11:39
Detinator Steam: Da
Reputatie: Fost membru Club eXtreamCS (6 luni)
Nume anterior: Terra
Has thanked: 199 times
Been thanked: 339 times

26 Mar 2020, 23:02

zLowCS wrote:
26 Mar 2020, 22:49
Pentru loose indentation , foloseste
#pragma tabelsize 0
Nup, am curatat un pic prin cod.
User avatar
The Kalu
eXtream Mod
eXtream Mod
Posts: 12364
Joined: 09 Oct 2010, 11:39
Detinator Steam: Da
Reputatie: Fost membru Club eXtreamCS (6 luni)
Nume anterior: Terra
Has thanked: 199 times
Been thanked: 339 times

27 Mar 2020, 02:10

Functioneaza perfect, multumesc.Am facut update si la amx mod x 1.8.3, nu stiu cat de sigur este!

Lipseste asta.

Code: Select all

Inca o chestie, daca are gag/mute sa nu ii adauge nimic timp de 1 zi ca si cum ar avea un fel de cooldown.
Image
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2856
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 38 times
Been thanked: 436 times
Contact:

27 Mar 2020, 20:24

pentru faza cu gag trb făcut cu nativ pentru plg extern pe care l postezi tu
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
Post Reply

Return to “Cereri”

  • Information