PHP Code:
#if cellbits == 32
#define OFFSET_BUYZONE 235
#else
#define OFFSET_BUYZONE 268
#endif
Since you use cstrike, remove this.
PHP Code:
new const KZ_TOP15_DIR[] = "addons/amxmodx/configs/kz/top15"
new const KZ_DIR[] = "addons/amxmodx/configs/kz"
Don't hardcode paths.
PHP Code:
public resethud(id)
{
if( !user_has_weapon(id,CSW_KNIFE) )
give_item( id,"weapon_knife" )
if(firstspawn[id])
{
ColorChat(id, GREEN, "[XJ]^x01 Welcome to ^x03nucLeaRKz.Idle.Ro ^x01")
ColorChat(id, GREEN, "[XJ]^x01 Visit ^x03www.KZ-Romania.com ^x01")
if(get_pcvar_num(kz_checkpoints) == 0)
ColorChat(id, GREEN, "[XJ]^x01 Checkpoints are off.")
if(get_pcvar_num(kz_spawn_mainmenu) == 1)
kz_menu (id)
}
firstspawn[id] = false
return HAM_IGNORED
}
Use consistent returns, and don't use ResetHUD event instead of spawn.
PHP Code:
public curweapon(id)
{
new WeaponNum = read_data(2)
new WeaponActive = read_data(1)
if ((WeaponNum != g_WeaponUsed[id]) && WeaponActive) // if weapon has changed and its the active weapon continue
Put active condition in register_event native.
Would be better to use Ham_Item_Deploy for this, or Ham_CS_ResetPlayerMaxSpeed.
PHP Code:
message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "StatusText" ) , _, id )
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid( "RoundTime" ), _, id);
Cache msg type value.
PHP Code:
register_forward(FM_StartFrame, "fw_StartFrame")
This is not used.
PHP Code:
for(new i = 0; i < 8; i++)
if( user_has_weapon(id, other_weapons[i]) )
{
strip_user_weapons(id)
give_item(id,"weapon_knife")
give_item(id,"weapon_usp")
set_pdata_int(id, 382, 24, 5)
}
You forgot to exit the loop after code is executed.
PHP Code:
if( pev(id, pev_health) < 100 )
set_pev(id, pev_health, 100.0)
Use get_user_health and set_user_health.
PHP Code:
if( !DefaultStart )
{
new mapname[64]
get_mapname( mapname, 63)
kz_set_start(mapname, SavedStart[id])
ColorChat(id, GREEN, "[XJ]^x01 Start position set for this map.")
}
Cache mapname, it won't change during the current map...
PHP Code:
if( get_pdata_int(id, 114) == 2 )
Use cs_get_user_team.
More general, when you use pdatas, name them.
PHP Code:
RegisterHam( Ham_Spawn, "weaponbox", "FwdSpawnWeaponbox", 1 )
Remove weaponbox at this point won't remove linked weapons as well, better to hook Ham_Touch and to do the exacte same code as you made.
PHP Code:
if( is_user_connected( iPlayer ) && ( get_user_flags( iPlayer ) & KZ_LEVEL ) )
{
set_msg_arg_int( 2, ARG_BYTE, is_user_alive( iPlayer ) ? SCOREATTRIB_VIP : SCOREATTRIB_DEAD );
}
Replace connected check with alive, and then don't bother with SCOREATTRIB_DEAD in blobk.
PHP Code:
public msgStatusIcon( const iMsgId, const iMsgDest, const iPlayer )
{
static szMsg[ 8 ];
get_msg_arg_string( 2, szMsg, 7 );
if( equal( szMsg, "buyzone" ) )
{
set_pdata_int( iPlayer, OFFSET_BUYZONE, get_pdata_int( iPlayer, OFFSET_BUYZONE ) & ~( 1<<0 ) )
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
Here an example of what you can do at map start so you can disable buy :
Code:
public plugin_precache()
{
new iEnt = create_entity("info_map_parameters")
set_pdata_int(iEnt, 34, 3)
dllfunc(DLLFunc_Spawn, iEnt)
RegisterHam(Ham_Spawn, "info_map_parameters", "InfoMapParameters_Spawn")
Code:
public InfoMapParameters_Spawn( iEnt )
{
remove_entity(iEnt)
return HAM_SUPERCEDE
}
Code:
register_clcmd("buy", "ClientCommand_Buy")
register_clcmd("bUy", "ClientCommand_Buy")
register_clcmd("buY", "ClientCommand_Buy")
register_clcmd("bUY", "ClientCommand_Buy")
register_clcmd("Buy", "ClientCommand_Buy")
register_clcmd("BUy", "ClientCommand_Buy")
register_clcmd("BuY", "ClientCommand_Buy")
register_clcmd("BUY", "ClientCommand_Buy")
Code:
// This is only to prevent buy menu from opening, this menu wouldn't work anyway
public ClientCommand_Buy(id)
{
return PLUGIN_HANDLED_MAIN
}
PHP Code:
public plugin_end( )
{
TrieDestroy( g_tStarts )
TrieDestroy( g_tStops )
}
FYI, this is not needed.
PHP Code:
public timer_task()
{
for(new i=1;i<=MaxPlayers;i++)
Use get_players there, then you don't need to check if player is connected and you can also remove bots and hltvs.
Then you have 2 ways, use get_players twice, 1 with dead flag, 1 with alive flag (i would do this), the other way would be to check is_user_alive
PHP Code:
public client_command(id)
{
static szCmd[13]
read_argv(0, szCmd, 12)
static const commands_block[][] =
{
"radio1", "radio2", "radio3",
"coverme", "takepoint", "holdpos",
"regroup", "followme", "takingfire",
"go", "fallback", "sticktog",
"getinpos", "stormfront", "report",
"roger", "enemyspot", "needbackup",
"sectorclear", "inposition", "reportingin",
"getout", "negative", "enemydown",
"chooseteam", "jointeam 1"
}
static const drop_weapons[][] =
{
"drop"
}
if (get_pcvar_num(kz_use_radio) == 0)
for ( new i = 0 ; i < sizeof( commands_block ) ; i++ )
{
if(equal(szCmd, commands_block[i]))
return PLUGIN_HANDLED;
}
else
return PLUGIN_CONTINUE
if (get_pcvar_num(kz_drop_weapons) == 0)
for ( new i = 0 ; i < sizeof( drop_weapons ) ; i++ )
{
if(equal(szCmd, drop_weapons[i]))
return PLUGIN_HANDLED
}
else
return PLUGIN_CONTINUE
return PLUGIN_CONTINUE
}
Since you don't use equali, use register_clcmd instead of client_command forward.
Also, for radios, here is a better code :
Code:
public Player_Spawn( id )
{
if( is_user_alive( id ) )
{
// Set this pdata will let menu avalaible, but menu can't be used anyway.
// you can register radio menu commands and block them if you want.
#define XO_PLAYER 5
#define m_iRadiosLeft 192
set_pdata_int(id, m_iRadiosLeft, 0, XO_PLAYER)
}
PHP Code:
static const drop_weapons[][] =
{
"drop"
}
if (get_pcvar_num(kz_drop_weapons) == 0)
for ( new i = 0 ; i < sizeof( drop_weapons ) ; i++ )
{
if(equal(szCmd, drop_weapons[i]))
return PLUGIN_HANDLED
}
else
return PLUGIN_CONTINUE
I this this is a joke, loop a 1 dimension array...
But as said before, use register_clcmd instead.
PHP Code:
give_item(id,"weapon_usp")
give_item(id,"weapon_usp")
give_item(id,"weapon_usp")
... Use cs_set_user_bpammo.
PHP Code:
set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} );
set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING );
set_pev( id, pev_fuser2, 0.0 );
engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 18.0 } );
set_pev(id, pev_origin, Checkpoints[ id ][ !g_bCpAlternate[id] ] )
You use wrong values here, here are correct ones :
Code:
new const Float:VEC_DUCK_HULL_MIN[3] = {-16.0, -16.0, -18.0 }
new const Float:VEC_DUCK_HULL_MAX[3] = { 16.0, 16.0, 32.0 }
new const Float:VEC_DUCK_VIEW[3] = { 0.0, 0.0, 12.0 } // this one is for pev_view_ofs
PHP Code:
public noclip(id)
{
set_user_noclip(id, get_user_noclip(id) == 1 ? 0 : 1)
if(get_user_noclip(id) == 1)
detect_cheat(id,"Noclip")
ColorChat(id, GREEN, "[XJ]^x01 Noclip ^x03%s^x01", get_user_noclip(id) ? "ON" : "OFF")
return PLUGIN_HANDLED
}
public GodMode(id)
{
set_user_godmode(id, get_user_godmode(id) == 1 ? 0 : 1)
if(get_user_godmode(id) == 1)
detect_cheat(id,"God Mode")
ColorChat(id, GREEN, "[XJ]^x01 God Mode ^x03%s^x01", get_user_godmode(id) ? "ON" : "OFF")
return PLUGIN_HANDLED
}
You only need to use get_user_noclip ONCE here, same for get_user_godmode.
PHP Code:
public MenuHandler(id , menu, item)
{
if( item == MENU_EXIT ) {
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], name[32]
new access, callback
menu_item_getinfo(menu, item, access, data, 5, _, _, callback)
new key = str_to_num(data)
get_user_name(id, name, 31)
switch(key) {
case 1:{
CheckPoint(id)
kz_menu(id)
}
case 2:{
GoCheck(id)
kz_menu(id)
}
case 3:{
top15menu(id)
}
case 4:{
goStart(id)
kz_menu(id)
}
case 5:{
ShowTimer_Menu(id)
}
case 6:{
Pause(id)
kz_menu(id)
}
case 7:{
InvisMenu(id)
}
case 8:{
ct(id)
}
case 9:{
reset_checkpoints(id)
kz_menu(id)
}
case '*':{
}
}
return PLUGIN_HANDLED
}
get_user_name is not used
I doubt str_to_num('*') is equal to '*', instead of using menu_item_getinfo and str_to_num, you could directly use "item", item starts at 0 though, not 1.
Also, menus have an exit item by default, that one you check at the begining of your menu callback.
PHP Code:
case 9:
{
show_menu(id,0,"")
}
Same here, menu already has an exit item, 9 will never be triggered.
So, in all your menus, you don't need to use menu_item_getinfo and str_to_num, just use switch( item ) but instead of starting at 1, start at 0, and don't bother about exit thing (exept the item MENU_EXIT check, obviously), it is already handled by default by this menu system.
__________________