24/05/2023, 10:07 PM
Hola buenas a todos, necesito una ayuda con un plugin de gungame para half-life, lo que pasa es que yo instalo el hl weapon mods y pongo armas nuevas por ejemplo: m249, minigun, barnacle y cuando yo lo pongo en los niveles, no funciona, osea no te equipa las armas, quedas sin armas, ya intente muchas cosas como spawnear las armas, probe otra version del weapon mod, entre otras cosas y lo mismo.. antes no me decia nada la consola, ahora si me tira un error y no entiendo mucho ni se que hay que hacer..
Código:
[FUN] Item "weapon_ak47" failed to create
Run time error 10: native error (native "give_item")
gungame.sma::Add_PlayerWeapon (line 2771)
gungame.sma::Equip_PlayerWithWeapon (line 2641)
gungame.sma::ReEquip_Player (line 2329)
y segun el creador es compatible con hl weapons mod, si alguien me pudiera ayudar que tengo que hacer se los agradeceria mucho!
aqui dejo el codigo del plugin gungame
Código PHP:
/* AMX Mod X
* Half-Life GunGame plugin by serfreeman1337
*
* http://aghl.ru/forum/ - Russian Half-Life and Adrenaline Gamer Community
*
* This file is provided as is (no warranties)
*/
/*
* Thanks:
* Safety1st
* KORD_12.7
* ET^NiK
*/
/*
* Translators:
* Safety1st - English.
* ACM1PT - Spanish.
*/
/*
* More information:
*
* http://gf.hldm.org/hl-gungame/ - serfreeman1337's site
* http://aghl.ru/forum/viewtopic.php?f=19&t=702 - Russian HL and AG Community
* https://forums.alliedmods.net/showthread.php?t=180714 - Official AMXX forum
*/
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "Half-Life GunGame"
#define VERSION "2.1"
#define AUTHOR "serfreeman1337" // ICQ: 50429042
#define LASTUPDATE "1, November (11), 2014"
// Enable detection and usage of color codes in notify messages
// This is only for AGHL.ru client.dll and RCD
#define AGHL_COLOR
// Enable support for Half-Life Weapon Mod by KORD_12.7
// ---> http://aghl.ru/forum/viewtopic.php?f=42&t=721
//#define HLWPNMOD
// Enable if you using Sturmbot for Day Of Defeat
// This prevents bot from staying in spectator
//#define DODBOTFIX
// Enable colorchat support for Counter-Strike
// Don't forget to replace gungame_cstrike.txt with your gungame.txt file
//#define CSCOLOR
#define extraoffset_weapon 4
// maximum win sounds
#define WINSOUNDS 15
// -------------------------------------------------------------------------------------------------
#if defined CSCOLOR
// -- CSTRIKE COLOR -- //
#if AMXX_VERSION_NUM < 183
#include <colorchat>
#define print_team_default DontChange
#define print_team_grey Grey
#define print_team_red Red
#define print_team_blue Blue
#endif
new const chatTeamColor[] = {
print_team_grey,
print_team_red,
print_team_blue
}
#undef AGHL_COLOR
#endif
new task_Refill_Id
new task_Refill_Max
new task_Hud_Id
new task_Icon_Blink
new task_Equip_Id
new task_Change_Id
new task_WarmUp_Id
new task_ProLevel_Id = 3446
new task_EntRemove_Id = 3447
#if defined AGHL_COLOR
new task_RequestColor_Id
#endif
// -- DATA STRUCTS -- //
enum _:weaponAmmoStruct {
WAMMO_PRIMARY_AMMOID,
WAMMO_SECONDARY_AMMOID,
WAMMO_PRIMARY_MAXAMMO,
WAMMO_SECONDARY_MAXAMMO
}
enum _:dataOffsetsStruct {
m_pPlayer,
m_iClip,
m_pActiveItem,
m_rgAmmo,
offsetAmmoDiff,
msgWeaponList
}
// this is for level settings parse
enum _:keyNames {
KEYSET_SHOWNAME,
KEYSET_KILLS,
KEYSET_SKIP,
KEYSET_REFIL_TIME_1,
KEYSET_REFIL_AMMOUNT_1,
KEYSET_DISABLE_FULLAMO_1,
KEYSET_REFIL_TIME_2,
KEYSET_REFIL_AMMOUNT_2,
KEYSET_DISABLE_FULLAMO_2,
KEYSET_CLIP,
KEYSET_ICONSPRITE,
KEYSET_BOTCANT
}
enum _:playersDataStruct {
PLAYER_CURRENTLEVEL,
PLAYER_LASTLEVEL,
PLAYER_KILLS,
PLAYER_NEEDKILLS,
PLAYER_WEAPONNAME[32],
PLAYER_RANKPOS,
PLAYER_ICON[32],
PLAYER_TEAM,
Trie:PLAYER_INFLICTORS,
Trie:PLAYER_NOREFIL,
bool:PLAYER_BOT,
#if defined AGHL_COLOR && !defined CSCOLOR
bool:PLAYER_AGHL
#endif
}
enum _:weaponSetStruct {
WSET_SHOWNAME[32],
WSET_KILLS,
WSET_SKIP,
WSET_ICONSPRITE[32],
Array:WSET_EQUIP_ITEMS,
Trie:WSET_INFLICTORS_MAP,
Array:WSET_INFARRAY,
Trie:WSET_NOREFIL_MAP,
bool:WSET_BOTCANT
#if defined HLWPNMOD
,bool:WSET_WPNMOD
#endif
}
enum _:equipStruct {
EQUIP_NAME[32],
EQUIP_CLIP,
Float:EQUIP_PRIMARY_REFIL_TIME,
Float:EQUIP_SECONDARY_REFIL_TIME,
EQUIP_PRIMARY_REFIL_AMMOUNT,
EQUIP_SECONDARY_REFIL_AMMOUNT,
bool:EQUIP_FULL_PRIMARY,
bool:EQUIP_FULL_SECONDARY,
}
enum _:autoSaveStruct {
ASAVE_LEVEL,
ASAVE_KILLS,
Float:ASAVE_TIME
}
enum _:refilTaskStruct {
REFIL_PLAYERID,
REFIL_WEAPONID,
REFIL_AMMOID,
REFIL_AMMOUNT,
REFIL_MAXAMMO,
REFIL_TASKID
}
enum _:cvars {
CVAR_SOUND_WINNER,
CVAR_SOUND_LEVELUP,
CVAR_SOUND_LEVELDOWN,
CVAR_UPARMOR,
CVAR_DESCORE,
CVAR_AUTOSAVE,
CVAR_ENDGAME_DELAY,
CVAR_SHOWSTATS,
CVAR_STATS_COLOR,
CVAR_STATS_POS,
CVAR_MAPCHOOSER_TYPE,
CVAR_MAPCHANGES_STYLE,
CVAR_NEARLEVEL,
CVAR_INFORMER_DISPLAY,
CVAR_INFORMER_POS,
CVAR_INFORMER_COLOR,
CVAR_INFORMER_HOLDTIME,
CVAR_CHAT_MESSAGE,
CVAR_RESTORE_HP,
CVAR_DEFAULT_HP,
CVAR_DEFAULT_AP,
CVAR_INFLICTORS_NODAMAGE,
CVAR_ICON,
CVAR_ICON_BLINKTIME,
CVAR_ICON_COLOR,
CVAR_ICON_BLINKCOLOR1,
CVAR_ICON_BLINKCOLOR2,
CVAR_HANDICAP,
CVAR_WARMUP,
CVAR_PROLEVEL_MUSIC,
// 2.1
CVAR_ENABLED,
CVAR_CFGFILE,
CVAR_TEAMPLAY,
CVAR_TEAMMULGOAL,
CVAR_MAPCHANGE_CMD
}
enum _:informerDisplay {
INF_TPL_WEAPON,
INF_TPL_LEVEL,
INF_TPL_MAXLEVEL,
INF_TPL_SAMELEVEL,
INF_TPL_KILLS,
INF_TPL_NEEDKILLS,
INF_TPL_RANK,
INF_TPL_RANKNUM,
INF_TPL_LEADER,
INF_TPL_LWEAPON
}
enum _:notifyType {
NOTIFY_UP,
NOTIFY_DOWN,
NOTIFY_NOW,
NOTIFY_LAST,
NOTIFY_SKIP,
NOTIFY_WIN,
NOTIFY_ENABLED,
NOTIFY_DISABLED,
NOTIFY_TEAMUP,
NOTIFY_TEAMWIN,
NOTIFY_TEAMLAST
}
// -- DATAS -- //
new offsetsForMe[dataOffsetsStruct][] = { // offsets names
"m_pPlayer",
"m_iClip",
"m_pActiveItem",
"m_rgAmmo",
"offsetAmmoDiff",
"msgWeaponList"
}
new informerTplKeys[informerDisplay][] = {
"<weapon>",
"<level>",
"<maxlevel>",
"<samelevel>",
"<kills>",
"<needkills>",
"<rank>",
"<ranknum>",
"<leader>",
"<lweapon>"
}
new informerBitSum
new setKeys[keyNames][] = {
"name",
"kills",
"skip",
"refil_time_1",
"refil_ammount_1",
"disable_fullammo_1",
"refil_time_2",
"refil_ammount_2",
"disable_fullammo_2",
"clip",
"icon",
"botcant"
}
new cvar[cvars]
new modOffsets[dataOffsetsStruct]
new Trie:weaponAmmoTrie
new Trie:ammoMaxMap
new Trie:autoSaveMap
new Array:weaponSets
new playersData[33][playersDataStruct]
new bool:isValve
new bool:isAG
new StatusIcon
new ScreenFade
new AmmoPickup
new AmmoX
new WeapPickup
new currentPlayers
#if AMXX_VERSION_NUM < 183
new MaxClients
#endif
new maxLevel
new bool:isEndGame = false
new bool:isVoteStarted = false
new leader_name[32] = "--"
new wp_leader[32] = "--"
new striper
new Float:autoSaveTime
new warmUpMode = 0
new Array:warmUpSet
new cfgFileWas[30]
// leet sound
new sound_winner[64],sound_levelup[64],sound_leveldown[64],prolevel_music[64]
new Float:proLevelLoop
new bool:proLevelPlayed = false
// -- HUD -- //
new informerColor[3],Float:informerPos[2]
new syncInformerHud
new endHudColor[3],Float:endHudPos[3]
new Float:holdTime
// -- ICON -- //
new Float:blinkTime
new iconColors[9]
// -- CHAT -- //
new chatInformerBitsum
// -- API -- //
new fwdRet // dummy var
new fwdWin,fwdLevelUp,fwdWarmUpStart,fwdWarmUpEnd
new fwdState,fwdEquip
// -- EFFECTS -- //
new noDmgSnds[][] = {
"weapons/electro4.wav",
"weapons/electro5.wav",
"weapons/electro6.wav"
}
public Array:ggblockedItems
#if defined HLWPNMOD
// -- WPNMOD -- //
#include <hl_wpnmod>
new Trie:wpnModMap
stock wpnmod_give_item(const iPlayer, const szItem[]){
new Float: vecOrigin[3];
pev(iPlayer, pev_origin, vecOrigin);
new iItem = wpnmod_create_item(szItem, vecOrigin);
if (is_valid_ent(iItem))
{
entity_set_int(iItem, EV_INT_spawnflags, entity_get_int(iItem,EV_INT_spawnflags) | SF_NORESPAWN);
dllfunc(DLLFunc_Touch,iItem,iPlayer)
return iItem;
}
return -1;
}
#endif
// Sound Precache
public plugin_precache(){
register_plugin(PLUGIN, VERSION, AUTHOR)
task_Refill_Id = 100
task_Refill_Max = 4 // maximum number of refil tasks per player
task_Hud_Id = task_Refill_Id + (task_Refill_Max * 33)
task_Icon_Blink = task_Hud_Id + 33
task_Equip_Id = task_Icon_Blink + 33
task_Change_Id = task_Equip_Id + 33
task_WarmUp_Id = task_Change_Id + 33
// we are ninjas
//
// end game music
// separate with semicolon
//
cvar[CVAR_SOUND_WINNER] = register_cvar("gg_sound_winner","media/Half-Life03.mp3;media/Half-Life08.mp3;media/Half-Life11.mp3;media/Half-Life17.mp3")
//
// level up and level down sounds
// leave empty for disable this feature
//
cvar[CVAR_SOUND_LEVELUP] = register_cvar("gg_sound_levelup","debris/beamstart5.wav")
cvar[CVAR_SOUND_LEVELDOWN] = register_cvar("gg_sound_leveldown","debris/beamstart5.wav")
//
// bonus armor value on levelup
// player has 1 for 3 chance to get bonus armor
//
cvar[CVAR_UPARMOR] = register_cvar("gg_uparmor","30")
//
// allows/disallows level down for selfkill
//
cvar[CVAR_DESCORE] = register_cvar("gg_descore","1")
//
// auto save function
// plugin will rembemer player kills and level after disconnect
//
cvar[CVAR_AUTOSAVE] = register_cvar("gg_autosave","300.0")
//
// end game delay time
// TODO: check out how it works XD
//
cvar[CVAR_ENDGAME_DELAY] = register_cvar("gg_endgame_delay","15")
// information messages
cvar[CVAR_SHOWSTATS] = register_cvar("gg_showstats", "1")
//
// end game hud color
// r g b
//
cvar[CVAR_STATS_COLOR] = register_cvar("gg_stats_color","255 255 0")
//
// end game hud pos
// x y
//
cvar[CVAR_STATS_POS] = register_cvar("gg_stats_pos","0.73 0.40")
//
// map change style
// 0 - no vote, just change to nextmap instead
// 1 - start vote at end of the game
// 2 - start vote if someone reaches pre end level
//
cvar[CVAR_MAPCHANGES_STYLE] = register_cvar("gg_mapchange_style","1")
//
// mapchooser you have
// 0 - auto detect
// 1 - Galileo
// 2 - default amxx mapchooser
// 3 - use custom command
// 4 - Deagle's Map Manager
//
cvar[CVAR_MAPCHOOSER_TYPE] = register_cvar("gg_mapchooser_type","0")
//
// for mapchange style 2 sets near level from max level to start vote
//
cvar[CVAR_NEARLEVEL] = register_cvar("gg_startvote_nearlevel","2")
//
// hud informer display
// 0 - off
// 1 - on
//
cvar[CVAR_INFORMER_DISPLAY] = register_cvar("gg_informer_display","1")
//
// hud informer position
//
cvar[CVAR_INFORMER_POS] = register_cvar("gg_informer_pos","-1.0 0.97")
//
// hud informer color
//
cvar[CVAR_INFORMER_COLOR] = register_cvar("gg_informer_color","128 255 0")
//
// hud informer hold time
//
cvar[CVAR_INFORMER_HOLDTIME] = register_cvar("gg_informer_holdtime","20.0")
//
// enable chat messages bitsumm
// a - level up message
// b - level down message
// c - level now message
// d - reached last level notify
// e - level skip message
// f - winner message
// g - enable message
// h - disable message
//
cvar[CVAR_CHAT_MESSAGE] = register_cvar("gg_chat_messages","abcdefgh")
//
// restore hp on levelup
//
cvar[CVAR_RESTORE_HP]= register_cvar("gg_restore_hp","1")
//
// default hp
//
cvar[CVAR_DEFAULT_HP] = register_cvar("gg_default_hp","100")
//
// default ap
//
cvar[CVAR_DEFAULT_AP] = register_cvar("gg_default_ap","100")
//
// enables status icon of current weapon
// only if current mod supports StatusIcon message
//
cvar[CVAR_ICON] = register_cvar("gg_icon_enable","1")
//
// weapon icon color
// r g b
//
cvar[CVAR_ICON_COLOR] = register_cvar("gg_icon_color","255 127 0")
//
// weapon icon blink time on level time
// sets the time which weapon icon will blink for level up
cvar[CVAR_ICON_BLINKTIME] = register_cvar("gg_icon_blink","3.0")
//
// blink color 1
// r g b
//
cvar[CVAR_ICON_BLINKCOLOR1] = register_cvar("gg_icon_blink1","45 215 255")
//
// blink color 2
// r g b
//
cvar[CVAR_ICON_BLINKCOLOR2] = register_cvar("gg_icon_blink2","255 0 0")
//
// handicap mode
// 0 - disable
// 1 - new player will have average level of all players
// 2 - new player will have lowest level of all players
//
cvar[CVAR_HANDICAP] = register_cvar("gg_handicap_on","1")
//
// warmup mode
// specify time of warump round duration
// user 0.0 for disable this opiton
//
cvar[CVAR_WARMUP] = register_cvar("gg_warmup","20.0")
//
// endlevel music
// sets music which will be played when someone need one kill to win
// leave blank for disable
// only mp3 files is supported
// you can also loop music to play, for example:
// media/csgo02.mp3 21.4
// this will loop csgo02.mp3 file for 21.4 seconds
//
cvar[CVAR_PROLEVEL_MUSIC] = register_cvar("gg_prolevel_music","")
//
// enable disable gungame on start
//
cvar[CVAR_ENABLED] = register_cvar("gg_enabled","1")
//
// teamplay mode
//
cvar[CVAR_TEAMPLAY] = register_cvar("gg_teamplay","0")
//
// required kills multipler for all weapons for teamplay mode
//
cvar[CVAR_TEAMMULGOAL] = register_cvar("gg_teamplay_multigoal","2")
//
// default cfg file name
//
cvar[CVAR_CFGFILE] = register_cvar("gg_cfg_file","gungame.ini")
//
// custom map change command
//
cvar[CVAR_MAPCHANGE_CMD] = register_cvar("gg_mapchange_cmd","amx_nextmap_vote 0 0 0")
load_cfg()
// load multiply sounds
new winnerSnd[256]
get_pcvar_string(cvar[CVAR_SOUND_WINNER],winnerSnd,charsmax(winnerSnd))
new ePos,stPos,i
new winSnds[WINSOUNDS][sizeof sound_winner]
if(winnerSnd[0]){
do {
ePos = strfind(winnerSnd[stPos],";")
formatex(winSnds[i++],ePos,winnerSnd[stPos])
if(i >= WINSOUNDS)
break
stPos += ePos + 1
} while (ePos != -1)
ePos = random(i)
copy(sound_winner,charsmax(sound_winner),winSnds[ePos])
precache_generic(sound_winner)
/*
if(file_exists(winSnds[ePos])){
copy(sound_winner,charsmax(sound_winner),winSnds[ePos])
precache_generic(sound_winner)
}else{
log_amx("WARNING! Can't find ^"%s^" sound file! Win music is disabled.",
winSnds[ePos])
}
*/
}
get_pcvar_string(cvar[CVAR_PROLEVEL_MUSIC],winnerSnd,charsmax(winnerSnd))
for(i = 0 ; i < WINSOUNDS ; ++i)
arrayset(winSnds[i],0,sizeof sound_winner)
i = 0
ePos = 0
stPos = 0
if(winnerSnd[0]){
do {
ePos = strfind(winnerSnd[stPos],";")
formatex(winSnds[i++],ePos,winnerSnd[stPos])
if(i >= WINSOUNDS)
break
stPos += ePos + 1
} while (ePos != -1)
new snd[128],loop[10]
parse(winSnds[random(i)],snd,charsmax(snd),loop,charsmax(loop))
proLevelLoop = str_to_float(loop)
if(file_exists(snd)){
copy(prolevel_music,charsmax(prolevel_music),snd)
precache_generic(prolevel_music)
}else{
log_amx("WARNING! Can't find ^"%s^" sound file! End level music is disabled.",
snd)
}
}
get_pcvar_string(cvar[CVAR_SOUND_LEVELUP],sound_levelup,charsmax(sound_levelup))
get_pcvar_string(cvar[CVAR_SOUND_LEVELDOWN],sound_leveldown,charsmax(sound_leveldown))
if(sound_levelup[0])
precache_generic(sound_levelup)
if(sound_leveldown[0])
precache_generic(sound_leveldown)
if(modOffsets[msgWeaponList] > 0) // register weapon list
register_message(modOffsets[msgWeaponList],"MSG_WeaponList")
for(new i ; i < sizeof noDmgSnds ; ++i)
precache_sound(noDmgSnds[i])
}
public plugin_init(){
register_cvar("gungame", VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED)
register_dictionary("gungame.txt")
}
new gameName[64] = "Unknown"
new bool:modFound = false
new bool:ggActive
public plugin_cfg(){
server_print("")
server_print(" Half-Life GunGame Copyright (c) 2014 %s",AUTHOR)
server_print(" Version %s build on %s", VERSION, LASTUPDATE)
server_print("")
ggActive = get_pcvar_num(cvar[CVAR_ENABLED]) == 1
#if defined AGHL_COLOR && !defined CSCOLOR
if(isValve){
task_RequestColor_Id = task_WarmUp_Id + 1
register_dictionary("gungame_clr.txt")
}
#endif
if(!modOffsets[msgWeaponList]){
new weaponListMsg = get_user_msgid("WeaponList")
if(!weaponListMsg){
log_amx("ERROR! Unable to get weapon list!")
set_fail_state("weapon list retrieve failed")
}
register_message(weaponListMsg,"MSG_WeaponList")
}
if(get_pcvar_num(cvar[CVAR_ICON])){
StatusIcon = get_user_msgid("StatusIcon")
if(!StatusIcon){
// valve client.dll has StatusIcon
if(isValve){
StatusIcon = engfunc(EngFunc_RegUserMsg,"StatusIcon",-1)
isValve = true
}
}
new tmpStr[64],parseStr[3][10]
blinkTime = get_pcvar_float(cvar[CVAR_ICON_BLINKTIME])
// magic, no have idea how it works
for(new i,z,j; i < sizeof iconColors ; i++,z++){
if(!(i % 3)){
get_pcvar_string(cvar[CVAR_ICON_COLOR + j ++],tmpStr,charsmax(tmpStr))
parse(tmpStr,
parseStr[0],charsmax(parseStr[]),
parseStr[1],charsmax(parseStr[]),
parseStr[2],charsmax(parseStr[])
)
}
if(z == 3)
z =0
iconColors[i] = str_to_num(parseStr[z])
if(i > 2 && !blinkTime)
break
}
}
if(get_pcvar_num(cvar[CVAR_SHOWSTATS])){
new tmpStr2[64],parseStr2[3][10]
get_pcvar_string(cvar[CVAR_STATS_COLOR],tmpStr2,charsmax(tmpStr2))
parse(tmpStr2,
parseStr2[0],charsmax(parseStr2[]),
parseStr2[1],charsmax(parseStr2[]),
parseStr2[2],charsmax(parseStr2[])
)
endHudColor[0] = str_to_num(parseStr2[0])
endHudColor[1] = str_to_num(parseStr2[1])
endHudColor[2] = str_to_num(parseStr2[2])
get_pcvar_string(cvar[CVAR_STATS_POS],tmpStr2,charsmax(tmpStr2))
parse(tmpStr2,
parseStr2[0],charsmax(parseStr2[]),
parseStr2[1],charsmax(parseStr2[])
)
endHudPos[0] = str_to_float(parseStr2[0])
endHudPos[1] = str_to_float(parseStr2[1])
}
if(get_pcvar_num(cvar[CVAR_INFORMER_DISPLAY])){
new informerText[312]
formatex(informerText,charsmax(informerText),"%L",LANG_SERVER,"INFORMER")
for(new i ; i < informerDisplay ; ++i)
if(contain(informerText,informerTplKeys[i]) != -1)
informerBitSum |= (1 << i)
new forParse[30],parsedValue[3][10]
get_pcvar_string(cvar[CVAR_INFORMER_POS],forParse,charsmax(forParse))
parse(forParse,parsedValue[0],charsmax(parsedValue[]),parsedValue[1],charsmax(parsedValue[]))
informerPos[0] = str_to_float(parsedValue[0])
informerPos[1] = str_to_float(parsedValue[1])
get_pcvar_string(cvar[CVAR_INFORMER_COLOR],forParse,charsmax(forParse))
parse(forParse,parsedValue[0],charsmax(parsedValue[]),parsedValue[1],charsmax(parsedValue[]),parsedValue[2],charsmax(parsedValue[]))
informerColor[0] = str_to_num(parsedValue[0])
informerColor[1] = str_to_num(parsedValue[1])
informerColor[2] = str_to_num(parsedValue[2])
holdTime = get_pcvar_float(cvar[CVAR_INFORMER_HOLDTIME])
}else
task_Hud_Id = 0
ScreenFade = get_user_msgid("ScreenFade")
AmmoX = get_user_msgid("AmmoX")
AmmoPickup = get_user_msgid("AmmoPickup")
WeapPickup = get_user_msgid("WeapPickup")
syncInformerHud = CreateHudSyncObj()
#if AMXX_VERSION_NUM < 183
MaxClients = get_maxplayers()
#endif
new gh[10]
get_pcvar_string(cvar[CVAR_CHAT_MESSAGE],gh,charsmax(gh))
chatInformerBitsum = read_flags(gh) //get_pcvar_flags(cvar[CVAR_CHAT_MESSAGE])
autoSaveTime = get_pcvar_float(cvar[CVAR_AUTOSAVE])
// block drop command
register_clcmd("drop","block_drop")
fwdWin = CreateMultiForward("gg_win",ET_IGNORE,FP_CELL)
fwdLevelUp = CreateMultiForward("gg_levelup",ET_IGNORE,FP_CELL,FP_CELL,FP_CELL)
fwdWarmUpStart = CreateMultiForward("gg_warmup_start",ET_IGNORE)
fwdWarmUpEnd = CreateMultiForward("gg_warmup_end",ET_STOP)
fwdState = CreateMultiForward("gg_state",ET_IGNORE,FP_CELL)
fwdEquip = CreateMultiForward("gg_player_equip",ET_IGNORE,FP_CELL)
if(ggActive){
ggActive = false // for retrigger Enable_GunGame function
Enable_GunGame()
}
// op. cmds
register_concmd("gg_enable","CMD_GGToggle",ADMIN_RCON,"[0|1] - toggles the functionality of GunGame.")
}
//
// --- GG CMDS ---
//
public CMD_GGToggle(id,level,cid){
if(!cmd_access(id,level,cid,0))
return PLUGIN_HANDLED
new sArg[10]
read_argv(1,sArg,charsmax(sArg))
if(sArg[0])
str_to_num(sArg) ? Enable_GunGame() : Disable_GunGame()
else // azazazaza
ggActive ? Disable_GunGame() : Enable_GunGame()
new adminName[32],adminAuth[36],adminIp[15]
get_user_name(id,adminName,charsmax(adminName))
get_user_authid(id,adminAuth,charsmax(adminAuth))
get_user_ip(id,adminIp,charsmax(adminIp),true)
log_amx("%s<%s><%s> toggled gungame",adminName,adminAuth,adminIp)
return PLUGIN_HANDLED
}
// --- GG HOOKS --- //
new hookMsgAmmoX,hookMsgWeapPickup,hookMsgAmmoPickup
new HamHook:hookSpawn,HamHook:hookKilled,HamHook:hookDamage,HamHook:hookTrace,HamHook:hookUseGame,HamHook:hookUseStrip
//
// Enable GunGame plugin
//
public Enable_GunGame(){
if(ggActive)
return
if(weaponSets)
ArrayClear(weaponSets)
if(warmUpSet)
ArrayClear(warmUpSet)
new cvarState = get_pcvar_num(cvar[CVAR_ENABLED])
load_cfg()
// power on self test
if(!modFound){
server_print("[GunGame] Mod settings is not preset!")
set_fail_state("missing mod settings")
}
new offsetsPreset
// check offsets
for(new i ; i < dataOffsetsStruct ; ++i){
if(!modOffsets[i] && i < offsetAmmoDiff)
log_amx("ERROR! Offset ^"%s^" is not present!",offsetsForMe[i])
else
offsetsPreset ++
}
if(offsetsPreset < dataOffsetsStruct){
server_print("[GunGame] Offsets is missing")
set_fail_state("missing offsets")
}else{
server_print("[GunGame] Offsets for %s loaded",gameName)
}
// check level weapons for valid
if(weaponSets == Invalid_Array){
server_print("[GunGame] No active levels^n")
log_amx("ERROR! No active levels!")
return
}
maxLevel = ArraySize(weaponSets)
server_print("[GunGame] Total %d levels loaded from ^"%s^" configuration file",maxLevel,cfgFileWas)
// set hooks for players
if(!hookSpawn){ // register new hooks
hookSpawn = RegisterHam(Ham_Spawn,"player","On_PlayerSpawn",true)
hookKilled = RegisterHam(Ham_Killed,"player","On_PlayerKilled",true)
hookDamage = RegisterHam(Ham_TakeDamage,"player","On_PlayerTakeDamage",false)
hookTrace = RegisterHam(Ham_TraceAttack,"player","On_TraceAttack",false)
hookUseGame = RegisterHam(Ham_Use,"player_weaponstrip","HS_BlockUse",false)
hookUseStrip = RegisterHam(Ham_Use,"game_player_equip","HS_BlockUse",false)
}else{ // enable hooks
EnableHamForward(hookSpawn)
EnableHamForward(hookKilled)
EnableHamForward(hookDamage)
EnableHamForward(hookTrace)
EnableHamForward(hookUseGame)
EnableHamForward(hookUseStrip)
}
// create stripper of player equipments
if(!striper)
striper = create_entity("player_weaponstrip")
if(!is_valid_ent(striper)){
log_amx("ERROR! Unable to init weapon striper functions.")
set_fail_state("unable to create striper")
}
if(get_pcvar_num(cvar[CVAR_MAPCHANGES_STYLE]) && !get_cvar_num(cvar[CVAR_MAPCHOOSER_TYPE]))
mapchooser_detect()
// infinity ammo
hookMsgAmmoX = register_message(AmmoX,"MSG_AmmoX")
// block weapon pickup draw icon
hookMsgWeapPickup = register_message(WeapPickup,"MSG_BlockDraw")
hookMsgAmmoPickup = register_message(AmmoPickup,"MSG_BlockDraw")
set_pcvar_num(cvar[CVAR_ENABLED],true)
ggActive = true
ExecuteForward(fwdState,fwdRet,ggActive)
if(!cvarState){
new players[32],pnum
get_players(players,pnum)
#if defined AGHL_COLOR
new bool:rmb
#endif
for(new i,player ; i < pnum ; i++){
player = players[i]
#if defined AGHL_COLOR
rmb = playersData[player][PLAYER_AGHL]
#endif
client_putinserver(player)
#if defined AGHL_COLOR
playersData[rmb][PLAYER_AGHL] = rmb
#endif
if(is_user_alive(player))
Equip_PlayerWithWeapon(player)
}
gg_notify_msg(0,NOTIFY_ENABLED)
}
Map_LockItems(true)
}
//
// Disable GunGame plugin
//
public Disable_GunGame(){
if(ggActive){
DisableHamForward(hookSpawn)
DisableHamForward(hookKilled)
DisableHamForward(hookDamage)
DisableHamForward(hookTrace)
DisableHamForward(hookUseGame)
DisableHamForward(hookUseStrip)
unregister_message(AmmoX,hookMsgAmmoX)
unregister_message(WeapPickup,hookMsgWeapPickup)
unregister_message(AmmoPickup,hookMsgAmmoPickup)
set_pcvar_num(cvar[CVAR_ENABLED],false)
ggActive = false
new players[32],pnum
get_players(players,pnum)
for(new i,player ; i < pnum ; i++){
player = players[i]
if(task_Hud_Id && !playersData[player][PLAYER_BOT])
ClearSyncHud(player,syncInformerHud) // reset hud
Reset_RefilTasks(player) // reset refil tasks
StatusIcon_Display(player,3)
remove_task(task_Icon_Blink + player)
remove_task(task_Hud_Id + player)
remove_task(task_Equip_Id + player)
remove_task(task_Change_Id + player)
}
warmUpMode = 0
remove_task(task_WarmUp_Id)
remove_task(task_ProLevel_Id)
remove_task(task_EntRemove_Id)
gg_notify_msg(0,NOTIFY_DISABLED)
Map_LockItems(false)
ExecuteForward(fwdState,fwdRet,ggActive)
}
}
public plugin_natives(){
register_library("gungame")
register_native("gg_get_max_level","api_get_max_level")
register_native("gg_get_level_data","api_get_level_data")
register_native("gg_get_player_level","api_get_player_level")
register_native("gg_set_player_level","api_set_player_level")
register_native("gg_equip_force","api_equip_force",true)
}
// parse configuration files
// thanks to Safety1st for his tips
public load_cfg(){
new mapName[32],cfgFilePath[512],cfgFileLen,bool:isMapCfg
get_mapname(mapName,charsmax(mapName))
// build path for config folder
cfgFileLen = get_configsdir(cfgFilePath,charsmax(cfgFilePath))
cfgFileLen += formatex(cfgFilePath[cfgFileLen],charsmax(cfgFilePath) - cfgFileLen,"/gungame/")
// check that we have map config
formatex(cfgFilePath[cfgFileLen],charsmax(cfgFilePath) - cfgFileLen,"%s.ini",mapName)
if(file_exists(cfgFilePath))
isMapCfg = true
cfgFilePath[cfgFileLen] = 0 // keep our path clean
new cfgFile[30]
get_pcvar_string(cvar[CVAR_CFGFILE],cfgFile,charsmax(cfgFile))
copy(cfgFileWas,charsmax(cfgFileWas),cfgFile)
formatex(cfgFilePath[cfgFileLen],charsmax(cfgFilePath) - cfgFileLen,cfgFileWas)
new Trie:keyTrie = TrieCreate()
static Trie:hamHooks
for(new i ; i < keyNames ; ++i) // i'm realy lazy for write few strings of code, lets do amxx dirty work
TrieSetCell(keyTrie,setKeys[i],i)
new f = fopen(cfgFilePath,"rt")
new buffer[512],lineCount
if(f){
#define CFG_BLOCK_NONE 0
#define CFG_BLOCK_CVARS 1
#define CFG_BLOCK_WEAPONS 2
#define CFG_BLOCK_MODSETTINGS 3
#define CFG_MOD_NONE 0
#define CFG_MOD_OFFSETS 1
#define CFG_MOD_BLOCKSPAWN 2
#define CFG_MOD_WARMUP 3
#define CFG_MOD_WEAPONLIST 4
#define CFG_LEVEL_NONE 0
#define CFG_LEVEL_MAIN 1
#define CFG_LEVEL_EQUIP 2
#define CFG_LEVEL_WEAPON 3
#define CFG_LEVEL_INFLICTORS 4
new currentBlockId // cfg vars
new modName[20] // mod settings vars
new modBlockId = CFG_MOD_NONE
get_cvar_pointer("sv_ag_version") ? copy(modName,charsmax(modName),"agmini") : get_modname(modName,charsmax(modName))
if(strcmp(modName,"valve") == 0)
isValve = true
else if(strcmp(modName,"agmini") == 0 || strcmp(modName,"ag") == 0)
isAG = true
while(!feof(f)){
fgets(f,buffer,charsmax(buffer))
trim(buffer)
lineCount ++
// skip comments and empty lines
if(!buffer[0] || buffer[0] == ';' || contain(buffer,"//") == 0)
continue
switch(currentBlockId){
case CFG_BLOCK_NONE:{
if(buffer[0] == '<'){
if(strcmp(buffer,"<cvars>") == 0)
currentBlockId = CFG_BLOCK_CVARS
else if(strcmp(buffer,"<sets>") == 0)
currentBlockId = CFG_BLOCK_WEAPONS
else if(strcmp(buffer,"<mods>") == 0)
currentBlockId = CFG_BLOCK_MODSETTINGS
}
}
case CFG_BLOCK_CVARS:{ // parse cvar block
if(buffer[0] == '<'){
if(strcmp(buffer,"</cvars>") == 0)
currentBlockId = CFG_BLOCK_NONE
continue
}
new cvarName[40],cvarValue[256],cvarId
parse(buffer,cvarName,charsmax(cvarName),cvarValue,charsmax(cvarValue))
cvarId = get_cvar_pointer(cvarName)
if(cvarId){
set_pcvar_string(cvarId,cvarValue)
}else{
log_amx("WARNING! Unknown cvar ^"%s^" on line %d",cvarName,lineCount)
}
}
case CFG_BLOCK_WEAPONS:{ // parse weapons block
if(isMapCfg){ // we will parse weapons block later
currentBlockId = CFG_BLOCK_NONE
continue
}
if(buffer[0] == '<'){
if(strcmp(buffer,"</sets>") == 0){
currentBlockId = CFG_BLOCK_NONE
continue
}
}
Parse_WeaponSets(buffer,lineCount,keyTrie,hamHooks,false)
}
case CFG_BLOCK_MODSETTINGS:{ // parse mod settings
if(buffer[0] == '<'){
if(strcmp(buffer,"</mods>") == 0){
currentBlockId = CFG_BLOCK_NONE
continue
}
}
if(!modFound){
if(buffer[0] == '<'){
new checkingMod[12]
new endBracket = strfind(buffer,">")
if(endBracket == -1)
continue
if(strlen(buffer) > charsmax(checkingMod))
continue
formatex(checkingMod,strlen(buffer) - 2,"%s",buffer[1])
if(strcmp(checkingMod,modName) == 0)
modFound = true
}
continue
}
switch(modBlockId){
case CFG_MOD_NONE:{
if(buffer[0] == '<'){
new tagKey[20]
new endBracket = strfind(buffer,">")
if(endBracket == -1)
continue
if(strlen(buffer) > charsmax(tagKey))
continue
formatex(tagKey,strlen(buffer) - 2,"%s",buffer[1])
if(strcmp(tagKey,"offsets") == 0)
modBlockId = CFG_MOD_OFFSETS
else if(strcmp(tagKey,"blockspawn") == 0)
modBlockId = CFG_MOD_BLOCKSPAWN
else if(strcmp(tagKey,"weaponlist") == 0)
modBlockId = CFG_MOD_WEAPONLIST
else if(strcmp(tagKey,"warmup") == 0){
modBlockId = CFG_MOD_WARMUP
Parse_WeaponSets(buffer,lineCount,keyTrie,hamHooks,true)
}else if(strcmp(tagKey[1],modName) == 0) // mod settings parse finished
currentBlockId = CFG_BLOCK_NONE
}else{
new keyName[20],keyValue[64]
strtok(buffer,keyName,charsmax(keyName),keyValue,charsmax(keyValue),'=',1)
replace(keyValue,charsmax(keyValue),"=","")
trim(keyValue)
if(strcmp(keyName,"name") == 0)
copy(gameName,charsmax(gameName),keyValue)
}
}
case CFG_MOD_OFFSETS:{ // parse offsets block
if(strcmp(buffer,"</offsets>") == 0){ // offsets block parse finished
modBlockId = CFG_MOD_NONE
continue
}
new offsetName[30],offsetDiff[10]
strtok(buffer,offsetName,charsmax(offsetName),offsetDiff,charsmax(offsetDiff),'=',1)
// TODO: check out new strtok2 native in AMXX 1.8.3
replace(offsetDiff,charsmax(offsetDiff),"=","")
trim(offsetDiff)
for(new i ; i < sizeof offsetsForMe ; ++i){
if(strcmp(offsetName,offsetsForMe[i]) == 0)
modOffsets[i] = str_to_num(offsetDiff)
}
}
case CFG_MOD_BLOCKSPAWN:{
if(strcmp(buffer,"</blockspawn>") == 0){ // block spawn parse finished
modBlockId = CFG_MOD_NONE
continue
}
if(!ggblockedItems)
ggblockedItems = ArrayCreate(32)
ArrayPushString(ggblockedItems,buffer)
}
case CFG_MOD_WARMUP:{
if(strcmp(buffer,"</warmup>") == 0){
Parse_WeaponSets(buffer,lineCount,keyTrie,hamHooks,true)
modBlockId = CFG_MOD_NONE
continue
}
Parse_WeaponSets(buffer,lineCount,keyTrie,hamHooks,true)
}
case CFG_MOD_WEAPONLIST:{
if(strcmp(buffer,"</weaponlist>") == 0){
modBlockId = CFG_MOD_NONE
continue
}
new weaponName[32],szData[4][10]
parse(buffer,weaponName,charsmax(weaponName),
szData[0],charsmax(szData[]),
szData[1],charsmax(szData[]),
szData[2],charsmax(szData[]),
szData[3],charsmax(szData[])
)
if(!ammoMaxMap)
ammoMaxMap = TrieCreate()
if(!weaponAmmoTrie)
weaponAmmoTrie = TrieCreate()
new ammoKey[10]
new weaponAmmo[weaponAmmoStruct]
weaponAmmo[WAMMO_PRIMARY_AMMOID] = str_to_num(szData[0])
weaponAmmo[WAMMO_PRIMARY_MAXAMMO] = str_to_num(szData[1])
weaponAmmo[WAMMO_SECONDARY_AMMOID] = str_to_num(szData[2])
weaponAmmo[WAMMO_SECONDARY_MAXAMMO] = str_to_num(szData[3])
// set ammo map
for(new i ; i < 2; i++){
if(weaponAmmo[WAMMO_PRIMARY_AMMOID + i] == -1)
continue
num_to_str(weaponAmmo[WAMMO_PRIMARY_AMMOID + i],ammoKey,charsmax(ammoKey))
TrieSetCell(ammoMaxMap,ammoKey,weaponAmmo[WAMMO_PRIMARY_MAXAMMO + i])
}
// set weapon ammo details
TrieSetArray(weaponAmmoTrie,weaponName,weaponAmmo,weaponAmmoStruct)
//modOffsets[msgWeaponList] = -1
}
}
}
}
}
fclose(f)
}
if(isMapCfg){
cfgFilePath[cfgFileLen] = 0 // keep our path clean
formatex(cfgFileWas,charsmax(cfgFileWas),"%s.ini",mapName)
formatex(cfgFilePath[cfgFileLen],charsmax(cfgFilePath) - cfgFileLen,cfgFileWas)
new f = fopen(cfgFilePath,"rt")
buffer[0] = 0
lineCount = 0
while(!feof(f)){
fgets(f,buffer,charsmax(buffer))
trim(buffer)
lineCount ++
// skip comments and empty lines
if(!buffer[0] || buffer[0] == ';' || contain(buffer,"//") == 0)
continue
Parse_WeaponSets(buffer,lineCount,keyTrie,hamHooks,false)
}
fclose(f)
}
TrieDestroy(keyTrie)
/*if(hamHooks)
TrieDestroy(hamHooks)*/
}
//#define âîçâðàùåíèå_îëîâà return
#define ITEM_FLAG_SELECTONEMPTY 1
#define ITEM_FLAG_NOAUTORELOAD 2
#define ITEM_FLAG_NOAUTOSWITCHEMPTY 4
#define ITEM_FLAG_LIMITINWORLD 8
#define ITEM_FLAG_EXHAUSTIBLE 16
// parse weapon list
public MSG_WeaponList(MsgDEST,MsgID,id){
#define argWeaponName 1
#define argPrimaryAmmoId 2
#define argPrimaryAmmoMaxAmount 3
#define argSecondaryAmmoId 4
#define argSecondaryAmmoMaxAmount 5
#define argSlotId 6
#define argNumberInSlot 7
#define argWeaponID 8
#define argFlags 9
// TODO: recheck item flags
static bool:weaponListInited
if(weaponListInited) // weapon list is already parsed
return PLUGIN_CONTINUE
static Float:lastInited
if(lastInited && lastInited != get_gametime()){ // all weapons info are sending to client at same time
weaponListInited = true
return PLUGIN_CONTINUE
}
lastInited = get_gametime()
if(!ammoMaxMap)
ammoMaxMap = TrieCreate()
if(!weaponAmmoTrie)
weaponAmmoTrie = TrieCreate()
new weaponName[32]
new ammoKey[10]
new weaponAmmo[weaponAmmoStruct]
get_msg_arg_string(argWeaponName,weaponName,charsmax(weaponName))
weaponAmmo[WAMMO_PRIMARY_AMMOID] = get_msg_arg_int(argPrimaryAmmoId)
weaponAmmo[WAMMO_PRIMARY_MAXAMMO] = get_msg_arg_int(argPrimaryAmmoMaxAmount)
weaponAmmo[WAMMO_SECONDARY_AMMOID] = get_msg_arg_int(argSecondaryAmmoId)
weaponAmmo[WAMMO_SECONDARY_MAXAMMO] = get_msg_arg_int(argSecondaryAmmoMaxAmount)
// set ammo map
for(new i ; i < 2; i++){
if(weaponAmmo[WAMMO_PRIMARY_AMMOID + i] == -1)
continue
num_to_str(weaponAmmo[WAMMO_PRIMARY_AMMOID + i],ammoKey,charsmax(ammoKey))
TrieSetCell(ammoMaxMap,ammoKey,weaponAmmo[WAMMO_PRIMARY_MAXAMMO + i])
}
// set weapon ammo details
TrieSetArray(weaponAmmoTrie,weaponName,weaponAmmo,weaponAmmoStruct)
#if defined HLWPNMOD
if(wpnmod_get_weapon_info(get_msg_arg_int(argWeaponID),ItemInfo_bCustom)){
if(!wpnModMap)
wpnModMap = TrieCreate()
TrieSetCell(wpnModMap,weaponName,true)
}
#endif
return PLUGIN_CONTINUE
}
public MSG_BlockDraw(MsgDEST,MsgID,player){
return PLUGIN_HANDLED
}
new Trie:mapItems
//
// Hook state meaning:
// 0 - new hook
// 1 - active hook
// 2 - disabled hook
//
enum _:mapItemsHooks {
HamHook:HOOK_TOUCH,
HamHook:HOOK_SPAWN,
HamHook:HOOK_THINK,
HOOK_STATE
}
//
// Lock some items on map
//
Map_LockItems(bool:lock){
if(!mapItems && !lock)
return
new entCount = entity_count()
new classname[32]
for(new i,count = ArraySize(ggblockedItems) ; i < count ; ++i){
ArrayGetString(ggblockedItems,i,classname,charsmax(classname))
if(strfind(classname,"*") == -1){
if(!mapItems)
mapItems = TrieCreate()
Item_SetLock(classname,0,lock,true)
}
}
// Loop throught all entites
for(new ent = MaxClients + 1 ; ent <= entCount ; ent++){
if(is_valid_ent(ent) && Item_LockCheck(ent)){ // find our blocked entity
entity_get_string(ent,EV_SZ_classname,classname,charsmax(classname))
Item_SetLock(classname,ent,lock)
}
}
}
Item_SetLock(classname[32],ent,bool:lock = true,bool:special = false){
if(!mapItems)
mapItems = TrieCreate()
new itemHooks[mapItemsHooks]
if(lock){ // lock this entity
if(!TrieGetArray(mapItems,classname,itemHooks,sizeof itemHooks) || itemHooks[HOOK_STATE] == 0){ // set block hooks
itemHooks[HOOK_TOUCH] = _:RegisterHam(Ham_Touch,classname,"Item_BlockHook")
itemHooks[HOOK_SPAWN] = _:RegisterHam(Ham_Spawn,classname,!special ? "Item_SpawnHook" : "HS_EntitySpawnBlock",true)
itemHooks[HOOK_THINK] = _:RegisterHam(Ham_Think,classname,"Item_SpawnHook",true)
itemHooks[HOOK_STATE] = 1
TrieSetArray(mapItems,classname,itemHooks,sizeof itemHooks)
}else if(itemHooks[HOOK_STATE] == 2){ // reenable exists hooks
EnableHamForward(itemHooks[HOOK_TOUCH])
EnableHamForward(itemHooks[HOOK_SPAWN])
//EnableHamForward(itemHooks[HOOK_THINK])
itemHooks[HOOK_STATE] = 1
TrieSetArray(mapItems,classname,itemHooks,sizeof itemHooks)
}
// hide it
if(is_valid_ent(ent)){
if(entity_get_int(ent,EV_INT_movetype))
entity_set_int(ent,EV_INT_effects,entity_get_int(ent,EV_INT_effects) | EF_NODRAW)
if(entity_get_float(ent,EV_FL_takedamage) != DAMAGE_NO){
entity_set_float(ent,EV_FL_fuser1,entity_get_float(ent,EV_FL_takedamage))
entity_set_float(ent,EV_FL_takedamage,DAMAGE_NO)
}
}else{
new targetEnt
while((targetEnt = find_ent_by_class(targetEnt,classname))){
if(entity_get_int(targetEnt,EV_INT_movetype))
entity_set_int(targetEnt,EV_INT_effects,entity_get_int(targetEnt,EV_INT_effects) | EF_NODRAW)
entity_set_float(targetEnt,EV_FL_fuser1,entity_get_float(targetEnt,EV_FL_takedamage))
entity_set_float(targetEnt,EV_FL_takedamage,DAMAGE_NO)
}
}
}else{ // unlock this entity
if(TrieGetArray(mapItems,classname,itemHooks,sizeof itemHooks) && itemHooks[HOOK_STATE] == 1){
DisableHamForward(itemHooks[HOOK_TOUCH])
DisableHamForward(itemHooks[HOOK_SPAWN])
DisableHamForward(itemHooks[HOOK_THINK])
itemHooks[HOOK_STATE] = 2
TrieSetArray(mapItems,classname,itemHooks,sizeof itemHooks)
}
// show int
if(is_valid_ent(ent)){
if(entity_get_int(ent,EV_INT_movetype))
entity_set_int(ent,EV_INT_effects,entity_get_int(ent,EV_INT_effects) & ~EF_NODRAW)
if(entity_get_float(ent,EV_FL_fuser1))
entity_set_float(ent,EV_FL_takedamage,entity_get_float(ent,EV_FL_fuser1))
}else{ // pisal buhim, hz 4to za func
new targetEnt
while((targetEnt = find_ent_by_class(targetEnt,classname))){
if(entity_get_int(targetEnt,EV_INT_movetype))
entity_set_int(targetEnt,EV_INT_effects,entity_get_int(targetEnt,EV_INT_effects) & ~EF_NODRAW)
if(entity_get_float(targetEnt,EV_FL_fuser1))
entity_set_float(targetEnt,EV_FL_takedamage,entity_get_float(targetEnt,EV_FL_fuser1))
}
}
}
}
//
// Block touch while gungame runing
//
public Item_BlockHook(ent){
if(entity_get_int(ent,EV_INT_spawnflags) & SF_NORESPAWN)
return HAM_IGNORED
return HAM_SUPERCEDE
}
//
// Hide entity on spawn while gungame runing
//
public Item_SpawnHook(ent){
if(!is_valid_ent(ent))
return HAM_IGNORED
new classname[32]
entity_get_string(ent,EV_SZ_classname,classname,31)
if(entity_get_int(ent,EV_INT_spawnflags) & SF_NORESPAWN)
return HAM_IGNORED
if(entity_get_int(ent,EV_INT_movetype))
entity_set_int(ent,EV_INT_effects,entity_get_int(ent,EV_INT_effects) | EF_NODRAW)
if(entity_get_float(ent,EV_FL_takedamage) != DAMAGE_NO){
entity_set_float(ent,EV_FL_fuser1,entity_get_float(ent,EV_FL_takedamage))
entity_set_float(ent,EV_FL_takedamage,DAMAGE_NO)
}
return HAM_IGNORED
}
Item_LockCheck(ent){
new classname[32],checkClassName[32]
entity_get_string(ent,EV_SZ_classname,classname,charsmax(classname))
for(new i,count = ArraySize(ggblockedItems) ; i < count ; ++i){
ArrayGetString(ggblockedItems,i,checkClassName,charsmax(checkClassName))
if(strfind(checkClassName,"*") == -1)
continue
else
checkClassName[strlen(checkClassName) - 1] = 0
if(contain(classname,checkClassName) == 0)
return true
}
return false
}
//
// Prevent entity from spawn
//
public HS_EntitySpawnBlock(ent){
set_task(0.1,"ENT_DelayedRemove",task_EntRemove_Id + ent)
//return HAM_SUPERCEDE
}
//
// I realy no have idea why instant removing crashes linux server.
// Just leave as is :D
//
public ENT_DelayedRemove(taskId){
new ent = taskId - task_EntRemove_Id
if(is_valid_ent(ent))
remove_entity(ent)
}
public HS_BlockUse(ent)
return HAM_SUPERCEDE
public HS_DisableAutoSwitch(ent){
SetHamReturnInteger(true)
return HAM_OVERRIDE
}
public block_drop(){
if(ggActive)
return PLUGIN_HANDLED
return PLUGIN_CONTINUE
}
public Play_ProLevelMusic(){
client_cmd(0,"mp3 play ^"%s^"",prolevel_music)
if(proLevelLoop)
set_task(proLevelLoop,"Play_ProLevelMusic",task_ProLevel_Id)
}
// check equipment for valid
public Test_ValidEnt(classname[]){
return true
// TODO: figure out why create entity in precache cause DOD crash
/*
new testEnt = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,classname))
if(!is_valid_ent(testEnt))
return false
else
remove_entity(testEnt)
return true
*/
}
// parse level set
// narkoman configurtaion file format
public Parse_WeaponSets(buffer[],lineCount,Trie:keyTrie,&Trie:hamHooks,bool:warmUp){
static weaponSet[weaponSetStruct],equipItem[equipStruct]
static setBlockId
switch(setBlockId){
case CFG_LEVEL_NONE:{
if(buffer[0] == '<'){
if(strcmp(buffer,!warmUp ? "<level>" : "<warmup>") == 0){ // new level block
arrayset(weaponSet,0,weaponSetStruct)
setBlockId = CFG_LEVEL_MAIN
}
}
}
case CFG_LEVEL_MAIN:{ // parse level vars
if(buffer[0] == '<'){
if(strcmp(buffer,!warmUp ? "</level>" : "</warmup>") == 0){ // level block read finished
setBlockId = CFG_LEVEL_NONE
if(!weaponSet[WSET_EQUIP_ITEMS])
return
if(!weaponSet[WSET_SHOWNAME][0]){
ArrayGetArray(weaponSet[WSET_EQUIP_ITEMS],0,equipItem)
copy(weaponSet[WSET_SHOWNAME],
charsmax(weaponSet[WSET_SHOWNAME]),
equipItem[EQUIP_NAME]
)
replace(weaponSet[WSET_SHOWNAME],charsmax(weaponSet[WSET_SHOWNAME]),"weapon_","")
ucfirst(weaponSet[WSET_SHOWNAME])
}
if(!weaponSets && !warmUp)
weaponSets = ArrayCreate(weaponSetStruct)
else if(!warmUpSet && warmUp)
warmUpSet = ArrayCreate(weaponSetStruct)
if(!warmUp)
ArrayPushArray(weaponSets ,weaponSet) // push the level data
else
ArrayPushArray(warmUpSet,weaponSet) // push the level data
return
}else if(strcmp(buffer,"<equip>") == 0){ // equip block start
setBlockId = CFG_LEVEL_EQUIP
return
}else if(strcmp(buffer,"<inflictors>") == 0){ // inflictors calssname for this weapon
setBlockId = CFG_LEVEL_INFLICTORS
return
}
}
// TODO: checkout new strtok2 native
new keyName[20],keyValue[40]
strtok(buffer,keyName,charsmax(keyName),keyValue,charsmax(keyValue),'=',1)
replace(keyValue,charsmax(keyValue),"=","")
trim(keyValue)
new keyId
if(!TrieGetCell(keyTrie,keyName,keyId))
return
switch(keyId){
case KEYSET_SHOWNAME: copy(weaponSet[WSET_SHOWNAME],charsmax(weaponSet[WSET_SHOWNAME]),keyValue)
case KEYSET_KILLS: weaponSet[WSET_KILLS] = str_to_num(keyValue)
case KEYSET_SKIP: weaponSet[WSET_SKIP] = str_to_num(keyValue)
case KEYSET_ICONSPRITE: copy(weaponSet[WSET_ICONSPRITE],charsmax(weaponSet[WSET_ICONSPRITE]),keyValue)
case KEYSET_BOTCANT: weaponSet[WSET_BOTCANT] = str_to_num(keyValue) == 1
default: log_amx("WARNING! Unknown key ^"%s^" on line %d",keyName,lineCount)
}
}
case CFG_LEVEL_EQUIP:{
if(buffer[0] == '<'){
if(strcmp(buffer,"</equip>") == 0){
setBlockId = CFG_LEVEL_MAIN
return
}
}
if(buffer[0] == '<' && buffer[strlen(buffer) - 1] == '>'){
arrayset(equipItem,0,equipStruct)
formatex(equipItem[EQUIP_NAME],strlen(buffer) - 2,"%s",buffer[1])
equipItem[EQUIP_FULL_PRIMARY] = 1
equipItem[EQUIP_FULL_SECONDARY] = 1
equipItem[EQUIP_CLIP] = -1
setBlockId = CFG_LEVEL_WEAPON
}else{
#if !defined HLWPNMOD
if(!Test_ValidEnt(buffer)){
log_amx("WARNING! Invalid equipment ^"%s^" on line %d",buffer,lineCount)
return
}
#endif
arrayset(equipItem,0,equipStruct)
copy(equipItem[EQUIP_NAME],charsmax(equipItem[EQUIP_NAME]),buffer)
equipItem[EQUIP_FULL_PRIMARY] = 1
equipItem[EQUIP_FULL_SECONDARY] = 1
equipItem[EQUIP_CLIP] = -1
if(weaponSet[WSET_EQUIP_ITEMS] == Invalid_Array)
weaponSet[WSET_EQUIP_ITEMS] = _:ArrayCreate(equipStruct)
ArrayPushArray(weaponSet[WSET_EQUIP_ITEMS],equipItem)
}
}
case CFG_LEVEL_WEAPON:{
if(buffer[0] == '<'){
new tmp[40]
formatex(tmp,charsmax(tmp),"</%s>",equipItem[EQUIP_NAME])
if(strcmp(buffer,tmp) == 0){
if(weaponSet[WSET_EQUIP_ITEMS] == Invalid_Array)
weaponSet[WSET_EQUIP_ITEMS] = _:ArrayCreate(equipStruct)
ArrayPushArray(weaponSet[WSET_EQUIP_ITEMS],equipItem)
setBlockId = CFG_LEVEL_EQUIP
}
return
}
new keyName[20],keyValue[40]
strtok(buffer,keyName,charsmax(keyName),keyValue,charsmax(keyValue),'=',1)
replace(keyValue,charsmax(keyValue),"=","")
trim(keyValue)
new keyId
if(!TrieGetCell(keyTrie,keyName,keyId))
return
switch(keyId){
case KEYSET_REFIL_TIME_1: equipItem[EQUIP_PRIMARY_REFIL_TIME] = _:(str_to_float(keyValue) ? str_to_float(keyValue) : -1.0)
case KEYSET_REFIL_AMMOUNT_1: equipItem[EQUIP_PRIMARY_REFIL_AMMOUNT] = str_to_num(keyValue) ? str_to_num(keyValue) : 1
case KEYSET_DISABLE_FULLAMO_1: equipItem[EQUIP_FULL_PRIMARY] = !str_to_num(keyValue)
case KEYSET_REFIL_TIME_2: equipItem[EQUIP_SECONDARY_REFIL_TIME] = _:(str_to_float(keyValue) ? str_to_float(keyValue) : -1.0)
case KEYSET_REFIL_AMMOUNT_2: equipItem[EQUIP_SECONDARY_REFIL_AMMOUNT] = str_to_num(keyValue) ? str_to_num(keyValue) : 1
case KEYSET_DISABLE_FULLAMO_2: equipItem[EQUIP_FULL_SECONDARY] = !str_to_num(keyValue)
case KEYSET_CLIP: equipItem[EQUIP_CLIP] = str_to_num(keyValue)
default: log_amx("WARNING! Unknown key ^"%s^" on line %d",keyName,lineCount)
}
}
case CFG_LEVEL_INFLICTORS:{
if(buffer[0] == '<'){
if(strcmp(buffer,"</inflictors>") == 0){
setBlockId = CFG_LEVEL_MAIN
return
}
}
if(weaponSet[WSET_INFLICTORS_MAP] == Invalid_Trie)
weaponSet[WSET_INFLICTORS_MAP] = _:TrieCreate()
new parseInf[3][36]
parse(buffer,parseInf[0],charsmax(parseInf[]),
parseInf[1],charsmax(parseInf[]),
parseInf[2],charsmax(parseInf[])
)
new inflictorData[4]
inflictorData[0] = str_to_num(parseInf[1]) // limit
inflictorData[1] = str_to_num(parseInf[2]) // allow damage from other players flag
TrieSetArray(weaponSet[WSET_INFLICTORS_MAP],parseInf[0],inflictorData,sizeof inflictorData)
if(inflictorData[0]){ // register limit handler
if(!Test_ValidEnt(parseInf[0])){
log_amx("WARNING! Invalid inflictor item ^"%s^" on line %d",parseInf[0],lineCount)
return
}
if(!weaponSet[WSET_INFARRAY])
weaponSet[WSET_INFARRAY] = _:ArrayCreate(32)
ArrayPushString(weaponSet[WSET_INFARRAY],parseInf[0])
if(!hamHooks)
hamHooks = TrieCreate()
if(TrieKeyExists(hamHooks,parseInf[0])) // already registred
return
else
TrieSetCell(hamHooks,parseInf[0],true) // new hook
RegisterHam(Ham_Spawn,parseInf[0],"Inflictors_SpawnHandler",true)
RegisterHam(Ham_Killed,parseInf[0],"Inflictors_DestroyHandler",true)
RegisterHam(Ham_Use,parseInf[0],"Inflictors_DestroyHandler",true)
RegisterHam(Ham_TakeDamage,parseInf[0],"Inflictors_DamageHandler",false)
}
}
}
}
//
// Player join server
//
public client_putinserver(id){
if(!ggActive)
return
arrayset(playersData[id],0,playersDataStruct)
playersData[id][PLAYER_LASTLEVEL] = -1
Update_PlayersRanks()
currentPlayers = get_playersnum()
playersData[id][PLAYER_BOT] = is_user_bot(id)
if(!playersData[id][PLAYER_BOT]){
#if defined AGHL_COLOR && !defined CSCOLOR
if(task_RequestColor_Id) // Check
set_task(0.1,"RequestColor_Task",task_RequestColor_Id + id)
#endif
if(autoSaveTime && autoSaveMap){
new authId[36],aSave[autoSaveStruct]
get_user_authid(id,authId,charsmax(authId))
if(TrieGetArray(autoSaveMap,authId,aSave,autoSaveStruct)){
if(aSave[ASAVE_TIME] + autoSaveTime > get_gametime()){
playersData[id][PLAYER_CURRENTLEVEL] = aSave[ASAVE_LEVEL]
playersData[id][PLAYER_KILLS] = aSave[ASAVE_KILLS]
}
TrieDeleteKey(autoSaveMap,authId)
}
}
if(!playersData[id][PLAYER_CURRENTLEVEL] && !get_pcvar_num(cvar[CVAR_TEAMPLAY])){
new handicap =get_pcvar_num(cvar[CVAR_HANDICAP])
if(handicap)
SetLevel_ForNewPlayer(id,handicap)
}
if(warmUpMode == 0 && get_pcvar_num(cvar[CVAR_WARMUP])){ // start warmup mode
warmUpMode = 1
new data[1]
data[0] = get_pcvar_num(cvar[CVAR_WARMUP])
set_task(1.0,"WarmUp_Timer",task_WarmUp_Id,data,sizeof data)
ExecuteForward(fwdWarmUpStart,fwdRet)
}else if(warmUpMode == 0)
warmUpMode = 2
if(proLevelPlayed && !isEndGame)
client_cmd(id,"mp3 play ^"%s^"",prolevel_music)
else if(isEndGame)
client_cmd(0,"mp3 play ^"%s^"",sound_winner)
}
}
public WarmUp_Timer(data[1]){
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 6.0, 0.7, 0.1, 0.2)
switch(warmUpMode){
case 1:{
if(!data[0]){
warmUpMode = 3
data[0] = 3
if(!isAG){
new players[32],pnum
get_players(players,pnum,"ah")
for(new i,player ; i < pnum ; ++i){
player = players[i]
if(checkPlayerSpectator(player) != -1)
continue
entity_set_vector(player,EV_VEC_velocity,Float:{0.0,0.0,0.0})
set_pev(player,pev_flags,pev(player,pev_flags) | FL_FROZEN)
}
}
}
}
case 3:{
if(!data[0]){
warmUpMode = 2
new players[32],pnum
get_players(players,pnum,"ah") // ah oh oh oh ah oh
show_hudmessage(0,"%L",LANG_PLAYER,"WARMUP_ROUND_OVER")
client_cmd(0,"spk buttons/bell1.wav")
ArrayDestroy(warmUpSet)
warmUpSet = Invalid_Array
ExecuteForward(fwdWarmUpEnd,fwdRet)
if(fwdRet == PLUGIN_HANDLED)
return
for(new i,player ; i < pnum ; ++i){
player = players[i]
if(checkPlayerSpectator(player) != -1)
continue
if(!isAG)
set_pev(player,pev_flags,pev(player,pev_flags) &~ FL_FROZEN)
ExecuteHam(Ham_Use,striper,player,player,1.0,0.0) // strip player's weapons
ExecuteHamB(Ham_Spawn,player)
}
return
}
}
}
if(warmUpMode == 3)
client_cmd(0,"spk buttons/blip1.wav")
show_hudmessage(0,"%L",LANG_PLAYER,warmUpMode == 1 ? "WARMUP_ROUND_DISPLAY" : "WARMUP_ROUND_PREPARE",data[0])
data[0] --
set_task(1.0,"WarmUp_Timer",task_WarmUp_Id,data,sizeof data)
}
//
// Check whatever player spectator or not
// @return
// -1 - no spectator
// 0 - free look mode
// player id - spectating player
//
stock checkPlayerSpectator(id){
new iUser1 = entity_get_int(id,EV_INT_iuser1)
new iUser2 = entity_get_int(id,EV_INT_iuser2)
if(iUser1 || iUser2)
return iUser2
return -1
}
//
// Set level for new player
// id - player id
// handicap - level calculation mode
//
public SetLevel_ForNewPlayer(id,handicap){
new players[32],pnum
get_players(players,pnum)
switch(handicap){
case 1:{ // calculate average level
new lvlSum
for(new i,player ; i < pnum ; ++i){
player = players[i]
if(checkPlayerSpectator(id) != -1)
continue
lvlSum += playersData[player][PLAYER_CURRENTLEVEL]
}
playersData[id][PLAYER_CURRENTLEVEL] = lvlSum / pnum
}
case 2:{ // calculate lowest level
new lowLvl = 9999
for(new i,player; i < pnum ; ++i){
player = players[i]
if(checkPlayerSpectator(id) != -1)
continue
if(playersData[player][PLAYER_CURRENTLEVEL] < lowLvl)
lowLvl = playersData[player][PLAYER_CURRENTLEVEL]
}
playersData[id][PLAYER_CURRENTLEVEL] = lowLvl
}
}
}
//
// Player disconnect
//
public client_disconnect(id){
if(!ggActive)
return
Reset_RefilTasks(id)
if(task_Hud_Id && !playersData[id][PLAYER_BOT])
remove_task(id + task_Hud_Id)
#if defined AGHL_COLOR && !defined CSCOLOR
if(task_RequestColor_Id && !playersData[id][PLAYER_BOT])
remove_task(id + task_RequestColor_Id)
#endif
currentPlayers --
Update_PlayersRanks()
if(autoSaveTime && !playersData[id][PLAYER_BOT]){
new aSave[autoSaveStruct]
aSave[ASAVE_LEVEL] = playersData[id][PLAYER_CURRENTLEVEL]
aSave[ASAVE_KILLS] = playersData[id][PLAYER_KILLS]
aSave[ASAVE_TIME] = _:get_gametime()
new authId[36]
get_user_authid(id,authId,charsmax(authId))
if(!autoSaveMap)
autoSaveMap = TrieCreate()
TrieSetArray(autoSaveMap,authId,aSave,autoSaveStruct)
}
if(proLevelPlayed || isEndGame)
client_cmd(id,"mp3 stop")
}
#if defined AGHL_COLOR && !defined CSCOLOR
public RequestColor_Task(taskId){
new id = taskId - task_RequestColor_Id
query_client_cvar(id,"hud_colortext","RequestColor_Handler")
}
public RequestColor_Handler(id,cvar[],value[])
playersData[id][PLAYER_AGHL] = str_to_num(value) == 1
#endif
public ggSpawnEquip = true
//
// Player spawn
//
public On_PlayerSpawn(id){
if(!ggSpawnEquip)
return HAM_IGNORED
if(!is_user_alive(id)){ // lalka style fix
if(isAG && entity_get_int(id,EV_INT_flags) != 8) // ya 8, a tbi - net azazazazaza
return HAM_IGNORED
set_task(0.1,"On_PlayerSpawn",id)
return HAM_IGNORED
}
if(is_user_alive(id)){
#if defined DODBOTFIX
if(!get_user_team(id))
return HAM_IGNORED
#endif
Equip_PlayerWithWeapon(id)
if(warmUpMode == 3)
set_pev(id,pev_flags,pev(id,pev_flags) | FL_FROZEN)
if(isEndGame){
set_user_godmode(id,true)
set_user_gravity(id,0.3)
set_user_maxspeed(id,9999.0) // da ya je freeman
set_pev(id,pev_flags,pev(id,pev_flags) | FL_FROZEN)
UTIL_ScreenFade(id,{0,0,0},get_pcvar_float(cvar[CVAR_ENDGAME_DELAY]) / 2.0,120.0,255,1)
}
}
return HAM_IGNORED
}
//
// Player kill
//
public On_PlayerKilled(victim,killer){
if(task_Hud_Id && !playersData[victim][PLAYER_BOT])
ClearSyncHud(victim,syncInformerHud) // reset hud
Reset_RefilTasks(victim) // reset refil tasks
StatusIcon_Display(victim,3)
if(!(0 < killer <= MaxClients)) // player was killed by world
return HAM_IGNORED
if(warmUpMode != 2 || playersData[killer][PLAYER_CURRENTLEVEL] != playersData[killer][PLAYER_LASTLEVEL])
return HAM_IGNORED
if(killer == victim && get_pcvar_num(cvar[CVAR_DESCORE]) && !get_pcvar_num(cvar[CVAR_TEAMPLAY])){ // descore function on selfkill
playersData[victim][PLAYER_KILLS] --
if(playersData[victim][PLAYER_KILLS] < 0){
if(playersData[victim][PLAYER_CURRENTLEVEL]){
playersData[victim][PLAYER_CURRENTLEVEL] --
//Equip_PlayerWithWeapon(victim)
}else // reset kills for frist level
playersData[victim][PLAYER_KILLS] = 0
}
return HAM_IGNORED
}else if(killer == victim)
return HAM_IGNORED
new inflictor = entity_get_edict(victim,EV_ENT_dmg_inflictor) // get inflictor id
Disculpenmen el codigo es muy largo y tuve que borrar gran parte del codigo, si no esta la linea del error igual dejo el archivo sma para que lo puedan descargar..
Saludos