广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 1400 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
nav5
个人文章 个人相簿 个人日记 个人地图
初露锋芒
级别: 初露锋芒 该用户目前不上站
推文 x2 鲜花 x26
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[1.6][插件] please fix this code : the plugin works , but "stack error"  (the plugin works , but "stack error")
i created a plugin that trigger a entity when the vip escape ,it works but there 's a bug : stack errror

for further detail, i want to triggers (break) all func_breakable which has the "targetname" field is "bombtargeta" in the map when the VIP escapes ,such as

我创建了一个插件,引发实体贵宾逃生时,它的工作原理,但有一个错误:栈errror

当贵宾逃逸,如进一步的细节,我想所有func_breakable“TARGETNAME”字段是“bombtargeta”在地图触发器(打破)

{
"model" "*36"
"targetname" "bombtargeta"
"rendermode" "4"
"spawnflags" "1"
"renderamt" "255"
"rendercolor" "0 0 0"
"classname" "func_breakable"
}
{
"model" "*37"
"targetname" "bombtargeta"
"rendermode" "4"
"spawnflags" "1"
"renderamt" "255"
"rendercolor" "0 0 0"
"classname" "func_breakable"
}

i use this code

复制程式
public event_vip_safety(id) {
if (id == g_vip_id)
{
open_jail(id)
set_player_vip(id)
}
}
public open_jail(id) {
new ent2 =0
while((ent2 = engfunc(EngFunc_FindEntityByString, ent2, "targetname", "bombtargeta"))) {
dllfunc(DLLFunc_Use,ent2,id)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}


the plugin will be like this

复制程式
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#define PLUGIN_NAME "VIP Alternative"
#define PLUGIN_VERSION "0.1"
#define PLUGIN_AUTHOR "VEN"
new CVAR_NAME[] = "varmor"
#define CVAR_DEFAULT "100"
#define BIT_ICON_NORMAL (1<<0)
#define BIT_ICON_BLINK (1<<1)
#define BIT_ICON BIT_ICON_NORMAL
#define ICON_R 0
#define ICON_G 0
#define ICON_B 255
#define OFFSET_VIP_32BIT 209
#define OFFSET_VIP_64BIT 242
#define OFFSET_VIP_LINUXDIFF 5
#define BIT_VIP (1<<8)
#if !defined PROCESSOR_TYPE
#if cellbits == 32
#define OFFSET_VIP OFFSET_VIP_32BIT
#else
#define OFFSET_VIP OFFSET_VIP_64BIT
#endif
#else
#if PROCESSOR_TYPE == 0
#define OFFSET_VIP OFFSET_VIP_32BIT
#else
#define OFFSET_VIP OFFSET_VIP_64BIT
#endif
#endif
#define CVAR_POINTERS_AMXX_INIT_VER_NUM 170
#if defined AMXX_VERSION_NUM && AMXX_VERSION_NUM >= CVAR_POINTERS_AMXX_INIT_VER_NUM
#define CVAR_POINTERS
new g_cvar_pointer
#endif
new ICON_NAME[] = "vipsafety"
#define BIT_CENTER_TEXT (1<<2)
new MESSAGE_TEXT[] = "#Cannot_Switch_From_VIP"
new g_msgid_icon
new g_msgid_text
new g_vip_id
public plugin_init() {
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
#if defined CVAR_POINTERS
g_cvar_pointer = register_cvar(CVAR_NAME, CVAR_DEFAULT)
#else
register_cvar(CVAR_NAME, CVAR_DEFAULT)
#endif
register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
register_event("ResetHUD", "event_hud_reset", "be")
register_event("StatusIcon", "event_vip_safety", "be", "1=1", "2=vipsafety")
#if defined BIT_ICON
register_event("DeathMsg", "event_death", "a", "2!0")
#endif
register_clcmd("fullupdate", "clcmd_fullupdate")
register_clcmd("chooseteam", "clcmd_role_switch")
register_clcmd("jointeam", "clcmd_role_switch")
g_msgid_icon = get_user_msgid("StatusIcon")
g_msgid_text = get_user_msgid("TextMsg")
}
public event_new_round() {
if (!g_vip_id || !is_user_connected(g_vip_id))
return
new tchar[2]
get_user_team(g_vip_id, tchar, 1)
if (tchar[0] != 'C') {
g_vip_id = 0
return
}
set_player_vip(g_vip_id)
if (get_cvar_value() < 0)
g_vip_id = 0
}
public event_hud_reset(id) {
set_task(0.1, "task_vip_alteration", id)
}
public task_vip_alteration(id) {
if (is_user_alive(id) && set_player_vip(id, false)) {
g_vip_id = id
set_user_health (id, 200)
#if defined BIT_ICON
msg_vip_icon(id)
#endif
}
}
public client_disconnect(id) {
if (id == g_vip_id && !is_player_vip(id)) {
set_player_vip(id)
g_vip_id = 0
}
}
public event_vip_safety(id) {
if (id == g_vip_id)
{
open_jail(id)
set_player_vip(id)
}
}
public open_jail(id) {
new ent2 =0
while((ent2 = engfunc(EngFunc_FindEntityByString, ent2, "targetname", "bombtargeta"))) {
dllfunc(DLLFunc_Use,ent2,id)
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}
public event_death() {
new id = read_data(2)
if (id == g_vip_id)
msg_vip_icon(id, false)
}
public clcmd_role_switch(id) {
if (id != g_vip_id)
return PLUGIN_CONTINUE
msg_cant_switch_roles(id)
return PLUGIN_HANDLED
}
public clcmd_fullupdate() {
return PLUGIN_HANDLED
}
stock get_cvar_value() {
#if defined CVAR_POINTERS
return get_pcvar_num(g_cvar_pointer)
#else
return get_cvar_num(CVAR_NAME)
#endif
}
stock is_player_vip(id) {
return (get_pdata_int(id, OFFSET_VIP, OFFSET_VIP_LINUXDIFF) & BIT_VIP)
}
stock bool:set_player_vip(id, bool:vip = true) {
new oldbits = get_pdata_int(id, OFFSET_VIP, OFFSET_VIP_LINUXDIFF)
if (!vip && !(oldbits & BIT_VIP))
return false
new newbits
switch (vip) {
case true : newbits = (oldbits | BIT_VIP)
case false: newbits = (oldbits & ~BIT_VIP)
}
set_pdata_int(id, OFFSET_VIP, newbits, OFFSET_VIP_LINUXDIFF)
return true
}
stock msg_vip_icon(id, bool:show = true) {
message_begin(MSG_ONE, g_msgid_icon, {0, 0, 0}, id)
write_byte((show ? BIT_ICON : 0))
write_string(ICON_NAME)
if (show) {
write_byte(ICON_R)
write_byte(ICON_G)
write_byte(ICON_B)
}
message_end()
}
stock msg_cant_switch_roles(id) {
message_begin(MSG_ONE, g_msgid_text, {0, 0, 0}, id)
write_byte(BIT_CENTER_TEXT)
write_string(MESSAGE_TEXT)
message_end()
}



It works but there is a bug
它的工作原理,但有一个bug


复制程式
[AMXX] Displaying debug trace (plugin "vipvr200t.amxx")
[AMXX] Run time error 3: stack error
[AMXX] Displaying debug trace (plugin "vipvr200t.amxx")
[AMXX] Run time error 3: stack error
[AMXX]    [0] vipvr200t.sma::set_player_vip (line 142)
[AMXX]    [1] vipvr200t.sma::event_vip_safety (line98 )

please tell me how to fix it ?


thanks



献花 x0 回到顶端 [楼 主] From:未知地址 | Posted:2012-05-12 18:25 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.015024 second(s),query:15 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言