Ошибка с плагином ножей

Сообщения
14
Реакции
-1
Ошибка
L 01/22/2022 - 17:29:31: Info (map "35hp_lava") (file "addons/amxmodx/logs/error_20220122.log")
L 01/22/2022 - 17:29:31: [HAMSANDWICH] Entity out of range (-1)
L 01/22/2022 - 17:29:31: [AMXX] Displaying debug trace (plugin "ctpax_knife_manager.amxx", version "0.3")
L 01/22/2022 - 17:29:31: [AMXX] Run time error 10: native error (native "ExecuteHamB")
L 01/22/2022 - 17:29:31: [AMXX] [0] ctpax_knife_manager.sma::Close_KnifeMenu (line 182)
ОС
Linux
Amx Mod X
AMX Mod X 1.9.0.5294 (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: Dec 3 2021 15:54:56
Built from: https://github.com/alliedmodders/amxmodx/commit/363871a
Build ID: 5294:363871a
Core mode: JIT+ASM32
Билд
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.11.0.767-dev
Build date: 16:15:06 Oct 28 2021 (2756)
Build from: https://github.com/dreamstalker/rehlds/commit/471158b
ReGamedll
ReGameDLL version: 5.21.0.540-dev
Build date: 17:33:16 Oct 25 2021
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/b9cccc6
Версия 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] Reunion RUN - reunion.so v0.1.92d ini Start Never
[ 2] VoiceTranscoder RUN - VoiceTranscoder.so v2017RC5 ini ANY ANY
[ 3] AMX Mod X RUN - amxmodx.so v1.9.0.5294 ini Start ANY
[ 4] ReSemiclip RUN - resemiclip.so v2.3.9 ini Chlvl ANY
[ 5] Rechecker RUN - rechecker.so v2.7 ini Chlvl ANY
[ 6] ReAuthCheck RUN - reauthcheck.so v0.1.6 ini Start Never
[ 7] ReSRDetector RUN - resrdetector.so v0.1.0 ini Chlvl ANY
[ 8] <whblocker_mm.so> badf - whblocker_mm.so v - ini - -
[ 9] CStrike RUN - cstrike_amxx_i386.so v1.9.0.5294 pl3 ANY ANY
[10] CSX RUN - csx_amxx_i386.so v1.9.0.5294 pl3 ANY ANY
[11] MySQL RUN - mysql_amxx_i386.so v1.9.0.5294 pl3 ANY ANY
[12] SQLite RUN - sqlite_amxx_i386.so v1.9.0.5294 pl3 ANY ANY
[13] ReAPI RUN - reapi_amxx_i386.so v5.21.0.248-dev pl3 ANY Never
[14] FakeMeta RUN - fakemeta_amxx_i386.so v1.9.0.5294 pl3 ANY ANY
[15] Ham Sandwich RUN - hamsandwich_amxx_i386.so v1.9.0.5294 pl3 ANY ANY
[16] ReAimDetector RUN - reaimdetector_amxx_i386.so v0.2.2 pl3 ANY Never
[17] Fun RUN - fun_amxx_i386.so v1.9.0.5294 pl3 ANY ANY
[18] Engine RUN - engine_amxx_i386.so v1.9.0.5294 pl3 ANY ANY
18 plugins, 17 running
Список плагинов
Currently loaded plugins:
name version author file status
[ 1] GameCMS_GagManager 2.2.7 ReAp zhorzh78 gamecms_gagmana running
[ 2] GameCMS_API 5.5.3 zhorzh78 gamecms_api.amx running
[ 3] CSStatsX SQL 0.7.4+2 serfreeman1337 csstatsx_sql.am debug
[ 4] FreshBans 1.4.6b kanagava fresh_bans.amxx running
[ 5] WebHS 0.1 kanagava fb_web_online.a running
[ 6] Admin Commands 1.9.0.5294 AMXX Dev Team admincmd.amxx running
[ 7] Slots Reservation 1.9.0.5294 AMXX Dev Team adminslots.amxx running
[ 8] Commands Menu 1.9.0.5294 AMXX Dev Team cmdmenu.amxx running
[ 9] Players Menu 1.2 O.Hooligan plmenu.amxx running
[ 10] NextMap 1.9.0.5235 AMXX Dev Team nextmap.amxx running
[ 11] Maps Menu 1.0 O.Hooligan mapsmenu.amxx running
[ 12] Plugin Menu 1.9.0.5294 AMXX Dev Team pluginmenu.amxx running
[ 13] Admin Chat 1.9.0.5294 AMXX Dev Team adminchat.amxx running
[ 14] Scrolling Message 1.9.0.5294 AMXX Dev Team scrollmsg.amxx running
[ 15] Info. Messages 1.9.0.5294 AMXX Dev Team imessage.amxx running
[ 16] Admin Votes 1.9.0.5294 AMXX Dev Team adminvote.amxx running
[ 17] Pause Plugins 1.9.0.5294 AMXX Dev Team pausecfg.amxx running
[ 18] Stats Configuration 1.9.0.5294 AMXX Dev Team statscfg.amxx running
[ 19] AES: StatsX 0.5.9 [REA serfreeman1337/s aes_statsx.amxx running
[ 20] StatsX 1.9.0.5294 AMXX Dev Team statsx.amxx running
[ 21] GameCMS_VipTest 3.8.1 zhorzh78 gamecms_viptest running
[ 22] GameCMS BonusSystem 1.1 +- DUKKHAZ0R gamecms_bonus.a running
[ 23] Hooligan VoteBan 1.4 cTpAx ctpax_voteban.a running
[ 24] Kill Assist 1.17 cTpAx ctpax_kill_assi running
[ 25] Hooligan Vampire 1.2 cTpAx ctpax_vampire.a running
[ 26] Ping 1.1 cTpAx ctpax_ping.amxx running
[ 27] Translit 1.0 cTpAx ctpax_translit. running
[ 28] Knife Duel 1.2 cTpAx ctpax_duel.amxx running
[ 29] Nice Voice 2.0 R cTpAx ctpax_voice.amx running
[ 30] MapChooser 2.9 cTpAx ctpax_map_choos debug
[ 31] cTpAx KillStreak 0.7 cTpAx ctpax_sound_kil running
[ 32] VIP 1.5 cTpAx ctpax_vipmenu.a running
[ 33] Menu 1.0 cTpAx ctpax_menu.amxx running
[ 34] Menu 1.0 cTpAx ctpax_cabinet.a running
[ 35] Menu 1.0 cTpAx ctpax_menupriv. running
[ 36] AmxModMenu 1.2 cTpAx ctpax_adminmenu running
[ 37] Knife Manager 0.3 cTpAx ctpax_knife_man debug
[ 38] TeamBalancer 1.20 cTpAx ctpax_balancer. running
[ 39] Warn Menu 0.1 cTpAx ctpax_warn_menu running
[ 40] GreetingMenu 1.0 cTpAx ctpax_ng.amxx running
[ 41] Damager 1.0 cTpAx ctpax_damager.a running
[ 42] Free ammo 1.4 cTpAx ctpax_ammo.amxx running
[ 43] recoil_manager 1.0 cTpAx ctpax_recoil.am running
[ 44] Frags Counter 1.0 cTpAx ctpax_frags.amx running
[ 45] [GTX] Healthnade 1.0 cTpAx ctpax_healthnad running
[ 46] cTpAx Admin ESP 1.0 cTpAx ctpax_esp.amxx running
[ 47] [GTX] Flash 1.0 cTpAx ctpax_antiflesh running
[ 48] CMS_GM_Sorry_Addon 1.0 sorry.amxx running
[ 49] Reset Score 0.2 Silenttt / CepeH rs.amxx running
[ 50] Parachute 1.0 maeStro parachute.amxx running
[ 51] lite screen fade 1.0 AcE lite_screen_fad running
[ 52] kill_knife_money 1.0 IntelCom knife_kill_mone running
[ 53] Killa HP 1.6 jas0n killa_hp.amxx running
[ 54] User Connect 0.1.1 Jumper connect_priv.am running
[ 55] Autoresponder/Advertis 0.5 MaximusBrood reklama_in_chat running
[ 56] XMAS Skybox 1.0 SeMax xmas_sky.amxx running
[ 57] [ReAPI] AWPoff 1.4.3 PAffAEJIkA :3 awp_off.amxx stopped
[ 58] Afk Control 0.5.1 neygomon afk_control.amx running
[ 59] AES: Status Info 0.1 serfreeman1337 aes_status_info running
[ 60] DemoRecoder 1.1 neygomon demka.amxx running
[ 61] SITE 1.0 O.Hooligan site.amxx running
[ 62] Block grande info 1.0 O.Hooligan BlockGrenadeInf running
[ 63] Top Round Damage 1.0.4 ReAP Dager* *.* -G- top_damage.amxx running
[ 64] [ReAPI] Custom Models 1.6.1 neugomon custom_models.a running
[ 65] Santa Hat + Snow 1.3 xPaw SantaHat.amxx running
[ 66] CSS C4 [Disabled] 0.0.1 Vaqtincha c4_ng.amxx paused
[ 67] NY Kill Sprite 1.0 O.Hooligan ng_sprite.amxx running
[ 68] ReAimDetector API 0.2.2 ReHLDS Team reaimdetector.a running
[ 69] Mode 2x2 2.5re s1lent mode2x2.amxx running
[ 70] Advanced Experience Sy 0.5.9 [REA serfreeman1337/s aes_main.amxx running
[ 71] AES: CStrike Addon 0.5.9 [REA serfreeman1337/s aes_exp_cstrike running
[ 72] AES: Informer 0.5.9 [REA serfreeman1337/s aes_informer.am running
[ 73] AES: Admin Tools 0.5.9 [REA serfreeman1337/s aes_exp_editor. running
[ 74] AES: Bonus System 0.5.9 Vega serfreeman1337/s aes_bonus_syste stopped
[ 75] AES: Bonus CSTRIKE 0.5.9.1 [R serfreeman1337/s aes_bonus_cstri stopped
75 plugins, 71 running
Автор плагина
Основа с инета, потом сам дописывал его
Версия плагина
0.5
Исходный код
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#include <sqlx>
#define INFO_CHAT

//const MAX_PLAYERS = 32;
const MAX_NUMBER_PAGE = 8;
new Array:g_aKnifes;
new g_iKnifesSize;
new g_iUserKnife[MAX_PLAYERS];
new g_iMenuPosition[MAX_PLAYERS];
new MODEL_V1[33][128];
new MODEL_P1[33][128];
new g_EmptyUser[33];
new g_EmptyUserChange[33];

enum _:DATA_LOAD
{
KNIFE_NAME[64],
KNIFE_MODEL_V[128],
KNIFE_MODEL_P[128],
KNIFE_FLAG[2]
};
new Handle:SQL_Tuple
new Handle:SQL_Connection
public plugin_init(){
register_plugin("Knife Manager","0.3","cTpAx");
register_clcmd("say /knife","Cmd_KnifeMenu");
RegisterHam(Ham_Item_Deploy, "weapon_knife", "Ham_KnifeDeploy", true);
register_menucmd(register_menuid("Open_KnifeMenu"), 1023, "Close_KnifeMenu");

register_cvar("SQLx_host","db4.myarena.ru")
register_cvar("SQLx_db","u26550_redbull")
register_cvar("SQLx_user","u26550_redbull")
register_cvar("SQLx_password","redbull8213")
}
public plugin_cfg(){
new host[33],dbase[33],user[33],pass[33]
get_cvar_string("SQLx_host",host,30)
get_cvar_string("SQLx_db",dbase,30)
get_cvar_string("SQLx_user",user,30)
get_cvar_string("SQLx_password",pass,30)
SQL_Tuple = SQL_MakeDbTuple(host,user,pass,dbase)
new err, error[256];
SQL_Connection = SQL_Connect(SQL_Tuple, err, error, charsmax(error))
if(SQL_Connection != Empty_Handle)
{
log_amx("[SQLx connect ok]") //Если соединение установлено
}else{
log_amx("[SQLX sql error] %s ",error) //Если нет и выводим причину(ошибку)
pause("a")
}
}
public client_putinserver(id)
{
Load_MySql(id)
}
public plugin_precache() LOADING_INI();

LOADING_INI(){
new szCfgDir[64], szCfgFile[128];
get_localinfo("amxx_configsdir", szCfgDir, charsmax(szCfgDir));

formatex(szCfgFile, charsmax(szCfgFile), "%s/ctpax_knife.ini", szCfgDir);
if(!file_exists(szCfgFile))
{
write_file(szCfgFile, ";# Файл менеджера ножей: ctpax_knife.ini");
write_file(szCfgFile, ";# (c) cTpAx 2022");
write_file(szCfgFile, ";#");
write_file(szCfgFile, ";# Пример добавления ножа");
write_file(szCfgFile, ";# ^"Название в меню^" ^"Модель V^" ^"Модель P^" ^"Флаг доступа^"");
write_file(szCfgFile, ";#");
write_file(szCfgFile, ";# Список ножей");
write_file(szCfgFile, "^"Стандартный^" ^"models/v_knife.mdl^" ^"models/p_knife.mdl^" ^"^"");
}
new GetArrayDataRead[DATA_LOAD], szBuffer[256], iLine, iLen;
g_aKnifes = ArrayCreate(DATA_LOAD);
while(read_file(szCfgFile, iLine++, szBuffer, charsmax(szBuffer), iLen))
{
if(!iLen || szBuffer[0] == ';') continue;
parse
(
szBuffer,
GetArrayDataRead[KNIFE_NAME], charsmax(GetArrayDataRead[KNIFE_NAME]),
GetArrayDataRead[KNIFE_MODEL_V], charsmax(GetArrayDataRead[KNIFE_MODEL_V]),
GetArrayDataRead[KNIFE_MODEL_P], charsmax(GetArrayDataRead[KNIFE_MODEL_P]),
GetArrayDataRead[KNIFE_FLAG], charsmax(GetArrayDataRead[KNIFE_FLAG])
);
engfunc(EngFunc_PrecacheModel, GetArrayDataRead[KNIFE_MODEL_V]);
engfunc(EngFunc_PrecacheModel, GetArrayDataRead[KNIFE_MODEL_P]);
ArrayPushArray(g_aKnifes, GetArrayDataRead);
}
g_iKnifesSize = ArraySize(g_aKnifes);
}

public Cmd_KnifeMenu(id) return Open_KnifeMenu(id,g_iMenuPosition[id] = 0);
Open_KnifeMenu(id, iPos)
{
if(iPos < 0) return PLUGIN_HANDLED;
new iStart = iPos * MAX_NUMBER_PAGE;
if(iStart > g_iKnifesSize) iStart = g_iKnifesSize;
iStart = iStart - (iStart % MAX_NUMBER_PAGE);
g_iMenuPosition[id] = iStart / MAX_NUMBER_PAGE;
new iEnd = iStart + MAX_NUMBER_PAGE;
if(iEnd > g_iKnifesSize) iEnd = g_iKnifesSize;
new szMenu[512], iLen, iPagesNum = (g_iKnifesSize / MAX_NUMBER_PAGE + ((g_iKnifesSize % MAX_NUMBER_PAGE) ? 1 : 0));
new iBitKeys = (1<<9), b;
iLen = formatex(szMenu, charsmax(szMenu), "\wВыбор ножа \r[%d|%d]^n^n", iPos + 1, iPagesNum);

for(new a = iStart; a < iEnd; a++)
{
new GetArrayData[DATA_LOAD];
ArrayGetArray(g_aKnifes, a, GetArrayData);

if(GetArrayData[KNIFE_FLAG]){
if(get_user_flags(id) & read_flags(GetArrayData[KNIFE_FLAG])){
if(g_iUserKnife[id] != a){
iBitKeys |= (1<<b);
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w%d\r] \w%s^n", ++b, GetArrayData[KNIFE_NAME]);

}else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[\rNO\d] %s^n", GetArrayData[KNIFE_NAME]), ++b;
}else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[\rNO\d] %s \r[Нет прав]^n", GetArrayData[KNIFE_NAME]), ++b;
}else{
if(g_iUserKnife[id] != a){
iBitKeys |= (1<<b);
iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\r[\w%d\r] \w%s^n", ++b, GetArrayData[KNIFE_NAME]);
}else iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "\d[\rNO\d] %s^n", GetArrayData[KNIFE_NAME]), ++b;
}
}
for(new i = b; i < MAX_NUMBER_PAGE; i++) iLen += formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n");
if(iEnd < g_iKnifesSize)
{
iBitKeys |= (1<<8);
formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n\r[\w9\r] \wДальше^n\r[\w0\r] \w%s", iPos ? "Назад" : "Выход");
}
else formatex(szMenu[iLen], charsmax(szMenu) - iLen, "^n^n\r[\w0\r] \w%s", iPos ? "Назад" : "Выход");
return show_menu(id, iBitKeys, szMenu, -1, "Open_KnifeMenu");
}

public Close_KnifeMenu(id, iKey)
{
switch(iKey)
{
case 8: return Open_KnifeMenu(id, ++g_iMenuPosition[id]);
case 9: return Open_KnifeMenu(id, --g_iMenuPosition[id]);
default:
{
new GetArrayData[DATA_LOAD];
static iSelect; iSelect = g_iMenuPosition[id] * MAX_NUMBER_PAGE + iKey;
ArrayGetArray(g_aKnifes, iSelect, GetArrayData);
g_iUserKnife[id] = iSelect;
engclient_cmd(id, "weapon_knife");
static iActiveItem; iActiveItem = get_pdata_cbase(id, 373, 5);
if(iActiveItem > 0)
#if defined INFO_CHAT
replace_all(GetArrayData[KNIFE_NAME], charsmax(GetArrayData[KNIFE_NAME]), "\r", "");
replace_all(GetArrayData[KNIFE_NAME], charsmax(GetArrayData[KNIFE_NAME]), "\w", "");
replace_all(GetArrayData[KNIFE_NAME], charsmax(GetArrayData[KNIFE_NAME]), "\y", "");
chat(id,"!g[Сервер] !yВы взяли: %s!", GetArrayData[KNIFE_NAME]);
client_cmd(id, "say /knife","Cmd_KnifeMenu");
new steam[32];
get_user_authid(id, steam, 31)
new Handle:Query = SQL_PrepareQuery(SQL_Connection,"SELECT * FROM `ctpax_knife` WHERE steamid = '%s'",steam)
if(!SQL_Execute(Query))
{
new Error[128]
SQL_QueryError(Query, Error, charsmax(Error))
log_to_file("mysqlt.log", "[DB_Create_Table] %s", Error);
SQL_FreeHandle(Query)
return PLUGIN_HANDLED;
}
if( SQL_NumResults(Query) > 0 )
{
SQL_ReadResult(Query, 2, MODEL_V1[id], charsmax(MODEL_V1[]))
SQL_ReadResult(Query, 3, MODEL_P1[id], charsmax(MODEL_P1[]))
new query[256],data[2];
format(query,charsmax(query),"UPDATE `ctpax_knife` SET `steamid`='%s',`v_model`='%s',`p_model`='%s' WHERE steamid = '%s'",steam,GetArrayData[KNIFE_MODEL_V],GetArrayData[KNIFE_MODEL_P],steam);
SQL_ThreadQuery(SQL_Tuple,"QueryHandler",query,data,charsmax(data))
g_EmptyUserChange[id] = 1
ExecuteHamB(Ham_Item_Deploy, iActiveItem);
}
else
{
new query[256],data[2];
format(query,charsmax(query),"INSERT INTO `ctpax_knife`(`steamid`, `v_model`, `p_model`) VALUES ('%s','%s','%s')",steam,GetArrayData[KNIFE_MODEL_V],GetArrayData[KNIFE_MODEL_P]);
SQL_ThreadQuery(SQL_Tuple,"QueryHandler",query,data,charsmax(data))
g_EmptyUserChange[id] = 1
ExecuteHamB(Ham_Item_Deploy, iActiveItem);
}
SQL_FreeHandle(Query)
ExecuteHamB(Ham_Item_Deploy, iActiveItem);
#endif
}
}
return PLUGIN_HANDLED;
}

public Ham_KnifeDeploy(iEntity)
{
new steam[32];
static id; id = get_pdata_cbase(iEntity, 41, 4)
get_user_authid(id, steam, 31)
static id2; id2 = get_pdata_cbase(iEntity, 41, 4)
if(g_EmptyUserChange[id] > 0){
new GetArrayData[DATA_LOAD];
ArrayGetArray(g_aKnifes, g_iUserKnife[id], GetArrayData);
set_pev(id, pev_viewmodel2, GetArrayData[KNIFE_MODEL_V]);
set_pev(id, pev_weaponmodel2, GetArrayData[KNIFE_MODEL_P]);
}else{

if(g_EmptyUser[id] > 0){
set_pev(id2, pev_viewmodel2, MODEL_V1[id])
set_pev(id2, pev_weaponmodel2, MODEL_P1[id])
}
else{
new GetArrayData[DATA_LOAD];
ArrayGetArray(g_aKnifes, g_iUserKnife[id], GetArrayData);
set_pev(id, pev_viewmodel2, GetArrayData[KNIFE_MODEL_V]);
set_pev(id, pev_weaponmodel2, GetArrayData[KNIFE_MODEL_P]);
}
}
return HAM_IGNORED;
}
#if defined INFO_CHAT
stock chat(pPlayer, const szMessage[], any:...){
new szBuffer[190];
if(numargs() > 2) vformat(szBuffer, charsmax(szBuffer), szMessage, 3);
else copy(szBuffer, charsmax(szBuffer), szMessage);
while(replace(szBuffer, charsmax(szBuffer), "!y", "^1")) {}
while(replace(szBuffer, charsmax(szBuffer), "!t", "^3")) {}
while(replace(szBuffer, charsmax(szBuffer), "!g", "^4")) {}
switch(pPlayer)
{
case 0:
{
for(new iPlayer = 1; iPlayer <= get_maxplayers(); iPlayer++)
{
if(!is_user_connected(iPlayer)) continue;
engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, 76, {0.0, 0.0, 0.0}, iPlayer);
write_byte(iPlayer);
write_string(szBuffer);
message_end();
}
}
default:
{
engfunc(EngFunc_MessageBegin, MSG_ONE_UNRELIABLE, 76, {0.0, 0.0, 0.0}, pPlayer);
write_byte(pPlayer);
write_string(szBuffer);
message_end();
}
}
}
#endif

public QueryHandler(FailState, Handle:Query, error[], err, data[], size, Float:querytime){

if(FailState != TQUERY_SUCCESS)
{
log_amx("sql error: %d (%s)", err, error)
return

}



}
public plugin_end(){
SQL_FreeHandle(SQL_Connection)
}
public client_disconnected(id)
{

}

public Load_MySql(id)
{
new sAuthID[32];
new szTemp[512];
get_user_authid(id, sAuthID, charsmax(sAuthID));

new Data[1];
Data[0] = id;

format(szTemp, charsmax(szTemp), "SELECT * FROM `ctpax_knife` WHERE (`ctpax_knife`.`steamid` = '%s')", sAuthID);

SQL_ThreadQuery(SQL_Tuple, "registration_client", szTemp, Data, 1);
}

public registration_client(FailState, Handle:Query, Error[], Errcode, Data[], DataSize)
{
if (FailState == TQUERY_CONNECT_FAILED)
{
log_amx("Load - Could not connect to SQL database. [%d] %s", Errcode, Error);
}
else if (FailState == TQUERY_QUERY_FAILED)
{
log_amx("Load Query failed. [%d] %s", Errcode, Error);
}

new id;
id = Data[0];
new GetArrayData[DATA_LOAD];
static iSelect;
ArrayGetArray(g_aKnifes, iSelect, GetArrayData);
g_iUserKnife[id] = iSelect;

if (SQL_NumResults(Query) < 1)
{
new sAuthID[32];
new szTemp[512];

get_user_authid(id, sAuthID, charsmax(sAuthID));

format(szTemp, charsmax(szTemp), "INSERT INTO `ctpax_knife` ( `steamid` , `v_model`,`p_model`)VALUES ('%s','%s','%s')", sAuthID,GetArrayData[KNIFE_MODEL_V],GetArrayData[KNIFE_MODEL_P]);
SQL_ThreadQuery(SQL_Tuple, "QueryHandler", szTemp);
}
else
{
SQL_ReadResult(Query, 2, MODEL_V1[id], charsmax(MODEL_V1[]))
SQL_ReadResult(Query, 3, MODEL_P1[id], charsmax(MODEL_P1[]))

if(checkin_model(id, MODEL_V1[id], MODEL_P1[id]))
g_EmptyUser[id] = 1

}
SQL_FreeHandle(Query)
}

stock checkin_model(id, V_MODEL[], P_MODEL[])
{
#pragma unused id
new GetArrayData[DATA_LOAD];
for(new i; i < ArraySize(g_aKnifes); i++)
{
ArrayGetArray(g_aKnifes, i, GetArrayData);

if(equal(V_MODEL, GetArrayData[KNIFE_MODEL_V]) && equal(P_MODEL, GetArrayData[KNIFE_MODEL_P]))
return true;
}
return false;
}
Помогите поправить код чтоб не было ошибки, не могу понять что не так
 
Сообщения
3,579
Реакции
1,569
Помог
137 раз(а)
Подсказка: нужно дополнить проверку на 156 строке.
 
Сообщения
75
Реакции
36
Помог
4 раз(а)
А ещё это убрал бы

register_cvar("SQLx_host","db4.myarena.ru")
register_cvar("SQLx_db","u26550_redbull")
register_cvar("SQLx_user","u26550_redbull")
register_cvar("SQLx_password","redbull8213")
 
Сообщения
673
Реакции
242
Помог
11 раз(а)
проверка if(iActiveItem > 0) не коректен

Код:
public Close_KnifeMenu(id, iKey)
{
    switch(iKey)
    {
        case 8: return Open_KnifeMenu(id, ++g_iMenuPosition[id]);
        case 9: return Open_KnifeMenu(id, --g_iMenuPosition[id]);
    default:
    {
        new GetArrayData[DATA_LOAD];
        static iSelect; iSelect = g_iMenuPosition[id] * MAX_NUMBER_PAGE + iKey;
        ArrayGetArray(g_aKnifes, iSelect, GetArrayData);
        g_iUserKnife[id] = iSelect;
        engclient_cmd(id, "weapon_knife");
        static iActiveItem; iActiveItem = get_pdata_cbase(id, 373, 5);
        
        #if defined INFO_CHAT
        replace_all(GetArrayData[KNIFE_NAME], charsmax(GetArrayData[KNIFE_NAME]), "\r", "");
        replace_all(GetArrayData[KNIFE_NAME], charsmax(GetArrayData[KNIFE_NAME]), "\w", "");
        replace_all(GetArrayData[KNIFE_NAME], charsmax(GetArrayData[KNIFE_NAME]), "\y", "");
        chat(id,"!g[Сервер] !yВы взяли: %s!", GetArrayData[KNIFE_NAME]);
        client_cmd(id, "say /knife","Cmd_KnifeMenu");
        new steam[32];
        get_user_authid(id, steam, 31)
        new Handle:Query = SQL_PrepareQuery(SQL_Connection,"SELECT * FROM `ctpax_knife` WHERE steamid = '%s'",steam)
        if(!SQL_Execute(Query))
        {
        new Error[128]
        SQL_QueryError(Query, Error, charsmax(Error))
        log_to_file("mysqlt.log", "[DB_Create_Table]  %s", Error);
        SQL_FreeHandle(Query)
        return PLUGIN_HANDLED;
        }
        if( SQL_NumResults(Query) > 0 )
        {
        SQL_ReadResult(Query, 2, MODEL_V1[id], charsmax(MODEL_V1[]))
        SQL_ReadResult(Query, 3, MODEL_P1[id], charsmax(MODEL_P1[]))
        new query[256],data[2];
        format(query,charsmax(query),"UPDATE `ctpax_knife` SET `steamid`='%s',`v_model`='%s',`p_model`='%s' WHERE steamid = '%s'",steam,GetArrayData[KNIFE_MODEL_V],GetArrayData[KNIFE_MODEL_P],steam);
        SQL_ThreadQuery(SQL_Tuple,"QueryHandler",query,data,charsmax(data))
        g_EmptyUserChange[id] = 1
        if(iActiveItem > 0 && get_user_weapon(id) == CSW_KNIFE)
        {
            ExecuteHamB(Ham_Item_Deploy, iActiveItem);
        }
        }
        else
        {           
        new query[256],data[2];
        format(query,charsmax(query),"INSERT INTO `ctpax_knife`(`steamid`, `v_model`, `p_model`) VALUES ('%s','%s','%s')",steam,GetArrayData[KNIFE_MODEL_V],GetArrayData[KNIFE_MODEL_P]);
        SQL_ThreadQuery(SQL_Tuple,"QueryHandler",query,data,charsmax(data))
        g_EmptyUserChange[id] = 1
        if(iActiveItem > 0 && get_user_weapon(id) == CSW_KNIFE)
        {
            ExecuteHamB(Ham_Item_Deploy, iActiveItem);
        }
        }
        SQL_FreeHandle(Query)
        if(iActiveItem > 0 && get_user_weapon(id) == CSW_KNIFE)
        {
            ExecuteHamB(Ham_Item_Deploy, iActiveItem);
        }
        #endif
        }
    }
    return PLUGIN_HANDLED;
}
 
Сообщения
3,579
Реакции
1,569
Помог
137 раз(а)
Nezox2828, if(iActiveItem != 0 && iActiveItem != FM_NULLENT)
 
Последнее редактирование:
Сообщения
333
Реакции
290
Помог
9 раз(а)
Nordic Warrior, Ну если больше 0, то уже точно не равен -1. Или я чего-то не знаю...
 
Сообщения
3,579
Реакции
1,569
Помог
137 раз(а)
zhorzh78, точно, поправил.
27 Янв 2022
Вообще, я не внимательно посмотрел код, там просто кто-то фигурную скобку потерял.
Код:
        if(iActiveItem > 0)
+       {
Закрывающая на 195 стр.
 
Сообщения
14
Реакции
-1
@Limbooc,При перезаходе нож выдаётся стандартный а не с базы данных
 
Сообщения
14
Реакции
-1
Nezox2828, так в конекте стоит чтоб выдавался с базы данных, илм я там не так что то сделал?
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу