im working on a hidden mod requested from Gangsta Bear, and now i tested it for the first time and i get some errors:
hope someone can help me with the code and tell me if i can do anything better,
and i need to know where to add !is_user_alive(id) and !is_user_connected(id) checks, if i need any
Code:
/*AMX Mod X script.
Copyright (C) 2005 Belsebub
The Hidden Mod comes with ABSOLUTELY NO WARRANTY.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
CREDITS
=======
Request By Gangsta Bear
BunnyHop Code From CheesyPeteza's BunnyHop Plugin
*/
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <engine>
//----------------------------------------------------------------------------------------------
new bool:Hidden[33] = false
new bool:IRIS[33] = false
new bool:Shotgun[33] = false
new bool:SMG[33] = false
new HiddenCount = 0
//----------------------------------------------------------------------------------------------
public plugin_init() {
register_plugin("The Hidden Mod","0.1","Belsebub")
//MENUS
register_menucmd(register_menuid("Hidden Menu:"),1023,"ActionMenu")
register_menucmd(register_menuid("Weapon Menu:"),1023,"ActionWeaponMenu")
//COMMANDS
register_clcmd("say /hiddenmenu","ShowMenu")
register_clcmd("say_team /hiddenmenu","ShowMenu")
//EVENTS
register_event("DeathMsg","Event_Death","a","2!0")
register_logevent("StartRound",2,"1=Round_Start")
register_event("ResetHUD", "Event_Resethud", "b")
register_event("CurWeapon", "Check_Speed", "be")
register_event("Damage", "Event_Damage", "b", "2!0")
register_event("TextMsg","Event_Hiddenbuy","b","2=#Cannot_Buy_This")
register_event("TextMsg","Event_Hiddenbuy","b","2=#Cant_buy")
register_event("TextMsg","Event_Hiddenbuy","b","2=#CT_cant_buy")
register_event("TextMsg","Event_Hiddenbuy","b","2=#Terrorist_cant_buy")
}
//----------------------------------------------------------------------------------------------
public plugin_precache() {
Disable_Buyzone()
}
//----------------------------------------------------------------------------------------------
public StartRound(id) {
new CsTeams:team = cs_get_user_team(id)
new players = get_playersnum(0)
new iPlayers[32], iNum = get_players( iPlayers, iNum )
if (HiddenCount == 0 && players >= 3) {
id = iPlayers[ random_num(0, iNum-1) ]
client_print(0, print_chat, "Randomly choosing a hidden")
Hidden[id] = true
HiddenCount++
return PLUGIN_CONTINUE
} else if (Hidden[id] == true && team == CS_TEAM_T) {
cs_set_user_team(id, CS_TEAM_CT, CS_CT_GIGN)
return PLUGIN_CONTINUE
} else if (IRIS[id] == true && team == CS_TEAM_CT){
cs_set_user_team(id, CS_TEAM_T, CS_T_ARCTIC)
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public Event_Resethud(id) {
if (Hidden[id] == true) {
set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,15)
set_user_health(id,250)
set_user_armor(id, 100)
set_user_maxspeed(id, 480.0)
give_item(id, "weapon_hegrenade")
give_item(id, "weapon_hegrenade")
client_print(id, print_center, "You Are The Hidden")
return PLUGIN_CONTINUE
} else if (IRIS[id] == true) {
if (Shotgun[id] == true) {
give_item(id, "weapon_m3")
cs_set_user_bpammo(id, CSW_M3, 24)
return PLUGIN_CONTINUE
} else if (SMG[id] == true) {
give_item(id, "weapon_p90")
cs_set_user_bpammo(id, CSW_P90, 50)
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public Check_Speed(id) {
new clip, ammo
new weapon = get_user_weapon(id,clip,ammo)
if(Hidden[id] == true) {
set_user_maxspeed(id, 480.0)
if (weapon == CSW_KNIFE || weapon == CSW_HEGRENADE) {
return PLUGIN_CONTINUE
} else {
client_cmd(id,"weapon_knife")
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public Disable_Buyzone() {
new ent = find_ent_by_class(-1,"info_map_parameters")
if(!ent) {
ent = create_entity("info_map_parameters")
}
DispatchKeyValue(ent,"buying","3")
DispatchSpawn(ent)
}
//----------------------------------------------------------------------------------------------
public Event_Hiddenbuy(id) {
client_print(id,print_center,"No buying - Hidden mod is on!")
}
//----------------------------------------------------------------------------------------------
public client_PreThink(id) {
if(Hidden[id] == true) {
entity_set_float(id, EV_FL_fuser2, 0.0)
if (entity_get_int(id, EV_INT_button) & 2)
{
new flags = entity_get_int(id, EV_INT_flags)
if (flags & FL_WATERJUMP)
return PLUGIN_CONTINUE
if ( entity_get_int(id, EV_INT_waterlevel) >= 2 )
return PLUGIN_CONTINUE
if ( !(flags & FL_ONGROUND) )
return PLUGIN_CONTINUE
new Float:velocity[3]
entity_get_vector(id, EV_VEC_velocity, velocity)
velocity[2] += 250.0
entity_set_vector(id, EV_VEC_velocity, velocity)
entity_set_int(id, EV_INT_gaitsequence, 6)
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public ShowMenu(id) {
new szMenuBody[512]
new keys
new len = format(szMenuBody, 511, "\yHidden Menu:^n" )
len += format( szMenuBody[len], 511-len, "^n\w1. Change Weapon (IRIS Only)" )
len += format( szMenuBody[len], 511-len, "^n\w2. Exit" )
keys = (1<<0|1<<1)
show_menu( id, keys, szMenuBody, -1 )
return PLUGIN_CONTINUE
}
//--------------------------------------------------------------------------------------------
public ActionMenu(id,key) {
switch(key)
{
case 0:
{
ShowWeaponMenu(id)
return PLUGIN_CONTINUE
}
case 1:
{
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public ShowWeaponMenu(id) {
if(IRIS[id] != true) {
client_print(id, print_center, "Only IRIS Can Change There Weapons.")
return PLUGIN_CONTINUE
}
new szMenuBody[512]
new keys
new len = format(szMenuBody, 511, "\yWeapon Menu:^n" )
len += format( szMenuBody[len], 511-len, "^n\w1. Shotgun" )
len += format( szMenuBody[len], 511-len, "^n\w2. SMG" )
len += format( szMenuBody[len], 511-len, "^n\w3. Exit" )
keys = (1<<0|1<<1|1<<2)
show_menu( id, keys, szMenuBody, -1 )
return PLUGIN_CONTINUE
}
//--------------------------------------------------------------------------------------------
public ActionWeaponMenu(id,key) {
switch(key)
{
case 0:
{
give_item(id, "weapon_m3")
cs_set_user_bpammo(id, CSW_M3, 24)
Shotgun[id] = true
return PLUGIN_CONTINUE
}
case 1:
{
give_item(id, "weapon_p90")
cs_set_user_bpammo(id, CSW_P90, 50)
SMG[id] = true
return PLUGIN_CONTINUE
}
case 2:
{
return PLUGIN_CONTINUE
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public client_disconnect(id) {
if (Hidden[id] == true) {
Hidden[id] = false
HiddenCount--
}
IRIS[id] = false
SMG[id] = false
Shotgun[id] = false
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public client_connect(id) {
Hidden[id] = false
IRIS[id] = true
SMG[id] = true
Shotgun[id] = false
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public client_putinserver (id)
{
set_task ( 20.0, "hidden_help" )
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public Event_Death(id) {
new killer = read_data(1)
new victim = read_data(2)
if (IRIS[killer] == true && Hidden[victim] == true) {
Hidden[victim] = false
set_user_rendering(victim, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 255)
Hidden[killer] = true
return PLUGIN_CONTINUE
} else if (IRIS[killer] == true && IRIS[victim] == true) {
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public hidden_help (id) {
client_print ( 0, print_chat, "Type /hiddenmenu to bring up the hidden menu." )
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public Event_Damage(victim) {
new weapon, bodypart, attacker = get_user_attacker(victim,weapon,bodypart)
new damage = read_data(2)
new victimhealth = get_user_health(victim)
if (attacker == 0)
return PLUGIN_CONTINUE
if (attacker == victim && weapon == 0)
return PLUGIN_CONTINUE
if(weapon == CSW_HEGRENADE) {
damage = floatround(float(damage) * 1.5)
if (damage>35 && victimhealth>35)
damage=25+random_num(0,10)
}
if (weapon == CSW_KNIFE)
damage = floatround(float(damage)*2.0)
if (victimhealth - damage<=15){
set_user_health(victim,random_num(1,victimhealth))
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------