Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
@buiduchuy:
- Sontung0 share sma cái nst wpn rồi, open vào lấy func nó ra là dc. Mà trên alliedmods thiếu gì Print Color
client_printc(index, const text[], any:...)
{
new szMsg[128];
vformat(szMsg, sizeof(szMsg) - 1, text, 3);
replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04");
replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01");
replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03");
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, index);
write_byte(index);
write_string(szMsg);
message_end();
}
client_printc(id, "!g[Bio] !nThe Coffin will !tExplode!n. Stand away !!!")
L 11/01/2011 - 19:22:05: [AMXX] Run time error 4: index out of bounds
L 11/01/2011 - 19:22:05: [AMXX] [0] bio_zclass_banshee.sma::Forward_AddToFullPack_Post (line 651)
L 11/01/2011 - 19:22:05: [AMXX] Displaying debug trace (plugin "bio_zclass_banshee.amx
new g_iConfusing[33], g_iEntFake[33]
new g_confusing[33]
public Forward_AddToFullPack_Post(es_handled, inte, ent, host, hostflags, player, pSet)
{
// neu host ko con song thi bo qua
if (!is_user_alive(host))
return FMRES_IGNORED
if(!g_confusing[host] || !g_iConfusing[host])
return FMRES_IGNORED
// neu host ko bi dinh bomb hc thang attacker da chet
static iAttacker
iAttacker = g_iConfusing[host]
if (!iAttacker || iAttacker == host || !is_user_alive(iAttacker))
return FMRES_IGNORED
// neu ent chinh la thang nem bomb
if ((1 < ent < 32) && is_user_zombie(ent))
{
// an? thang do'
set_es(es_handled, ES_RenderMode, kRenderTransAdd)
set_es(es_handled, ES_RenderAmt, 0.0)
// tao ent fake cho attacker neu chua co
new iEntFake = find_ent_by_owner(-1, CLASSNAME_FAKE_PLAYER, ent)
if(!iEntFake || !pev_valid(ent))
{
iEntFake = create_fake_player(ent)
}
g_iEntFake[ent] = iEntFake
}
// neu ent la fake player cua attack
if (ent == g_iEntFake[ent]) // HERE IS 651 LINE
{
// show hang' cho thang victim xem
set_es(es_handled, ES_RenderMode, kRenderNormal)
set_es(es_handled, ES_RenderAmt, 255.0)
// set model cua host cho ent fake
set_es(es_handled, ES_ModelIndex, pev(host, pev_modelindex))
}
return FMRES_IGNORED
}

Giá trị của ent lớn hơn 32.Ai giúp fix lỗi này với
Mã:L 11/01/2011 - 19:22:05: [AMXX] Run time error 4: index out of bounds L 11/01/2011 - 19:22:05: [AMXX] [0] bio_zclass_banshee.sma::Forward_AddToFullPack_Post (line 651) L 11/01/2011 - 19:22:05: [AMXX] Displaying debug trace (plugin "bio_zclass_banshee.amx
Đây là code: (tôi đánh dấu dòng 165 rồi đó)
PHP:new g_iConfusing[33], g_iEntFake[33] new g_confusing[33] public Forward_AddToFullPack_Post(es_handled, inte, ent, host, hostflags, player, pSet) { // neu host ko con song thi bo qua if (!is_user_alive(host)) return FMRES_IGNORED if(!g_confusing[host] || !g_iConfusing[host]) return FMRES_IGNORED // neu host ko bi dinh bomb hc thang attacker da chet static iAttacker iAttacker = g_iConfusing[host] if (!iAttacker || iAttacker == host || !is_user_alive(iAttacker)) return FMRES_IGNORED // neu ent chinh la thang nem bomb if ((1 < ent < 32) && is_user_zombie(ent)) { // an? thang do' set_es(es_handled, ES_RenderMode, kRenderTransAdd) set_es(es_handled, ES_RenderAmt, 0.0) // tao ent fake cho attacker neu chua co new iEntFake = find_ent_by_owner(-1, CLASSNAME_FAKE_PLAYER, ent) if(!iEntFake || !pev_valid(ent)) { iEntFake = create_fake_player(ent) } g_iEntFake[ent] = iEntFake } // neu ent la fake player cua attack if (ent == g_iEntFake[ent]) // HERE IS 651 LINE { // show hang' cho thang victim xem set_es(es_handled, ES_RenderMode, kRenderNormal) set_es(es_handled, ES_RenderAmt, 255.0) // set model cua host cho ent fake set_es(es_handled, ES_ModelIndex, pev(host, pev_modelindex)) } return FMRES_IGNORED }
- g_iEntFake[ent] là nó lưu trữ id của ent vào id của player là đúng rồi, nhưng ko hiểu sao...
- Check thử is_valid_ent rồi mà vẫn thế là sao nhỉ![]()
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam( Ham_Spawn, "player", "fwdPlayerSpawn", 1 );
register_concmd("hello","hello")
}
public fwdPlayerSpawn(id)
{
if(!is_user_bot(id))
{
client_cmd(id,"hello")
}
}
public hello(id)
{
client_print(id,print_chat,"Hello")
}// chạy
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam( Ham_Spawn, "player", "fwdPlayerSpawn", 1 );
}
public fwdPlayerSpawn(id)
{
if(!is_user_bot(id))
{
client_cmd(id,"awp")
}
} // hem chạy được
^
- Nên set_task thì hơn, vừa hồi sinh ra làm gì kịp mua súng

Tránh lỗi ko set kịp thì dùng ShowSyncHudMsg ấy, còn nếu hiện SPR thì dùng ACG hoặc metahook.Thanks bác,, em làm được òi
---------- Post added at 20:31 ---------- Previous post was at 19:55 ----------
@DIAS: bác có cách nào show hud message ở 2 chỗ ko?
Ví dụ em làm 1 plugins tổng hợp vừa hiển thị số máu và số đạn... Lạ thay... Khi hiện được máu thì hud đạn mất, khi được đạn thì hud máu mất... vậy phải làm sao để sửa lỗi này ạ?
2: em dùng hàm get_user_weapon(id,clip,ammo) rồi cho show_hudmessage thì khi vào game.. lúc bắn nó ko set kịp làm số 4 chồng nên số 3, số 3 chồng lên số 2...nhìn xấu lém.. nhẹ nhưng ko bằng cả SPR của CS nguyên thủy.. vậy bác có cách nào để ammo có thể hiện đến 175 mà ko phải dùng hud message ko ? Nếu ko có thì bác có cách nào tránh bị lỗi "ko set kịp" ko?
#include <amxmodx>
#include <fakemeta>
#include <fun>
#define PLUGIN "[Bio] Extra Item: Minigun M134"
#define VERSION "1.0"
#define AUTHOR "Dias" // Take from NST_WPN (sontung0)
new bool:g_has_m134[33]
new g_m_ready[33], g_m_shoot[33], g_m_canclick[33], g_attack[33]
new const v_model[] = "models/biohazard/v_m134.mdl"
new const p_model[] = "models/biohazard/p_m134.mdl"
enum (+= 100)
{
TASK_M134_READY = 2000,
TASK_M134_FIRE_CHANGE,
TASK_M134_CANCLICK
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_CmdStart, "fw_CmdStart")
register_event("CurWeapon", "event_curweapon", "be", "1=1")
register_clcmd("say /give", "give")
}
public plugin_precache()
{
precache_model(v_model)
precache_model(p_model)
}
public event_curweapon(id)
{
if(get_user_weapon(id) == CSW_M249 && g_has_m134[id])
{
set_pev(id, pev_viewmodel2, v_model)
set_pev(id, pev_weaponmodel2, p_model)
}
}
public give(id)
{
client_print(id, print_chat, "Gived")
g_has_m134[id] = true
give_item(id, "weapon_m249")
}
public fw_CmdStart(id, uc_handle, seed)
{
if(!is_user_alive(id))
return
static szWeapID, szClip, szAmmo
szWeapID = get_user_weapon(id, szClip, szAmmo)
static buttons
buttons = get_uc(uc_handle, UC_Buttons)
if(szWeapID == CSW_M249 && g_has_m134[id])
{
use_m134_attack(id, szClip, uc_handle)
}
}
public use_m134_attack(id, szClip, uc_handle)
{
static buttons
buttons = get_uc(uc_handle, UC_Buttons)
new Float:time_ready = 1.0
new Float:time_canclick = 1.0
new Float:time_idle_change = 0.5
if ((buttons & IN_ATTACK))
{
if (!g_m_canclick[id] && !g_m_ready[id] && !g_m_shoot[id] && szClip)
{
set_weapons_timeidle(id, time_ready)
play_weapon_anim(id, 5)
g_m_ready[id] = 1
set_player_nextattack(id, time_ready)
if (task_exists(id+TASK_M134_READY)) remove_task(id+TASK_M134_READY)
set_task(time_ready, "task_m134_create_shoot", id+TASK_M134_READY)
// double click
g_m_canclick[id] = 1
if (task_exists(id+TASK_M134_CANCLICK)) remove_task(id+TASK_M134_CANCLICK)
set_task(time_canclick, "task_m134_remove_canclick", id+TASK_M134_CANCLICK)
}
}
else if ((buttons & IN_ATTACK2))
{
if (!g_m_canclick[id] && !g_m_ready[id] && !g_m_shoot[id] && szClip)
{
buttons &= ~IN_ATTACK2
set_uc(uc_handle, UC_Buttons, buttons)
set_weapons_timeidle(id, time_idle_change)
play_weapon_anim(id, 7)
// create can shoot
g_m_ready[id] = 1
set_player_nextattack(id, time_ready)
if (task_exists(id+TASK_M134_READY)) remove_task(id+TASK_M134_READY)
set_task(time_ready, "task_m134_create_shoot", id+TASK_M134_READY)
// create anim fire change
if (task_exists(id+TASK_M134_FIRE_CHANGE)) remove_task(id+TASK_M134_FIRE_CHANGE)
set_task(time_idle_change, "task_m134_create_fire_change", id+TASK_M134_FIRE_CHANGE)
// double click
g_m_canclick[id] = 1
if (task_exists(id+TASK_M134_CANCLICK)) remove_task(id+TASK_M134_CANCLICK)
set_task(time_canclick, "task_m134_remove_canclick", id+TASK_M134_CANCLICK)
}
}
else if (szClip)
{
if (g_m_ready[id] || g_m_shoot[id])
{
g_m_ready[id] = 0
g_m_shoot[id] = 0
if (task_exists(id+TASK_M134_READY)) remove_task(id+TASK_M134_READY)
set_weapons_timeidle(id, time_ready)
play_weapon_anim(id, 6)
}
if ((buttons & IN_RELOAD)) set_player_nextattack(id, 0.0)
}
}
public task_m134_create_shoot(taskid)
{
if (task_exists(taskid)) remove_task(taskid)
new id = taskid - TASK_M134_READY
g_m_ready[id] = 0
g_m_shoot[id] = 1
//set_player_nextattack(id, 0.0)
}
public task_m134_remove_canclick(taskid)
{
remove_task(taskid)
new id = taskid - TASK_M134_CANCLICK
g_m_canclick[id] = 0
}
public task_m134_create_fire_change(taskid)
{
remove_task(taskid)
new id = taskid - TASK_M134_FIRE_CHANGE
new CURENT_WEAPON = get_user_weapon(id)
new szClip, szAmmo
new szWeapID = get_user_weapon( id, szClip, szAmmo )
new Float:time_fire_change = 0.2
if (szWeapID==CSW_M249 && CURENT_WEAPON && g_has_m134[id] && (pev(id, pev_button) & IN_ATTACK2))
{
if (!g_attack[id]) play_weapon_anim(id, 8)
if (szClip) set_task(time_fire_change, "task_m134_create_fire_change", id+TASK_M134_FIRE_CHANGE)
}
}
set_weapons_timeidle(id, Float:timeidle)
{
new entwpn = get_weapon_ent(id, get_user_weapon(id))
if (pev_valid(entwpn)) set_pdata_float(entwpn, 48, timeidle+3.0, 4)
}
play_weapon_anim(player, anim)
{
set_pev(player, pev_weaponanim, anim)
message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
write_byte(anim)
write_byte(pev(player, pev_body))
message_end()
}
set_player_nextattack(id, Float:nexttime)
{
set_pdata_float(id, 83, nexttime, 4)
}
get_weapon_ent(id, weaponid)
{
static wname[32], weapon_ent
get_weaponname(weaponid, wname, charsmax(wname))
weapon_ent = fm_find_ent_by_owner(-1, wname, id)
return weapon_ent
}
stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) {
new strtype[11] = "classname", ent = index;
switch (jghgtype) {
case 1: strtype = "target";
case 2: strtype = "targetname";
}
while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
return ent;
}