cs插件吧 关注:8,207贴子:87,910
  • 11回复贴,共1

这个插件能哪里出错了,哪位大神帮我看一下。

只看楼主收藏回复

/* 本插件由 AMXX-Studio 中文版修改生成 */
/* UTF-8 func by http://www.DT-Club.net */
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>
// Menu selections
const MENU_KEY_AUTOSELECT = 7
const MENU_KEY_BACK = 7
const MENU_KEY_NEXT = 8
const MENU_KEY_EXIT = 9
// Menu keys
const KEYSMENU = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
// For weapon buy menu handlers
#define WPN_STARTID g_menu_data[id][2]
#define WPN_MAXIDS (sizeof g_primary_items)
#define WPN_SELECTION (g_menu_data[id][2]+key)
#define WPN_AUTO_ON g_menu_data[id][3]
#define WPN_AUTO_PRI g_menu_data[id][4]
#define WPN_AUTO_SEC g_menu_data[id][5]
new g_hamczbots
new g_menu_data[33][8] // data for various menus
// 武器列表:主武器和副武器
new const g_primary_items[][] = { "weapon_galil", "weapon_famas", "weapon_m4a1", "weapon_ak47", "weapon_sg552", "weapon_aug", "weapon_scout",
"weapon_m3", "weapon_xm1014", "weapon_tmp", "weapon_mac10", "weapon_ump45", "weapon_mp5navy", "weapon_p90" }
new const g_secondary_items[][] = { "weapon_glock18", "weapon_usp", "weapon_p228", "weapon_deagle", "weapon_fiveseven", "weapon_elite" }
// 选择完武器后给与的道具列表 (例如:手雷)
new const g_additional_items[][] = { "weapon_hegrenade", "weapon_flashbang", "weapon_smokegrenade" }
// Primary and Secondary Weapon Names
new const WEAPONNAMES[][] = { "", "P228 Compact", "", "Schmidt Scout", "", "XM1014 M4", "", "Ingram MAC-10", "Steyr AUG A1",
"", "Dual Elite Berettas", "FiveseveN", "UMP 45", "SG-550 Auto-Sniper", "IMI Galil", "Famas",
"USP .45 ACP Tactical", "Glock 18C", "AWP Magnum Sniper", "MP5 Navy", "M249 Para Machinegun",
"M3 Super 90", "M4A1 Carbine", "Schmidt TMP", "G3SG1 Auto-Sniper", "", "Desert Eagle .50 AE",
"SG-552 Commando", "AK-47 Kalashnikov", "", "ES P90" }
// Max BP ammo for weapons
new const MAXBPAMMO[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120,
30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, -1, 100 }
public plugin_init()
{
register_plugin("NST Zombie Mod3", "1.0", "NST")
RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
// Menus
register_menu("Buy Menu 1", KEYSMENU, "menu_buy1")
register_menu("Buy Menu 2", KEYSMENU, "menu_buy2")
}
public client_putinserver(id) // Client joins the game
{
if (is_user_bot(id) && !g_hamczbots && get_pcvar_num(get_cvar_pointer("bot_quota")))// Reg Ham Zbot
{
set_task(0.1, "register_ham_czbots", id)
}
}
// Register Ham Forwards for CZ bots
public register_ham_czbots(id)
{
// Make sure it's a CZ bot and it's still connected
if (g_hamczbots || !is_user_connected(id) || !get_pcvar_num(get_cvar_pointer("bot_quota")))return;
RegisterHamFromEntity(Ham_Spawn, id, "fw_PlayerSpawn_Post", 1)
//RegisterHamFromEntity(Ham_TakeDamage, id, "fw_TakeDamage")
//RegisterHamFromEntity(Ham_TraceAttack, id, "fw_TraceAttack")
// Ham forwards for CZ bots succesfully registered
g_hamczbots = true
// If the bot has already spawned, call the forward manually for him
if (is_user_alive(id)) fw_PlayerSpawn_Post(id)
}
// Ham Player Spawn Post Forward
public fw_PlayerSpawn_Post(id)
{
// Not alive or didn't join a team yet
if (!is_user_alive(id))return;
//if (get_pcvar_num(cvar_removemoney))set_task(0.2, "task_hide_money", id+201301101528)// Hide money?
set_task(0.4, "show_menu_buy1", id+201301101528)// Show custom buy menu?
}
public show_menu_buy1(taskid)// Buy Menu 1
{
static id// Get player id
(taskid > get_maxplayers()) ? (id = taskid - 201301101528) : (id = taskid);
if (!is_user_alive(id))return;
// Bots pick their weapons randomly
if (is_user_bot(id))
{
buy_primary_weapon(id, random_num(0, sizeof g_primary_items - 1))
menu_buy2(id, random_num(0, sizeof g_secondary_items - 1))
return;
}
// Automatic selection enabled for player and menu called on spawn event
if (WPN_AUTO_ON && taskid > get_maxplayers())
{
buy_primary_weapon(id, WPN_AUTO_PRI)
menu_buy2(id, WPN_AUTO_SEC)
return;
}
static menu[300], len, weap
len = 0
// Title
len += formatex(menu[len], sizeof menu - 1 - len, "\y%L \r[%d-%d]^n^n", id, "MENU_BUY1_TITLE", WPN_STARTID+1, min(WPN_STARTID+7, WPN_MAXIDS))
// 1-7. Weapon List
for (weap = WPN_STARTID; weap < min(WPN_STARTID+7, WPN_MAXIDS); weap++)
len += formatex(menu[len], sizeof menu - 1 - len, "\r%d.\w %s^n", weap-WPN_STARTID+1, WEAPONNAMES[get_weaponid(g_primary_items[weap])])
// 8. Auto Select
len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w %L \y[%L]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "MOTD_ENABLED" : "MOTD_DISABLED")
// 9. Next/Back - 0. Exit
len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r9.\w %L/%L^n^n\r0.\w %L", id, "MENU_NEXT", id, "MENU_BACK", id, "MENU_EXIT")
show_menu(id, KEYSMENU, menu, -1, "Buy Menu 1")
}
// Buy Primary Weapon
buy_primary_weapon(id, selection)
{
// Drop previous weapons
fm_drop_weapons(id, 1)
//fm_drop_weapons(id, 2)
// Strip off from weapons
fm_strip_user_weapons(id)
fm_give_item(id, "weapon_knife")
// Get weapon index
static weaponid
weaponid = get_weaponid(g_primary_items[selection])
// Give the new weapon
fm_give_item(id, g_primary_items[selection])
fm_set_user_bpammo(id, weaponid, MAXBPAMMO[weaponid])
// Weapons bought
static i// Give additional items
for (i = 0; i < sizeof g_additional_items; i++)fm_give_item(id, g_additional_items[i])
}
public menu_buy1(id, key)
{
// Zombies or survivors get no guns
if (!is_user_alive(id))return PLUGIN_HANDLED;
// Special keys / weapon list exceeded
if (key >= MENU_KEY_AUTOSELECT || WPN_SELECTION >= WPN_MAXIDS)
{
switch (key)
{
case MENU_KEY_AUTOSELECT: // toggle auto select
{
WPN_AUTO_ON = 1 - WPN_AUTO_ON
}
case MENU_KEY_NEXT: // next/back
{
if (WPN_STARTID+7 < WPN_MAXIDS)WPN_STARTID += 7
elseWPN_STARTID = 0
}
case MENU_KEY_EXIT: return PLUGIN_HANDLED;// exit
}
// Show buy menu again
show_menu_buy1(id)
return PLUGIN_HANDLED;
}
WPN_AUTO_PRI = WPN_SELECTION// Store selected weapon id
buy_primary_weapon(id, WPN_AUTO_PRI)// Buy primary weapon
// Show pistols menu
show_menu_buy2(id)
return PLUGIN_HANDLED;
}
// Buy Menu 2
public menu_buy2(id, key)
{
// Zombies or survivors get no guns
if (!is_user_alive(id))return PLUGIN_HANDLED;
// Special keys / weapon list exceeded
if (key >= sizeof g_secondary_items)
{
// Toggle autoselect
if (key == MENU_KEY_AUTOSELECT)WPN_AUTO_ON = 1 - WPN_AUTO_ON
// Reshow menu unless user exited
if (key != MENU_KEY_EXIT)show_menu_buy2(id)
return PLUGIN_HANDLED;
}
// Store selected weapon
WPN_AUTO_SEC = key
// Drop secondary gun again, in case we picked another (bugfix)
fm_drop_weapons(id, 2)
// Get weapon index
static weaponid
weaponid = get_weaponid(g_secondary_items[key])
// Give the new weapon with full ammo
fm_give_item(id, g_secondary_items[key])
fm_set_user_bpammo(id, weaponid, MAXBPAMMO[weaponid])
return PLUGIN_HANDLED;
}
// Buy Menu 2
show_menu_buy2(id)
{
static menu[250], len, weap
len = 0
// Title
len += formatex(menu[len], sizeof menu - 1 - len, "\y%L^n", id, "MENU_BUY2_TITLE")
// 1-6. Weapon List
for (weap = 0; weap < sizeof g_secondary_items; weap++)
len += formatex(menu[len], sizeof menu - 1 - len, "^n\r%d.\w %s", weap+1, WEAPONNAMES[get_weaponid(g_secondary_items[weap])])
// 8. Auto Select
len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r8.\w %L \y[%L]", id, "MENU_AUTOSELECT", id, (WPN_AUTO_ON) ? "MOTD_ENABLED" : "MOTD_DISABLED")
// 0. Exit
len += formatex(menu[len], sizeof menu - 1 - len, "^n^n\r0.\w %L", id, "MENU_EXIT")
//menu_buy1(id, WPN_AUTO_SEC)
show_menu(id, KEYSMENU, menu, -1, "Buy Menu 2")
}
// Set User BP Ammo
stock fm_set_user_bpammo(id, weapon, amount)
{
new iOffset
switch (weapon)
{
case CSW_AWP: iOffset = 377
case CSW_SCOUT, CSW_AK47, CSW_G3SG1: iOffset = 378
case CSW_M249: iOffset = 379
case CSW_M4A1,CSW_FAMAS,CSW_AUG,CSW_SG550,CSW_GALI,CSW_SG552: iOffset = 380
case CSW_M3,CSW_XM1014: iOffset = 381
case CSW_USP, CSW_UMP45, CSW_MAC10: iOffset = 382
case CSW_FIVESEVEN, CSW_P90: iOffset = 383
case CSW_DEAGLE: iOffset = 384
case CSW_P228: iOffset = 385
case CSW_GLOCK18, CSW_MP5NAVY, CSW_TMP, CSW_ELITE: iOffset = 386
case CSW_FLASHBANG: iOffset = 387
case CSW_HEGRENADE: iOffset = 388
case CSW_SMOKEGRENADE: iOffset = 389
case CSW_C4: iOffset = 390
default:
{
log_error(AMX_ERR_NATIVE, "Invalid weapon id %d", weapon)
return 0
}
}
return set_pdata_int(id, iOffset, amount)
//return set_pdata_int(id, 376+get_pdata_int(weapon, 49, 4), amount, 4)
//set_pdata_int(id, AMMOOFFSET[weapon], amount, 5)
}
// Give an item to a player (from fakemeta_util)
stock fm_give_item(id, const item[])
{
static ent
ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
if (!pev_valid(ent)) return;
static Float:originF[3]
pev(id, pev_origin, originF)
set_pev(ent, pev_origin, originF)
set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
dllfunc(DLLFunc_Spawn, ent)
static save
save = pev(ent, pev_solid)
dllfunc(DLLFunc_Touch, ent, id)
if (pev(ent, pev_solid) != save)return;
engfunc(EngFunc_RemoveEntity, ent)
}
// Strip user weapons (from fakemeta_util)
stock fm_strip_user_weapons(id)
{
static ent
ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "player_weaponstrip"))
if (!pev_valid(ent)) return;
dllfunc(DLLFunc_Spawn, ent)
dllfunc(DLLFunc_Use, ent, id)
engfunc(EngFunc_RemoveEntity, ent)
}
stock fm_drop_weapons(index, slot)
{
new item = get_pdata_cbase(index, 367+slot, 4)
while(item > 0)
{
static classname[24]
pev(item, pev_classname, classname, charsmax(classname))
engclient_cmd(index, "drop", classname)
item = get_pdata_cbase(item, 42, 5)
}
set_pdata_cbase(index, 367, -1, 4)
}


IP属地:湖北1楼2019-11-11 20:32回复
    编译一下就找到问题了


    IP属地:山东来自Android客户端2楼2019-11-12 17:56
    收起回复
      么人吗?


      IP属地:湖北3楼2019-11-21 17:58
      回复