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

[CS:GO] Zombie Plague 1.2.1 (Updated 01-Mar-2023)


Post New Thread Reply   
 
Thread Tools Display Modes
romeo7
Senior Member
Join Date: Mar 2017
Old 02-26-2018 , 16:52   Re: [CS:GO] Release: Zombie Plague 7.8fix2
Reply With Quote #361

mysql not working prints error when join players
Quote:
[zbm3_addon_database.smx] Field 'money' doesn't have a default value in request: "INSERT INTO `zombieplague_database` (steam_id) VALUES ('STEAM_1:1:XXXXXXXX')"
romeo7 is offline
Mikado
Senior Member
Join Date: Nov 2012
Location: don't know where :/
Old 03-01-2018 , 01:35   Re: [CS:GO] Release: Zombie Plague 7.8fix2
Reply With Quote #362

Quote:
Originally Posted by eaz View Post
this one is for old version but you can try it

PHP Code:
#include <sourcemod> 
#include <sdktools>
#include <sdkhooks> 
#include <zombieplague>

#define EXTRA_ITEM_NAME                "Zombie Madness" // If string has @, phrase will be taken from translation file. For example: "@AK47" require translation block, "AK47" not require      
#define EXTRA_ITEM_COST                22       // Ammopacks cost     
#define EXTRA_ITEM_LEVEL                    0        // The level of the player, which allow to buy item. ['0' = off] 
#define EXTRA_ITEM_ONLINE            0       // The number of players, which allowed to buy item. ['0' = off]  
#define EXTRA_ITEM_LIMIT                    0       // The number of purchases, which allowed per round for player. ['0' = off] 

int iItem;

bool gMadnessUsed[MAXPLAYERS+1];

ConVar gMadnessTime;



public 
OnPluginStart() 
{
iItem ZP_RegisterExtraItem(EXTRA_ITEM_NAMEEXTRA_ITEM_COSTZP_TEAM_ZOMBIEEXTRA_ITEM_LEVELEXTRA_ITEM_ONLINEEXTRA_ITEM_LIMIT);
gMadnessTime         CreateConVar("zp_madness_time",          "2.0",     "Time of having madness.");
AutoExecConfig(true"zombieplague_madness");
}

public 
void OnMapStart(/*void*/)
{
    
// Sounds
    
FakePrecacheSound("zbm3/extra_item_zombie_madness.mp3");
}

public 
void ZP_OnClientInfected(int clientIndexint infectorIndex)
{
    
gMadnessUsed[clientIndex] = false
}

public 
void ZP_OnClientHeroed(int clientIndex)
{
    
gMadnessUsed[clientIndex] = false
}

