Добрый день. Имеется плагин от RuneMod, который выкидывает ошибки:
Код
L 06/15/2011 - 12:50:53: [CSTRIKE] Non-player entity 0 out of range
L 06/15/2011 - 12:50:53: [AMXX] Run time error 10 (plugin "runemod_theif.amxx") (native "cs_get_weapon_ammo") - debug not enabled!
L 06/15/2011 - 12:50:53: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
Код:
#include <amxmodx>
#include <engine>
#include <cstrike>
#include "runemod.inc" // We need to include this file, as it contains info we need. Like #define`s and stocks
#define AMMO2STEAL 3
new g_HasRune[MAXPLAYERS+1] // This is the Array used to store if the user is holding a rune.(Remember the base plugin informs this plugin once he picks up a rune.)
new g_MaxEnts
new g_MaxPlayers
new g_WarnMessage[MAXPLAYERS+1]
new g_WeapEntIndex[MAXPLAYERS+1]
new g_iMsgSayText
new const gs_WeaponList[31][25] = {" ","weapon_p228"," ","weapon_scout","weapon_hegrenade","weapon_xm1014","weapon_c4","weapon_mac10","weapon_aug","weapon_smokegrenade",
"weapon_elite","weapon_fiveseven","weapon_ump45","weapon_sg550","weapon_galil","weapon_famas","weapon_usp","weapon_glock18","weapon_awp","weapon_mp5navy","weapon_m249",
"weapon_m3","weapon_m4a1","weapon_tmp","weapon_g3sg1","weapon_flashbang","weapon_deagle","weapon_sg552","weapon_ak47","weapon_knife","weapon_p90" }
public plugin_init()
{
register_plugin("RuneMod Theif", "1.1.0", "EKS")
g_MaxEnts = get_global_int(GL_maxEntities)
g_MaxPlayers = get_maxplayers()
RegisterPlugin("TheifName","TheifDisc",{53,150,240},API_EVENTDAMAGEDONE+API_ROUNDSTARTED+API_EVENTCHANGEWEAPON+AP
I_USELANGSYSTEM)
g_iMsgSayText = get_user_msgid("SayText")
}
public plugin_modules()
{
require_module("cstrike")
}
public API_CurWeaponChange(id,WeaponIndex)
{
g_WeapEntIndex[id] = GenWeaponEntId(id,WeaponIndex)
}
public API_DamageDone(victim,attacker,damage)
{
if(!g_HasRune[attacker]) return PLUGIN_CONTINUE
new winx = get_user_curweaponindex(victim);
if(winx == CSW_HEGRENADE || winx == CSW_SMOKEGRENADE || winx == CSW_FLASHBANG || winx ==CSW_C4)
return PLUGIN_CONTINUE;
StealAmmo(victim,attacker)
if(g_WarnMessage[victim] != attacker)
{
new Name[32]
get_user_name(attacker,Name,31)
ChatColor(victim,"%L",LANG_PLAYER,"TheifStealing",Name)
}
return PLUGIN_CONTINUE
}
stock StealAmmo(victim,attacker)
{
new EntNum = GenWeaponEntId(victim,get_user_curweaponindex(victim) )
new Ammo = cs_get_weapon_ammo(EntNum)
Ammo = Ammo - AMMO2STEAL
if(Ammo < 0) Ammo = 0
cs_set_weapon_ammo(EntNum,Ammo)
if(Ammo > 0) // This means we stole ammo
{
Ammo = cs_get_weapon_ammo(g_WeapEntIndex[attacker])
Ammo = Ammo + AMMO2STEAL
cs_set_weapon_ammo(g_WeapEntIndex[attacker],Ammo)
}
}
public API_DropedRune(id,Reason) //This function is called by the base plugin to inform about the user droped his rune for whatever reason ( he could have used droprune or died )
{
g_HasRune[id] = 0
g_WeapEntIndex[id] = 0
}
public API_PickUpRune(id) // This function is used base plugin to inform this plugin that a user has picked up the rune.
{
g_HasRune[id] = 1
g_WeapEntIndex[id] = GenWeaponEntId(id,get_user_weaponindex(id))
}
public API_RoundStarted()
{
for(new i=1;i<=g_MaxPlayers;i++)
{
g_WarnMessage[i] = 0
}
}
stock GenWeaponEntId(id,WeaponIndex)
{
new Class[24]
for(new i=g_MaxPlayers;i<=g_MaxEnts;i++)
if(is_valid_ent(i) && entity_get_edict(i, EV_ENT_owner) == id)
{
entity_get_string(i,EV_SZ_classname,Class,23)
if(equal(gs_WeaponList[WeaponIndex],Class))
{
return i
}
}
return 0
}
stock ChatColor(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4") // Green Color
replace_all(msg, 190, "!y", "^1") // Default Color
replace_all(msg, 190, "!team", "^3") // Team Color
if (id) players[0] = id; else get_players(players, count, "ch")
{
for (new i = 0; i < count; i++)
{
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE, g_iMsgSayText, _, players[i])
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}
Знаю, что ошибка именно в этой части кода:
Код:
stock StealAmmo(victim,attacker)
{
new EntNum = GenWeaponEntId(victim,get_user_curweaponindex(victim) )
new Ammo = cs_get_weapon_ammo(EntNum)
Ammo = Ammo - AMMO2STEAL
if(Ammo < 0) Ammo = 0
cs_set_weapon_ammo(EntNum,Ammo)
if(Ammo > 0) // This means we stole ammo
{
Ammo = cs_get_weapon_ammo(g_WeapEntIndex[attacker])
Ammo = Ammo + AMMO2STEAL
cs_set_weapon_ammo(g_WeapEntIndex[attacker],Ammo)
}
}
Только не знаю, как исправить. is_user_alive, is_user_connected или чем-то другим? Заранее благодарен.