Участник
Пользователь
- Сообщения
- 103
- Реакции
- 9
- Ошибка
-
Перезапись данных в столбцах таблицы mysql сервера (сброс уровня игроков, привязанного по SteamID).
- ОС
- Linux
- Amx Mod X
-
AMX Mod X 1.9.0.5241 (http://www.amxmodx.org)
Authors:
David "BAILOPAN" Anderson, Pavol "PM OnoTo" Marko
Felix "SniperBeamer" Geyer, Jonny "Got His Gun" Bergstrom
Lukasz "SidLuke" Wlasinski, Christian "Basic-Master" Hammacher
Borja "faluco" Ferrer, Scott "DS" Ehlert
Compiled: Jan 30 2019 07:09:07
Built from: https://github.com/alliedmodders/amxmodx/commit/2110037
Build ID: 5241:2110037
Core mode: JIT+ASM32
- Билд
-
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.7.0.692-dev
Build date: 18:58:01 Sep 21 2019 (1988)
Build from: https://github.com/dreamstalker/rehlds/commit/e7232be
- ReGamedll
-
ReGameDLL version: 5.13.0.434-dev
Build date: 09:36:38 Dec 26 2019
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/7983a9d
- Версия Metamod
-
Metamod-r v1.3.0.128, API (5:13)
Metamod-r build: 17:47:54 Aug 24 2018
Metamod-r from: https://github.com/theAsmodai/metamod-r/commit/0cf2f70
- Список метамодулей
-
Currently loaded plugins:
description stat pend file vers src load unload
[ 1] SafeNameAndChat RUN - SafeNameAndChat.so v1.1 ini ANY ANY
[ 2] Reunion RUN - reunion_mm_i386.so v0.1.0.92 ini Start Never
[ 3] ReAuthCheck RUN - reauthcheck_mm_i386.so v0.1.6 ini Start Never
[ 4] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC3 ini ANY ANY
[ 5] AMX Mod X RUN - amxmodx_mm_i386.so v1.9.0.5241 ini Start ANY
[ 6] Rechecker RUN - rechecker_mm_i386.so v2.5 ini Chlvl ANY
[ 7] ReSemiclip RUN - resemiclip_mm_i386.so v2.3.9 ini Chlvl ANY
[ 8] MySQL RUN - mysql_amxx_i386.so v1.9.0.5241 pl5 ANY ANY
[ 9] ReAPI RUN - reapi_amxx_i386.so v5.12.0.192-dev pl5 ANY Never
[10] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5241 pl5 ANY ANY
[11] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5241 pl5 ANY ANY
[12] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5241 pl5 ANY ANY
[13] Fun RUN - fun_amxx_i386.so v1.9.0.5241 pl5 ANY ANY
[14] Engine RUN - engine_amxx_i386.so v1.9.0.5241 pl5 ANY ANY
[15] GeoIP RUN - geoip_amxx_i386.so v1.9.0.5241 pl5 ANY ANY
15 plugins, 15 running
- Список плагинов
-
Currently loaded plugins:
name version author file status
[ 1] [AMXX] DeathRun Stats 1.0 Komap AMXX_DeathRunSt debug
[ 2] GameCMS_API 5.2.9 zhorzh78 gamecms_api.amx running
[ 3] GameCMS_GagManager 2.2.2 zhorzh78 gamecms_gagmana running
[ 4] Lite Bans 2.2 neygomon lite_bans_off.a running
[ 5] GameCMS Time Awards 1.4 API_5 zhorzh78 gamecms_time_aw running
[ 6] Maps Menu 1.9.0.5234 AMXX Dev Team mapsmenu.amxx running
[ 7] Admin Votes 1.8.3-dev+ AMXX Dev Team adminvote.amxx running
[ 8] Lite MapChooser 2.6 neygomon mapchooser.amxx running
[ 9] [AMXX] NewYear v2 2.1.1 Komap AMXX_Xmas.amxx debug
[ 10] [AMXX] Fireworks 1.1.3 Komap AMXX_XmasFireWo debug
[ 11] Reklama 30.11.2018 mx?! reklama.amxx running
[ 12] Demo Recorder 2.4.0 F@nt0M demo_recorder.a running
[ 13] Players Menu 1.7 neugomon players_menu.am running
[ 14] Ping Control 1.31 neygomon ping_control.am running
[ 15] [AMXX] CKPUH_III_OT Komap 1.0 info.amxx running
[ 16] Frost Trap 1.11 R3X DeathRun_FrostT running
[ 17] Deathrun Manager 3.0.3 modi xPaw / smowin / DeathRun_MainMo debug
[ 18] Level [MySQL] + speed 1.0 Kulogram/Evolut DeathRun_LevelS running
[ 19] DeathRun Duels 3.2 Sho0ter & CaNiBa DeathRun_Duels. running
[ 20] DeathRun Games 1.0 [Forze]*Misterio DeathRun_Games. running
[ 21] DeathRun Shop 1.0 [Forze]*Misterio DeathRun_Shop.a running
[ 22] DeathRun Seller 1.0 [Forze]*Misterio DeathRun_Seller debug
[ 23] Чеки 0.7 BlackSmoke DeathRun_CheckP running
[ 24] DeathRun Knife Mod 1.0 [Forze]*Misterio DeathRun_KnifeS running
[ 25] plugin_trail 1.3.2 Bahrmanou,Nickro DeathRun_TrailS running
[ 26] [DR]AutoBhop 1.0 DeathRun_Bhop.a running
[ 27] DeathRun menu 1.0 [Forze]*Misterio DeathRun_Menu.a debug
[ 28] Auto Join on Connect 0.1 VEN DeathRun_AutoJo running
[ 29] AdminMenu 1.0 bublik DeathRun_VipMen running
[ 30] AdminMenu 1.0 bublik DeathRun_AdminM running
[ 31] AdminMenu 1.0 bublik DeathRun_BossMe running
[ 32] AdminMenu 1.0 bublik DeathRun_SuperM running
[ 33] AdminMenu 4.1 SkocH & Schibeki DeathRun_SuperG running
[ 34] DeathRun Hook 1.0 [Forze]*Misterio DeathRun_Hook.a running
[ 35] SpecList 1.2a SasaiLalka DeathRun_SpecLi running
[ 36] [DR] HidePlayers 1.0 Komap AMXX_DR_HidePla running
[ 37] VIP Tag 0.1 c-s.net.ua VipTab.amxx running
[ 38] [reAPI] Flash Control 1.1 neugomon flash_control.a running
[ 39] Paint Marker 1.1 w0w paint_marker.am debug
[ 40] Walls Creator 1.1 d3m37r4 walls_creator.a debug
[ 41] CMS_SkinManager 1.2 zhorhz78 CMS_SkinManager running
[ 42] AFK Kicker by Leo_[BH] 2.0 Leo_[BH] / Chees afkkicker.amxx running
[ 43] unknown unknown unknown transfer.amxx running
[ 44] [ReAPI] Block 'Fire in 0.0.1 sergrib block_fith.amxx running
[ 45] resetscore(ReAPI) 1.0 Phantom re_rs.amxx running
[ 46] knopki 1.0 StudenT knopki.amxx running
[ 47] Invisible Spectator 1.0 ReHLDS Team re_invis_spec.a running
[ 48] [183] Analizator 19.10.08 SKAJIbnEJIb analizator.amxx running
[ 49] Lite Translit 2.8 neygomon lite_translit.a running
49 plugins, 49 running
- Автор плагина
- Kulogram/Evolution
- Версия плагина
- 1.0
- Исходный код
-
#include < amxmodx >
#include < cstrike >
#include < sqlx >
#include < hamsandwich >
#include < fakemeta >
#include < amxmisc >
#define PLUGIN " Level [MySQL] + speedometr "
#define VERSION " 1.0 "
#define AUTHOR " Kulogram/Evolution "
new OneKill = 15 // Сколько нужно убить что бы получить 2 уровень
new TwoKill = 30 // + 10 убийств к следующему уровню ( На 2 уровне, нужно будет убить 50 игроков.)
new Level[ 33 ] , UserKills[ 33 ] , LevelNext[ 33 ], g_Money[ 33 ]
new MaxPlayers, TaskEnt, ShowSpeed
new bool:plrSpeed[33]
new const KEYSMENU = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
new const g_szSoundLevel[][] = { "Event_Levels/Level_Up.wav" }
// [ Start: MYSQL ]
new g_szQuery[ 2048 ] , szAuthID[ 33 ][ 32 ] ;
new Handle: g_hDBTuple , Handle: g_hConnect ;
new const szHost[ ] = "31.31.198.41" ,
szUser[ ] = "" ,
szPassword[ ] = "" ,
szDataBase[ ] = "" ,
szTableName[ ] = "Forze_Level_System"
// [ End: MYSQL ]
public plugin_init() {
register_plugin( PLUGIN , VERSION , AUTHOR )
register_forward(FM_Think, "Think")
TaskEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
set_pev(TaskEnt, pev_classname, "speedometer_think")
set_pev(TaskEnt, pev_nextthink, get_gametime() + 1.01)
RegisterHam( Ham_Killed , "player" , "Player_Killing" , 1 );
RegisterHam( Ham_Spawn , "player" , "Player_Spawn" , 1 );
register_menu( "Menu_1" , KEYSMENU , "ClCmd_Moneymenu" );
register_clcmd( "MoneyMenu" , "ClCmd_Moneymenunew" );
MaxPlayers = get_maxplayers();
ShowSpeed = register_cvar("showspeed", "1")
}
public plugin_natives() {
register_native( "SetUserLevel" , "NativeSetUserLevel" , 1 )
register_native( "GetUserLevel" , "NativeGetUserLevel" , 1 )
register_native( "SetUserNext" , "NativeSetUserNext" , 1 )
register_native( "GetUserNext" , "NativeGetUserNext" , 1 )
register_native( "GetUserGold" , "native_get_money" , 1 )
register_native( "SetUserGold" , "native_set_money" , 1 )
}
public plugin_precache() precache_sound( "Event_Levels/Level_Up.wav" )
public Think(ent)
{
if(ent == TaskEnt)
{
Info()
set_pev(ent, pev_nextthink, get_gametime() + 0.1)
}
}
public Player_Killing( victim , attacker )
{
if( !is_user_connected( attacker ) || Level[attacker] >= 100 )
return HAM_IGNORED
UserKills[attacker] += 1
g_Money[ attacker ] += random_num( 1 , 10 )
if(UserKills[attacker] >= LevelNext[attacker])
{
LevelNext[attacker] += TwoKill
Level[attacker] += 1
client_print( attacker , print_center , "Вы достигли %d уровня. Следующий через %d убийств" , Level[ attacker ] , LevelNext[ attacker ] )
UserKills[ attacker ] = 0
client_cmd( attacker , "spk %s" , g_szSoundLevel )
}
return PLUGIN_HANDLED;
}
public Player_Spawn( pPlayer )
{
if( !is_user_connected( pPlayer ) )
return;
set_task( 2.0 , "Check_Level" , pPlayer )
}
public Info()
{
static target
static Float:velocity[3]
static Float:speedh
for(new pPlayer = 0; pPlayer <= MaxPlayers; pPlayer++)
{
if(!is_user_bot(pPlayer) && is_user_connected(pPlayer) || (!plrSpeed[pPlayer]))
{
target = pev(pPlayer, pev_iuser1) == 4 ? pev(pPlayer, pev_iuser2) : pPlayer
pev(target, pev_velocity, velocity)
speedh = floatsqroot(floatpower(velocity[0], 2.0) + floatpower(velocity[1], 2.0))
set_hudmessage(0, 255, 0, -1.0, 0.89, 0, 0.0, 0.1, 0.01, 0.0)
if(Level [ pPlayer ] <= 99)
{
show_hudmessage( pPlayer , "Скорость: %3.2f^nЗолото: %d | Уровень: %d | Опыт: %i / %i" , speedh , g_Money[ pPlayer ], Level[ pPlayer ] , UserKills[ pPlayer ] , LevelNext[ pPlayer ] , UserKills[ pPlayer ] )
} else {
show_hudmessage( pPlayer , "Скорость: %3.2f^nЗолото: %d | Уровень: 100 | Максимум" , speedh, g_Money[ pPlayer ] )
}
}
}
return PLUGIN_CONTINUE
}
public Check_Level( pPlayer )
{
if( Level[ pPlayer ] < 1 )
{
Level[ pPlayer ] = 1
LevelNext[ pPlayer ] = OneKill
}
}
public ClCmd_Moneymenunew( pPlayer )
{
static menu[ 1048 ], len
len = 0
len += formatex( menu[ len ] , charsmax( menu ) - len , "\wВыдача золота^n^n" )
if( get_user_flags( pPlayer ) & ADMIN_CVAR )
len += formatex( menu[ len ] , charsmax( menu ) - len , "\y1. \wВыдать: \d[1000 золота]^n" )
else
len += formatex( menu[ len ] , charsmax( menu ) - len , "\y1. \dВыдать: \r[1000 золота]^n" )
len += formatex( menu[ len ] , charsmax( menu ) - len , "^n^n\y0. \wВыход" , pPlayer )
show_menu( pPlayer , KEYSMENU , menu , -1 , "Menu_1" );
}
public ClCmd_Moneymenu( pPlayer , key )
{
switch ( key )
{
case 0:
{
MenuPlayer( pPlayer )
}
}
return PLUGIN_HANDLED
}
public MenuPlayer( pPlayer )
{
if( get_user_flags( pPlayer ) & ADMIN_CVAR ) {
new i_Menu = menu_create( "\wВыбери игрока", "menu_handle" )
new s_Players[ 32 ], i_Num, i_Player
new s_Name[ 32 ], s_Player[ 10 ], text[ 128 ]
get_players( s_Players , i_Num )
for ( new i; i < i_Num; i++ )
{
i_Player = s_Players[ i ]
get_user_name( i_Player , s_Name , charsmax( s_Name ) )
num_to_str( i_Player , s_Player , charsmax( s_Player ) )
formatex( text , charsmax( text ) , "\w%s \y[\d%d\y]" , s_Name , g_Money[ i_Player ] )
menu_additem( i_Menu , text , s_Player , 0 )
}
menu_setprop( i_Menu, MPROP_EXITNAME , "Выход" )
menu_setprop( i_Menu, MPROP_NEXTNAME , "Далее" )
menu_setprop( i_Menu, MPROP_BACKNAME , "Назад" )
menu_display( pPlayer , i_Menu , 0 )
} else
client_print( pPlayer , print_center , "НЕТ ДОСТУПА." )
}
public menu_handle( pPlayer , menu , item )
{
if ( item == MENU_EXIT )
{
menu_destroy( menu )
return PLUGIN_HANDLED
}
new s_Data[ 6 ] , s_Name[ 64 ] , i_Access , i_Callback
menu_item_getinfo( menu , item , i_Access , s_Data , charsmax( s_Data ) , s_Name , charsmax( s_Name ) , i_Callback )
new i_Player = str_to_num( s_Data )
g_Money[ i_Player ] += 1000
client_print( i_Player , print_center , "Вы получили 1000 золота." )
menu_destroy( menu )
return PLUGIN_HANDLED
}
// [ Start: MYSQL ]
public plugin_cfg( ) {
new szError[ 512 ] , iErrorCode;
g_hDBTuple = SQL_MakeDbTuple ( szHost , szUser , szPassword , szDataBase );
g_hConnect = SQL_Connect( g_hDBTuple , iErrorCode , szError , charsmax( szError ) );
if ( g_hConnect == Empty_Handle )
set_fail_state( szError );
if ( !SQL_TableExists( g_hConnect , szTableName ) ) {
new Handle: Queries;
new Query [ 1024 ];
format( Query , 1023 , "CREATE TABLE `%s` (AuthID VARCHAR(40) CHARACTER SET cp1250 COLLATE cp1250_general_ci NOT NULL, Money INT NOT NULL, Level INT NOT NULL, Kills INT NOT NULL, NextKills INT NOT NULL, PRIMARY KEY (AuthID))" , szTableName );
Queries = SQL_PrepareQuery( g_hConnect, Query );
if ( !SQL_Execute( Queries ) ) {
SQL_QueryError( Queries , szError ,charsmax( szError ) );
set_fail_state( szError );
}
SQL_FreeHandle ( Queries );
}
SQL_QueryAndIgnore( g_hConnect , "SET NAMES utf8" );
}
public plugin_end ( ) {
if( g_hDBTuple ) SQL_FreeHandle( g_hDBTuple );
if( g_hConnect ) SQL_FreeHandle( g_hConnect );
return;
}
public client_putinserver( pPlayer )
{
new iParams [ 1 ]; iParams [ 0 ] = pPlayer;
get_user_authid( pPlayer, szAuthID [ pPlayer ] , charsmax( szAuthID[ ] ) );
plrSpeed[pPlayer] = ShowSpeed > 0 ? true : false
format( g_szQuery , charsmax( g_szQuery ) ,
"SELECT * FROM `%s` WHERE ( `%s`.`AuthID` = '%s' )", szTableName , szTableName , szAuthID [ pPlayer ]
);
SQL_ThreadQuery( g_hDBTuple, "SQL_QueryConnection", g_szQuery, iParams, sizeof iParams );
}
public client_disconnect( pPlayer ) {
format( g_szQuery , charsmax( g_szQuery ),
"UPDATE `%s` SET `Money` = '%d' , `Level` = '%i' , `Kills` = '%i' , `NextKills` = '%i' WHERE `%s`.`AuthID` = '%s';",
szTableName , g_Money[ pPlayer ] , Level[ pPlayer ] , UserKills[ pPlayer ] , LevelNext[ pPlayer ] , szTableName , szAuthID [ pPlayer ]
);
SQL_ThreadQuery( g_hDBTuple, "ThreadQueryHandler", g_szQuery );
}
public SQL_QueryConnection ( iState , Handle: hQuery , szError [ ] , iErrcode , iParams [ ] , iParamsSize ) {
switch ( iState ) {
case TQUERY_CONNECT_FAILED: log_amx ( "Load - Could not connect to SQL database. [%d] %s" , iErrcode , szError );
case TQUERY_QUERY_FAILED: log_amx ( "Load Query failed. [%d] %s" , iErrcode , szError );
}
new pPlayer = iParams[ 0 ];
if ( SQL_NumResults( hQuery ) < 1 ) {
if ( equal( szAuthID [ pPlayer ] , "ID_PENDING" ) )
return PLUGIN_HANDLED;
Level [ pPlayer ] = 0;
g_Money [ pPlayer ] = 0;
format(
g_szQuery , charsmax( g_szQuery ),
"INSERT INTO `%s` ( `AuthID` , `Money` , `Level` , `Kills` , `NextKills` ) VALUES ( '%s' , '%d' , '%i' , '%i' , '%i' );",
szTableName , szAuthID [ pPlayer ] , g_Money[ pPlayer ] , Level [ pPlayer ] , UserKills [ pPlayer ] , LevelNext [ pPlayer ]
);
SQL_ThreadQuery( g_hDBTuple , "ThreadQueryHandler" , g_szQuery );
return PLUGIN_HANDLED;
}
else {
g_Money [ pPlayer ] = SQL_ReadResult ( hQuery , 1 );
Level [ pPlayer ] = SQL_ReadResult ( hQuery , 2 );
UserKills [ pPlayer ] = SQL_ReadResult ( hQuery , 3 );
LevelNext [ pPlayer ] = SQL_ReadResult ( hQuery , 4 );
}
return PLUGIN_HANDLED;
}
public ThreadQueryHandler( iState , Handle: hQuery , szError [ ], iError , iParams [ ] , iParamsSize ) {
if ( iState == 0 )
return;
log_amx( "SQL Error: %d (%s)" , iError , szError );
}
stock bool: SQL_TableExists ( Handle: db , const szTable [ ] ) {
new Handle: query = SQL_PrepareQuery ( db , "SELECT * FROM information_schema.tables WHERE table_name = '%s' LIMIT 1;" , szTable );
new g_Error [ 512 ];
if ( !SQL_Execute ( query ) ) {
SQL_QueryError ( query , g_Error , charsmax ( g_Error ) );
set_fail_state ( g_Error );
}
else if ( !SQL_NumResults ( query ) ){
SQL_FreeHandle ( query );
return false;
}
SQL_FreeHandle ( query );
return true;
}
public NativeSetUserLevel( pPlayer , iValue ) {
Level [ pPlayer ] = iValue;
format( g_szQuery , charsmax( g_szQuery ) , "UPDATE `%s` SET `Level` = '%i' WHERE `%s`.`AuthID` = '%s';", szTableName, Level [ pPlayer ] , szTableName , szAuthID [ pPlayer ] );
SQL_ThreadQuery( g_hDBTuple , "ThreadQueryHandler" , g_szQuery );
}
public NativeSetUserNext( pPlayer , iValue ) {
LevelNext [ pPlayer ] = iValue;
format( g_szQuery , charsmax( g_szQuery ) , "UPDATE `%s` SET `LevelNext` = '%i' WHERE `%s`.`AuthID` = '%s';", szTableName, LevelNext [ pPlayer ] , szTableName , szAuthID [ pPlayer ] );
SQL_ThreadQuery( g_hDBTuple , "ThreadQueryHandler" , g_szQuery );
}
public native_set_money( pPlayer , num )
{
g_Money[ pPlayer ] = num
}
public NativeGetUserNext( pPlayer ) {
return LevelNext[ pPlayer ];
}
public NativeGetUserLevel( pPlayer ) {
return Level[ pPlayer ];
}
public native_get_money( pPlayer )
{
return g_Money[ pPlayer ]
}
// [ End: MYSQL ]
Проблема заключается в том, что у некоторых игроков сбрасывается опыт и другие данные занесенные в базу mysql. Сначала думал, что столбцы дублируются с новыми данными уже, но нет, при поиске нашел только один столбец с тем SteamID игрока, у которого был сброс, точно уверяю, что у игрока SteamID (STEAM_0:0:14614951) не менялся, у него куплена привилегия на данный айди, а также это стим версия кс. И могу уверять, что уровень у игрока был максимальный, а сейчас стал 4, он его за это время апнул.
Прикладываю исходник плагина уровневой системы, таблицу в которой была перезапись данных в столбцах.
Прикладываю исходник плагина уровневой системы, таблицу в которой была перезапись данных в столбцах.
В этой теме было размещено решение! Перейти к решению.
Вложения
-
694.6 KB Просмотры: 321