public 
Action ZP_OnExtraBuyCommand(int clientIndexint extraitemIndex

    
// Verify that the client is connected and alive 
    
if(!IsPlayerExist(clientIndex)) 
    { 
        return 
Plugin_Handled
    }  
    if(
extraitemIndex == iItem
    {    
        
gMadnessUsed[clientIndex] = true;
        
SetEntityRenderMode(clientIndexRENDER_TRANSCOLOR);  
        
SetEntityRenderColor(clientIndex2360140255);
        
EmitSoundToAll("*/zbm3/extra_item_zombie_madness.mp3"clientIndexSNDCHAN_VOICESNDLEVEL_SCREAMING);
        
CreateTimer(GetConVarFloat(gMadnessTime), EventRemoveMadnessclientIndexTIMER_FLAG_NO_MAPCHANGE);
    } 
     
    
// Allow buying 
    
return Plugin_Continue
}

public 
Action EventRemoveMadness(Handle hTimerany clientIndex)
{
    
// Verify that the client is exist
    
if(!IsPlayerExist(clientIndex))
    {
        return 
Plugin_Stop;
    }

    
// If player have it, reset ammo
    
if(gMadnessUsed[clientIndex])
    {
        
gMadnessUsed[clientIndex] = false;
        
SetEntityRenderMode(clientIndexRENDER_TRANSCOLOR);  
        
SetEntityRenderColor(clientIndex255255255255);
    }

    
// Destroy timer
    
return Plugin_Stop;
}

public 
Action DamageTraceAttack(int iVictimint &iAttackerint &Inflictorfloat &damageint &pDamageBitsint &iAmmoTypeint iHitBoxint iHitGroup)
{
    
// If player used tank skill
    
if (ZP_IsPlayerZombie(iVictim) && gMadnessUsed[iVictim])
    {
        return 
Plugin_Handled;
    }

    
// Allow trace
    
return Plugin_Continue;
}

public 
void OnClientPostAdminCheck(int clientIndex)
{
    
SDKHook(clientIndexSDKHook_TraceAttackDamageTraceAttack);

Thank's i took the timer from this and it works like a charm
Mikado is offline
Mikado
Senior Member
Join Date: Nov 2012
Location: don't know where :/
Old 03-02-2018 , 22:15   Re: [CS:GO] Release: Zombie Plague 7.8fix2
Reply With Quote #363

@gubka the zombie & human classes aren't saved after you reconnect, both go to default, using mysql ammo packs are succesfully saved, any help ?
Mikado is offline
gubka
Veteran Member
Join Date: Jan 2012
Location: Russia
Old 03-05-2018 , 16:33   Re: [CS:GO] Release: Zombie Plague 7.8fix2
Reply With Quote #364

Quote:
Originally Posted by Mikado View Post
@gubka the zombie & human classes aren't saved after you reconnect, both go to default, using mysql ammo packs are succesfully saved, any help ?
change database plugin

PHP Code:
/**
 * ============================================================================
 *
 *  Zombie Plague Mod #3 Generation
 *
 *
 *  Copyright (C) 2015-2018 Nikita Ushakov (Ireland, Dublin)
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ============================================================================
 **/

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <zombieplague>

#pragma newdecls required

// Define for deleting database each map
//#define DROPPING

/**
 * Record plugin info.
 **/
public Plugin DataBase =
{
    
name            "[ZP] Addon: DataBase",
    
author          "qubka (Nikita Ushakov)",     
    
description     "MYSQL or SQlite database for ammopacks, level, exp",
    
version         "6.0",
    
url             "https://forums.alliedmods.net/showthread.php?t=290657"
}
 
/**
 * Name of database section in the database.cfg
 **/
#define AMMOPACK_BLOCK_DATABASE         "zombiedatabase"

/**
 * Amount of variables for new player.
 **/
#define DEFAULT_AMMOPACK    50
#define DEFAULT_LEVEL        1
#define DEFAULT_EXP            0

/**
 * Steam ID length.
 **/
#define STEAMID_MAX_LENGTH     32

// Handle for database
Handle hDataBase INVALID_HANDLE;

// Arrays for storing ID in the SQL base
char SteamID[MAXPLAYERS+1][STEAMID_MAX_LENGTH];
int  DataID[MAXPLAYERS+1];
bool IsLoaded[MAXPLAYERS+1];

/**
 * Create a SQL database connection.
 **/
public void OnConfigsExecuted(/*void*/)
{
    
// Close database handle, if it was already created
    
if(hDataBase != INVALID_HANDLE)
    {
        
delete hDataBase;
    }
    
    
// Returns if a named configuration is present in databases.cfg.
    
if(SQL_CheckConfig(AMMOPACK_BLOCK_DATABASE))
    {
        
// Initialize chars
        
char sError[BIG_LINE_LENGTH];
        
char sDriver[SMALL_LINE_LENGTH]; 
        
char sRequest[PLATFORM_MAX_PATH];
        
        
// Creates an SQL connection from a named configuration
        
hDataBase SQL_Connect(AMMOPACK_BLOCK_DATABASEfalsesErrorsizeof(sError));

        
// If base doesn't exist or mod can't make connection
        
if(hDataBase == INVALID_HANDLE)
        {
            
SetFailState(sError);
            return;
        }
        
        
// Reads the driver of an opened database
        
SQL_ReadDriver(hDataBasesDriversizeof(sDriver)); 
        
        
// If driver is a MySQL
        
bool MySQLDataBase StrEqual(sDriver"mysql"false);
        
        
// Block sql base from the other requests
        
SQL_LockDatabase(hDataBase);
        
        
// Delete existing database if dropping enable
        #if defined DROPPING
            // Format request
            
Format(sRequestsizeof(sRequest), "DROP TABLE IF EXISTS `zombieplague_database`");
            
            
// Sent a request
            
if(!SQL_FastQuery(hDataBasesRequest))
            {
                
// Get an error, if it exist
                
SQL_GetError(hDataBasesErrorsizeof(sError));
                
                
// Log error and stop server
                
SetFailState("%s in request: \"%s\""sErrorsRequest);
                return;
            }
        
#endif
        
        // Format request
        
if(MySQLDataBase)
        {
            
Format(sRequestsizeof(sRequest), "CREATE TABLE IF NOT EXISTS `zombieplague_database` (`id` int(64) NOT NULL auto_increment, `steam_id` varchar(32) NOT NULL, `money` int(64) NOT NULL, `level` int(64) NOT NULL, `exp` int(64) NOT NULL, `humanclass` int(64) NOT NULL, `zombieclass` int(64) NOT NULL, PRIMARY KEY  (`id`), UNIQUE KEY `steam_id` (`steam_id`))");
        }
        else
        {
            
Format(sRequestsizeof(sRequest), "CREATE TABLE IF NOT EXISTS `zombieplague_database` (id INTEGER PRIMARY KEY AUTOINCREMENT, steam_id TEXT UNIQUE, money INTEGER, level INTEGER, exp INTEGER, humanclass INTEGER, zombieclass INTEGER)");
        }
        
        
// Sent a request
        
if(!SQL_FastQuery(hDataBasesRequest))
        {
            
// Get an error, if it exist
            
SQL_GetError(hDataBasesErrorsizeof(sError));
            
            
// Log error and stop server
            
SetFailState("%s in request: \"%s\""sErrorsRequest);
            return;
        }

        
// Unlock it
        
SQL_UnlockDatabase(hDataBase);
    }
    else
    {
        
SetFailState("Section \"%s\" doesn't found in databases.cfg"AMMOPACK_BLOCK_DATABASE);
    }
}



/**
 * SQL functions, which work with the client.
 **/
 
 
 
/**
 * Called when a client is disconnecting from the server.
 *
 * @param clientIndex        The client index.
 **/
public void OnClientDisconnect(int clientIndex)
{
    
#pragma unused clientIndex
    
    // If client wasn't load, then stop
    
if(!IsLoaded[clientIndex])
    {
        return;
    }
    
    
// Update ammopacks in database
    
SaveClientInfo(clientIndex);
    
    
// Reset client's variables
    
DataID[clientIndex] = -1;
    
IsLoaded[clientIndex] = false;
}

/**
 * Called once a client is authorized and fully in-game, and 
 * after all post-connection authorizations have been performed.  
 *
 * This callback is gauranteed to occur on all clients, and always 
 * after each OnClientPutInServer() call.
 * 
 * @param clientIndex        The client index. 
 **/
public void OnClientPostAdminCheck(int clientIndex)
{
    
#pragma unused clientIndex
    
    // Reset client's variables
    
DataID[clientIndex] = -1;
    
IsLoaded[clientIndex] = false;
    
    
// If database doesn't exist, then stop
    
if(hDataBase == INVALID_HANDLE)
    {
        return;
    }
    
    
// Verify that the client is non-bot
    
if(IsFakeClient(clientIndex))
    {
        return;
    }
    
    
// Initialize reqest char
    
static char sRequest[PLATFORM_MAX_PATH];
    
    
// Get client's authentication string (SteamID)
    
if(!GetClientAuthId(clientIndexAuthId_Steam2SteamID[clientIndex], sizeof(SteamID[])))
    {
        return;
    }

    
// Format request
    
Format(sRequestsizeof(sRequest), "SELECT id, money, level, exp, humanclass, zombieclass FROM `zombieplague_database` WHERE steam_id = '%s'"SteamID[clientIndex]);
    
    
// Sent a request
    
SQL_TQuery(hDataBaseSQLBaseExtract_CallbacksRequestGetClientUserId(clientIndex));
}

/**
 * General callback for threaded SQL stuff
 *
 * @param hDriver            Parent object of the handle.
 * @param hResult            Handle to the child object.
 * @param sSQLerror            Error string if there was an error.
 * @param clientID            Data passed in via the original threaded invocation.
 **/
public void SQLBaseExtract_Callback(Handle hDriverHandle hResult, const char[] sSQLerrorany clientID)
{
    
// Get real player index from event key
    
int clientIndex GetClientOfUserId(clientID);

    
#pragma unused clientIndex
    
    // Make sure the client didn't disconnect while the thread was running
    
if(clientIndex)
    {
        
// If invalid query handle
        
if(hResult == INVALID_HANDLE)
        {
            
LogError(sSQLerror);
            return;
        }
        else
        {
            
// Client was found, get ammopacks from the table
            
if(SQL_FetchRow(hResult))
            {
                
// Get client ID in the row
                
DataID[clientIndex] = SQL_FetchInt(hResult0); 
                
                
// Set client loaded amount of ammopacks
                
ZP_SetClientAmmoPack(clientIndexSQL_FetchInt(hResult1));
                
                
// Set client level
                
ZP_SetClientLevel(clientIndexSQL_FetchInt(hResult2));
                
                
// Set client exp
                
ZP_SetClientExp(clientIndexSQL_FetchInt(hResult3));

                
// Set client human class
                
ZP_SetClientHumanClass(clientIndexSQL_FetchInt(hResult4));

                
// Set client zombie class
                
ZP_SetClientZombieClass(clientIndexSQL_FetchInt(hResult5));

                
// Update ammopacks in database
                
SaveClientInfo(clientIndex);
            }
            else
            {
                
// Initialize reqest char
                
char sRequest[PLATFORM_MAX_PATH];
                
                
// Format request
                
Format(sRequestsizeof(sRequest), "INSERT INTO `zombieplague_database` (steam_id) VALUES ('%s')"SteamID[clientIndex]);
                
                
// Block sql base from the other requests
                
SQL_LockDatabase(hDataBase);
                
                
// Sent a request
                
if(!SQL_FastQuery(hDataBasesRequest))
                {
                    
// Initialize char
                    
static char sError[BIG_LINE_LENGTH];
                
                    
// Get an error, if it exist
                    
SQL_GetError(hDataBasesErrorsizeof(sError));
                    
                    
// Log error
                    
LogError("%s in request: \"%s\""sErrorsRequest);
                }
                
                
// Unlock it
                
SQL_UnlockDatabase(hDataBase);
                
                
// Set starter client stats
                
ZP_SetClientAmmoPack(clientIndexDEFAULT_AMMOPACK);
                
ZP_SetClientLevel(clientIndexDEFAULT_LEVEL);
                
ZP_SetClientExp(clientIndexDEFAULT_EXP);
            }
            
            
// Client was loaded
            
IsLoaded[clientIndex] = true;
        }
    }
}

/**
 * Called for inserting amount of ammopacks in the SQL base.
 *
 * @param clientIndex        The client index.
 **/
void SaveClientInfo(int clientIndex)
{
    
#pragma unused clientIndex
    
    // Initialize reqest char
    
static char sRequest[PLATFORM_MAX_PATH];
    
    
// Format request
    
if(DataID[clientIndex] < 1)
    {
        
Format(sRequestsizeof(sRequest), "UPDATE `zombieplague_database` SET money = %d, level = %d, exp = %d, humanclass = %d, zombieclass = %d WHERE steam_id = '%s'"ZP_GetClientAmmoPack(clientIndex), ZP_GetClientLevel(clientIndex), ZP_GetClientExp(clientIndex), ZP_GetClientHumanClassNext(clientIndex), ZP_GetClientZombieClassNext(clientIndex), SteamID[clientIndex]);
    }
    else
    {
        
Format(sRequestsizeof(sRequest), "UPDATE `zombieplague_database` SET money = %d, level = %d, exp = %d, humanclass = %d, zombieclass = %d WHERE id = %d"ZP_GetClientAmmoPack(clientIndex), ZP_GetClientLevel(clientIndex), ZP_GetClientExp(clientIndex), ZP_GetClientHumanClassNext(clientIndex), ZP_GetClientZombieClassNext(clientIndex), DataID[clientIndex]);
    }
    
    
// Block sql base from the other requests
    
SQL_LockDatabase(hDataBase);
    
    
// Sent a request
    
if(!SQL_FastQuery(hDataBasesRequest))
    {
        
// Initialize char
        
static char sError[BIG_LINE_LENGTH];
    
        
// Get an error, if it exist
        
SQL_GetError(hDataBasesErrorsizeof(sError));
        
        
// Log error
        
LogError("%s in request: \"%s\""sErrorsRequest);
    }
    
    
// Unlock it
    
SQL_UnlockDatabase(hDataBase);

__________________

Last edited by gubka; 03-05-2018 at 16:41.
gubka is offline
Send a message via ICQ to gubka
Mikado
Senior Member
Join Date: Nov 2012
Location: don't know where :/
Old 03-08-2018 , 04:33   Re: [CS:GO] Release: Zombie Plague 7.8fix2
Reply With Quote #365

Quote:
Originally Posted by gubka View Post
change database plugin
Quote:
L 03/08/2018 - 00:09:25: SourceMod error session started
L 03/08/2018 - 00:09:25: Info (map "zm_ice_attack3_csgo") (file "errors_20180308.log")
L 03/08/2018 - 00:09:25: [zbm3_addon_database.smx] no such column: humanclass
L 03/08/2018 - 09:20:50: Error log file session closed.
getting log errors and still not saving.

Edit: Nvm, it works now, had to delet old data.
thank's to @romeo7

Last edited by Mikado; 03-13-2018 at 05:47.
Mikado is offline
AuricYoutube
Senior Member
Join Date: Aug 2016
Location: Here
Old 03-10-2018 , 02:48   Re: [CS:GO] Release: Zombie Plague 7.8fix2
Reply With Quote #366

can you add prop shop pls
AuricYoutube is offline
romeo7
Senior Member
Join Date: Mar 2017
Old 03-10-2018 , 16:31   Re: [CS:GO] Release: Zombie Plague 7.8fix2
Reply With Quote #367

Quote:
Originally Posted by Mikado View Post
getting log errors and still not saving.
you must delete old data
romeo7 is offline
EMINEM_FB
Senior Member
Join Date: Dec 2010
Location: Czech republic
Old 03-13-2018 , 12:21   Re: [CS:GO] Release: Zombie Plague 7.8fix2
Reply With Quote #368

Fixed view possition of all zombie plague claws



Download here
Contact me for more models here
__________________

Last edited by EMINEM_FB; 03-13-2018 at 12:22.
EMINEM_FB is offline
rokfestr
Member
Join Date: Apr 2011
Old 03-19-2018 , 05:30   Re: [CS:GO] Release: Zombie Plague 7.8fix2
Reply With Quote #369

Quote:
Originally Posted by gubka View Post
change database plugin

PHP Code:
/**
 * ============================================================================
 *
 *  Zombie Plague Mod #3 Generation
 *
 *
 *  Copyright (C) 2015-2018 Nikita Ushakov (Ireland, Dublin)
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ============================================================================
 **/

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <zombieplague>

#pragma newdecls required

// Define for deleting database each map
//#define DROPPING

/**
 * Record plugin info.
 **/
public Plugin DataBase =
{
    
name            "[ZP] Addon: DataBase",
    
author          "qubka (Nikita Ushakov)",     
    
description     "MYSQL or SQlite database for ammopacks, level, exp",
    
version         "6.0",
    
url             "https://forums.alliedmods.net/showthread.php?t=290657"
}
 
/**
 * Name of database section in the database.cfg
 **/
#define AMMOPACK_BLOCK_DATABASE         "zombiedatabase"

/**
 * Amount of variables for new player.
 **/
#define DEFAULT_AMMOPACK    50
#define DEFAULT_LEVEL        1
#define DEFAULT_EXP            0

/**
 * Steam ID length.
 **/
#define STEAMID_MAX_LENGTH     32

// Handle for database
Handle hDataBase INVALID_HANDLE;

// Arrays for storing ID in the SQL base
char SteamID[MAXPLAYERS+1][STEAMID_MAX_LENGTH];
int  DataID[MAXPLAYERS+1];
bool IsLoaded[MAXPLAYERS+1];

/**
 * Create a SQL database connection.
 **/
public void OnConfigsExecuted(/*void*/)
{
    
// Close database handle, if it was already created
    
if(hDataBase != INVALID_HANDLE)
    {
        
delete hDataBase;
    }
    
    
// Returns if a named configuration is present in databases.cfg.
    
if(SQL_CheckConfig(AMMOPACK_BLOCK_DATABASE))
    {
        
// Initialize chars
        
char sError[BIG_LINE_LENGTH];
        
char sDriver[SMALL_LINE_LENGTH]; 
        
char sRequest[PLATFORM_MAX_PATH];
        
        
// Creates an SQL connection from a named configuration
        
hDataBase SQL_Connect(AMMOPACK_BLOCK_DATABASEfalsesErrorsizeof(sError));

        
// If base doesn't exist or mod can't make connection
        
if(hDataBase == INVALID_HANDLE)
        {
            
SetFailState(sError);
            return;
        }
        
        
// Reads the driver of an opened database
        
SQL_ReadDriver(hDataBasesDriversizeof(sDriver)); 
        
        
// If driver is a MySQL
        
bool MySQLDataBase StrEqual(sDriver"mysql"false);
        
        
// Block sql base from the other requests
        
SQL_LockDatabase(hDataBase);
        
        
// Delete existing database if dropping enable
        #if defined DROPPING
            // Format request
            
Format(sRequestsizeof(sRequest), "DROP TABLE IF EXISTS `zombieplague_database`");
            
            
// Sent a request
            
if(!SQL_FastQuery(hDataBasesRequest))
            {
                
// Get an error, if it exist
                
SQL_GetError(hDataBasesErrorsizeof(sError));
                
                
// Log error and stop server
                
SetFailState("%s in request: \"%s\""sErrorsRequest);
                return;
            }
        
#endif
        
        // Format request
        
if(MySQLDataBase)
        {
            
Format(sRequestsizeof(sRequest), "CREATE TABLE IF NOT EXISTS `zombieplague_database` (`id` int(64) NOT NULL auto_increment, `steam_id` varchar(32) NOT NULL, `money` int(64) NOT NULL, `level` int(64) NOT NULL, `exp` int(64) NOT NULL, `humanclass` int(64) NOT NULL, `zombieclass` int(64) NOT NULL, PRIMARY KEY  (`id`), UNIQUE KEY `steam_id` (`steam_id`))");
        }
        else
        {
            
Format(sRequestsizeof(sRequest), "CREATE TABLE IF NOT EXISTS `zombieplague_database` (id INTEGER PRIMARY KEY AUTOINCREMENT, steam_id TEXT UNIQUE, money INTEGER, level INTEGER, exp INTEGER, humanclass INTEGER, zombieclass INTEGER)");
        }
        
        
// Sent a request
        
if(!SQL_FastQuery(hDataBasesRequest))
        {
            
// Get an error, if it exist
            
SQL_GetError(hDataBasesErrorsizeof(sError));
            
            
// Log error and stop server
            
SetFailState("%s in request: \"%s\""sErrorsRequest);
            return;
        }

        
// Unlock it
        
SQL_UnlockDatabase(hDataBase);
    }
    else
    {
        
SetFailState("Section \"%s\" doesn't found in databases.cfg"AMMOPACK_BLOCK_DATABASE);
    }
}



/**
 * SQL functions, which work with the client.
 **/
 
 
 
/**
 * Called when a client is disconnecting from the server.
 *
 * @param clientIndex        The client index.
 **/
public void OnClientDisconnect(int clientIndex)
{
    
#pragma unused clientIndex
    
    // If client wasn't load, then stop
    
if(!IsLoaded[clientIndex])
    {
        return;
    }
    
    
// Update ammopacks in database
    
SaveClientInfo(clientIndex);
    
    
// Reset client's variables
    
DataID[clientIndex] = -1;
    
IsLoaded[clientIndex] = false;
}

/**
 * Called once a client is authorized and fully in-game, and 
 * after all post-connection authorizations have been performed.  
 *
 * This callback is gauranteed to occur on all clients, and always 
 * after each OnClientPutInServer() call.
 * 
 * @param clientIndex        The client index. 
 **/
public void OnClientPostAdminCheck(int clientIndex)
{
    
#pragma unused clientIndex
    
    // Reset client's variables
    
DataID[clientIndex] = -1;
    
IsLoaded[clientIndex] = false;
    
    
// If database doesn't exist, then stop
    
if(hDataBase == INVALID_HANDLE)
    {
        return;
    }
    
    
// Verify that the client is non-bot
    
if(IsFakeClient(clientIndex))
    {
        return;
    }
    
    
// Initialize reqest char
    
static char sRequest[PLATFORM_MAX_PATH];
    
    
// Get client's authentication string (SteamID)
    
if(!GetClientAuthId(clientIndexAuthId_Steam2SteamID[clientIndex], sizeof(SteamID[])))
    {
        return;
    }

    
// Format request
    
Format(sRequestsizeof(sRequest), "SELECT id, money, level, exp, humanclass, zombieclass FROM `zombieplague_database` WHERE steam_id = '%s'"SteamID[clientIndex]);
    
    
// Sent a request
    
SQL_TQuery(hDataBaseSQLBaseExtract_CallbacksRequestGetClientUserId(clientIndex));
}

/**
 * General callback for threaded SQL stuff
 *
 * @param hDriver            Parent object of the handle.
 * @param hResult            Handle to the child object.
 * @param sSQLerror            Error string if there was an error.
 * @param clientID            Data passed in via the original threaded invocation.
 **/
public void SQLBaseExtract_Callback(Handle hDriverHandle hResult, const char[] sSQLerrorany clientID)
{
    
// Get real player index from event key
    
int clientIndex GetClientOfUserId(clientID);

    
#pragma unused clientIndex
    
    // Make sure the client didn't disconnect while the thread was running
    
if(clientIndex)
    {
        
// If invalid query handle
        
if(hResult == INVALID_HANDLE)
        {
            
LogError(sSQLerror);
            return;
        }
        else
        {
            
// Client was found, get ammopacks from the table
            
if(SQL_FetchRow(hResult))
            {
                
// Get client ID in the row
                
DataID[clientIndex] = SQL_FetchInt(hResult0); 
                
                
// Set client loaded amount of ammopacks
                
ZP_SetClientAmmoPack(clientIndexSQL_FetchInt(hResult1));
                
                
// Set client level
                
ZP_SetClientLevel(clientIndexSQL_FetchInt(hResult2));
                
                
// Set client exp
                
ZP_SetClientExp(clientIndexSQL_FetchInt(hResult3));

                
// Set client human class
                
ZP_SetClientHumanClass(clientIndexSQL_FetchInt(hResult4));

                
// Set client zombie class
                
ZP_SetClientZombieClass(clientIndexSQL_FetchInt(hResult5));

                
// Update ammopacks in database
                
SaveClientInfo(clientIndex);
            }
            else
            {
                
// Initialize reqest char
                
char sRequest[PLATFORM_MAX_PATH];
                
                
// Format request
                
Format(sRequestsizeof(sRequest), "INSERT INTO `zombieplague_database` (steam_id) VALUES ('%s')"SteamID[clientIndex]);
                
                
// Block sql base from the other requests
                
SQL_LockDatabase(hDataBase);
                
                
// Sent a request
                
if(!SQL_FastQuery(hDataBasesRequest))
                {
                    
// Initialize char
                    
static char sError[BIG_LINE_LENGTH];
                
                    
// Get an error, if it exist
                    
SQL_GetError(hDataBasesErrorsizeof(sError));
                    
                    
// Log error
                    
LogError("%s in request: \"%s\""sErrorsRequest);
                }
                
                
// Unlock it
                
SQL_UnlockDatabase(hDataBase);
                
                
// Set starter client stats
                
ZP_SetClientAmmoPack(clientIndexDEFAULT_AMMOPACK);
                
ZP_SetClientLevel(clientIndexDEFAULT_LEVEL);
                
ZP_SetClientExp(clientIndexDEFAULT_EXP);
            }
            
            
// Client was loaded
            
IsLoaded[clientIndex] = true;
        }
    }
}

/**
 * Called for inserting amount of ammopacks in the SQL base.
 *
 * @param clientIndex        The client index.
 **/
void SaveClientInfo(int clientIndex)
{
    
#pragma unused clientIndex
    
    // Initialize reqest char
    
static char sRequest[PLATFORM_MAX_PATH];
    
    
// Format request
    
if(DataID[clientIndex] < 1)
    {
        
Format(sRequestsizeof(sRequest), "UPDATE `zombieplague_database` SET money = %d, level = %d, exp = %d, humanclass = %d, zombieclass = %d WHERE steam_id = '%s'"ZP_GetClientAmmoPack(clientIndex), ZP_GetClientLevel(clientIndex), ZP_GetClientExp(clientIndex), ZP_GetClientHumanClassNext(clientIndex), ZP_GetClientZombieClassNext(clientIndex), SteamID[clientIndex]);
    }
    else
    {
        
Format(sRequestsizeof(sRequest), "UPDATE `zombieplague_database` SET money = %d, level = %d, exp = %d, humanclass = %d, zombieclass = %d WHERE id = %d"ZP_GetClientAmmoPack(clientIndex), ZP_GetClientLevel(clientIndex), ZP_GetClientExp(clientIndex), ZP_GetClientHumanClassNext(clientIndex), ZP_GetClientZombieClassNext(clientIndex), DataID[clientIndex]);
    }
    
    
// Block sql base from the other requests
    
SQL_LockDatabase(hDataBase);
    
    
// Sent a request
    
if(!SQL_FastQuery(hDataBasesRequest))
    {
        
// Initialize char
        
static char sError[BIG_LINE_LENGTH];
    
        
// Get an error, if it exist
        
SQL_GetError(hDataBasesErrorsizeof(sError));
        
        
// Log error
        
LogError("%s in request: \"%s\""sErrorsRequest);
    }
    
    
// Unlock it
    
SQL_UnlockDatabase(hDataBase);

Не работает на MySQL, выдает ошибку:
Code:
L 03/19/2018 - 12:04:45: [SM] Exception reported: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to us in request: "CREATE TABLE IF NOT EXISTS `zombieplague_database` (`id` int(64) NOT NULL auto_increment, `steam_id` varchar(32) NOT NULL, `money` int(64) NOT NULL, `level` int(64) NOT NULL, `exp` int(64) NOT NULL, `humanclass` int(64) NOT NULL, `zombieclass` int(64) NOT"
L 03/19/2018 - 12:04:45: [SM] Blaming: zp/zbm3_addon_database.smx
L 03/19/2018 - 12:04:45: [SM] Call stack trace:
L 03/19/2018 - 12:04:45: [SM]   [0] SetFailState
L 03/19/2018 - 12:04:45: [SM]   [1] Line 144, zbm3_addon_database.sp::OnConfigsExecuted
На sqlite без ошибок
rokfestr is offline
Mikado
Senior Member
Join Date: Nov 2012
Location: don't know where :/
Old 03-19-2018 , 22:25   Re: [CS:GO] Release: Zombie Plague 7.8fix2
Reply With Quote #370

Quote:
Originally Posted by rokfestr View Post
Не работает на MySQL, выдает ошибку:
Code:
L 03/19/2018 - 12:04:45: [SM] Exception reported: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to us in request: "CREATE TABLE IF NOT EXISTS `zombieplague_database` (`id` int(64) NOT NULL auto_increment, `steam_id` varchar(32) NOT NULL, `money` int(64) NOT NULL, `level` int(64) NOT NULL, `exp` int(64) NOT NULL, `humanclass` int(64) NOT NULL, `zombieclass` int(64) NOT"
L 03/19/2018 - 12:04:45: [SM] Blaming: zp/zbm3_addon_database.smx
L 03/19/2018 - 12:04:45: [SM] Call stack trace:
L 03/19/2018 - 12:04:45: [SM]   [0] SetFailState
L 03/19/2018 - 12:04:45: [SM]   [1] Line 144, zbm3_addon_database.sp::OnConfigsExecuted
На sqlite без ошибок
Delet old database.
Mikado is offline
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 02:35.


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