Raised This Month: $18 Target: $400
 4% 

Solved No Fall Demage Code Problem!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Supremache
Senior Member
Join Date: Sep 2019
Old 07-26-2020 , 18:41   No Fall Demage Code Problem!
Reply With Quote #1

Hello guys,
I have small problem i want help.
My question is: I was want to add no fall damage to bb mod and i have added some codes to plugin but nothing happening so where is the problem in those codes.

This is the defult
PHP Code:
public ham_TakeDamage(victiminflictorattackerFloat:damagedamagebits)
{
    if (!
is_valid_ent(victim) || !g_isAlive[victim] || !is_user_connected(attacker))
        return 
HAM_IGNORED
        
    
if(g_boolCanBuild || g_boolRoundEnded || g_boolPrepTime)
        return 
HAM_SUPERCEDE;

    if (
victim == attacker)
        return 
HAM_SUPERCEDE;
        
    if (
g_iSupercut)
    {
        
damage*=99.0
    
}
        
    
SetHamParamFloat(4damage)
    return 
HAM_HANDLED

What i did:
PHP Code:
public ham_TakeDamage(victiminflictorattackerFloat:damagedamagebits)
{
    if (!
is_valid_ent(victim) || !g_isAlive[victim] || !is_user_connected(attacker))
        return 
HAM_IGNORED
        
    
if(g_boolCanBuild || g_boolRoundEnded || g_boolPrepTime)
        return 
HAM_SUPERCEDE;

    if (
victim == attacker)
        return 
HAM_SUPERCEDE;
        
    if(
damagebits DMG_FALL)
        return 
HAM_SUPERCEDE;
        
    if (
g_iSupercut)
    {
        
damage*=99.0
    
}
        
    
SetHamParamFloat(4damage)
    return 
HAM_HANDLED

I added this but it's not work, can i get help ?
PHP Code:
if(damagebits DMG_FALL)
        return 
HAM_SUPERCEDE

Last edited by Supremache; 07-27-2020 at 16:47.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-26-2020 , 21:23   Re: No Fall Demage Code Problem!
Reply With Quote #2

When fall damage occurs, attacker is worldspawn so the code is stopping here, since worldspawn is not connected.

if (!is_valid_ent(victim) || !g_isAlive[victim] || !is_user_connected(attacker))
return HAM_IGNORED

Try this:
PHP Code:
public ham_TakeDamagevictim inflictor attacker Float:damage damagebits )
{
    if ( 
damagebits DMG_FALL )
    {
        return 
HAM_SUPERCEDE;
    }
    
    if ( !
pev_validvictim ) || !is_user_alivevictim ) || !is_user_connectedattacker ) )
        return 
HAM_IGNORED
    
    
if ( g_boolCanBuild || g_boolRoundEnded || g_boolPrepTime || ( victim == attacker ) )
        return 
HAM_SUPERCEDE;
    
    if ( 
g_iSupercut )
    {
        
SetHamParamFloatdamage 99.0 );
        return 
HAM_HANDLED;
    }
    
    return 
HAM_IGNORED;

__________________

Last edited by Bugsy; 07-26-2020 at 21:24.
Bugsy is offline
Supremache
Senior Member
Join Date: Sep 2019
Old 07-27-2020 , 11:17   Re: No Fall Demage Code Problem!
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
When fall damage occurs, attacker is worldspawn so the code is stopping here, since worldspawn is not connected.

if (!is_valid_ent(victim) || !g_isAlive[victim] || !is_user_connected(attacker))
return HAM_IGNORED

Try this:
PHP Code:
public ham_TakeDamagevictim inflictor attacker Float:damage damagebits )
{
    if ( 
damagebits DMG_FALL )
    {
        return 
HAM_SUPERCEDE;
    }
    
    if ( !
pev_validvictim ) || !is_user_alivevictim ) || !is_user_connectedattacker ) )
        return 
HAM_IGNORED
    
    
if ( g_boolCanBuild || g_boolRoundEnded || g_boolPrepTime || ( victim == attacker ) )
        return 
HAM_SUPERCEDE;
    
    if ( 
g_iSupercut )
    {
        
SetHamParamFloatdamage 99.0 );
        return 
HAM_HANDLED;
    }
    
    return 
HAM_IGNORED;

I understand now, thanks bro i will try it
Supremache is offline
Old 07-27-2020, 13:01
Supremache
This message has been deleted by Supremache.
Supremache
Senior Member
Join Date: Sep 2019
Old 07-27-2020 , 16:45   Re: No Fall Demage Code Problem!
Reply With Quote #4

Quote:
Originally Posted by supremache View Post
it's working fine but there's a sound for fall down, how can i remove it
i got the codes from zm_vip plugin and in this plugin haven't sound for no fall dmg but when i check this plugin i didn't found the disable fall dmg sound codes can you help me plz..

This is zm_vip
PHP Code:
/* plugin generated by amxx-studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <engine>
#include <fun>
#include <hamsandwich>
#include <basebuilder>
#include <protektion>

////////// plugin settings //////////
#define mode 3
#define chat_prefix "[go]"

// (only if mode 1 is turrned off. Otherwise set flags in vips.ini.) //
#define vipacces admin_level_h
#define mjacces admin_level_h
////////// settings end //////////

// flags
#define flag_a (1<<0)
#define flag_b (1<<1)
#define flag_c (1<<2)
#define flag_d (1<<3)
#define flag_e (1<<4)
#define flag_k (1<<10)

#define version "1.7.2"

#if cellbits == 32
const offset_clipammo 51
#else
const offset_clipammo 65
#endif
const offset_linux_weapons 4

const dmg_hegrenade = (1<<24)

#define set_flood(%1,%2)    (%1 |= (1<<(%2&31)))
#define clear_flood(%1,%2)    (%1 &= ~(1<<(%2&31)))
#define get_flood(%1,%2)    (%1 & (1<<(%2&31)))

#if mode & (1<<0) || mode & (1<<1)
new amx_password_field_string[30]
#endif
#if mode & (1<<0)
new g_user_privileges[33]
enum _:database_items
{
    
auth[50],
    
password[50],
    
accessflags,
    
flags
}
new 
vips_database[database_items]
new array:
database_holder
new g_hour_flags
new g_hour
#endif
#if mode & (1<<1)
const zv_plugin_handled 97
enum _
:items
{
    
i_name[31],
    
i_description[31],
    
i_cost,
    
i_team
}
new 
g_register_in_zp_extra
new g_zp_extra_item_number
new g_nonvip_tease
new g_menu_close
new extra_items[items]
new array:
items_database
new g_registered_items_count
new g_forward_return
new g_extra_item_selected
new g_team[33]
#endif
#if mode == 3
new g_vip_buy_time
new g_vip_cost_ammo
new g_vip_buy_flags
#endif
new const maxclip[] = { -113, -11017, -130301302025303525122010301008303020273030, -150 }
static const 
contact[] = ""
new g_jumpsg_allow_jumpg_armorg_killammog_infectammog_infecthealthg_show_vipsg_healthg_gravity,
g_unlimited_clipg_fall_damageg_damage_rewardg_damage_increaseg_happy_hourg_happy_hour_fragg_happy_hour_ammo
new happy_hour_on
new g_bit
new chache_g_jumps
new maxplayersg_msgsaytext
new jumpnum[33]
new 
bool:dojump[33]
new 
float:g_damage[33]

public 
plugin_init() {
    
    
supremache_protektion()
    
    
register_plugin("zm vip"version"aaarnas")
    
registerham(ham_spawn"player""fwdhamplayerspawnpost"1)
    
registerham(ham_killed"player""fw_playerkilled_post"1)
    
registerham(ham_takedamage"player""fw_takedamage")
    
register_event("resethud""hudreset""be")
    
register_event("hltv""chache_cvars""a""1=0""2=0")
    
    
maxplayers get_maxplayers()
    
g_msgsaytext get_user_msgid("saytext")
    
    
register_message(get_user_msgid("curweapon"), "message_cur_weapon")
    
    
g_jumps register_cvar("zp_vip_jumps""1")
    
g_allow_jump register_cvar("zp_vip_allow_jump""ab")
    
g_armor register_cvar("zp_vip_armor""0")
    
g_health register_cvar("zp_vip_health""50")
    
g_gravity register_cvar("zp_vip_gravity""0.6")
    
g_killammo register_cvar("zp_vip_killammo""2")
    
g_infectammo register_cvar("zp_vip_infectammo""2")
    
g_infecthealth register_cvar("zp_vip_infecthealth""300")
    
g_show_vips register_cvar("zp_vip_show""1")
    
g_unlimited_clip register_cvar("zp_vip_unlimited_ammo""0")
    
g_fall_damage register_cvar("zp_vip_no_fall_damage""1")
    
g_damage_reward register_cvar("zp_vip_damage_reward""500")
    
g_damage_increase register_cvar("zp_vip_damage_increase""1.5")
    
g_happy_hour register_cvar("zp_vip_happy_hour""1")
    
g_happy_hour_frag register_cvar("zp_vip_happy_hour_frag""1")
    
g_happy_hour_ammo register_cvar("zp_vip_happy_hour_ammo""1")
    
register_cvar("amx_contactinfo"contactfcvar_server)
    
register_cvar("zp_vip_version"versionfcvar_server|fcvar_sponly)
    
set_cvar_string("zp_vip_version"version)
        
#if mode & (1<<0) || mode & (1<<1)
    
get_cvar_string("amx_password_field"amx_password_field_stringcharsmax(amx_password_field_string))

#endif
#if mode & (1<<0) && mode & (1<<1)
    
g_vip_cost_ammo register_cvar("zp_vip_cost_ammo""0")
    
g_vip_buy_time register_cvar("zp_vip_buy_time""7")
    
g_vip_buy_flags register_cvar("zp_vip_buy_flags""abcd")
    
set_task(5.0,"check_date",0)
#endif
#if mode & (1<<0)
    
register_concmd("amx_reloadvips""reload_vips"admin_cfg)
    
g_hour register_cvar("zp_vip_hour""on")
    
g_hour_flags register_cvar("zp_vip_hour_flags""abe")
    
reload_vips()
#endif
#if mode & (1<<1)
    
register_clcmd("say /vm""menu_open")
    
g_nonvip_tease register_cvar("zp_vip_nonvip_tease""1")
    
g_register_in_zp_extra register_cvar("zp_vip_register_in_zp_extra""0")
    
g_menu_close register_cvar("zp_vip_menu_close""1")
    
    new 
temp[31]
    
formatex(temp30"*vip* extra items")
    if(
get_pcvar_num(g_register_in_zp_extra)) g_zp_extra_item_number zp_register_extra_item(temp00)
    
g_extra_item_selected createmultiforward("zv_extra_item_selected"et_continuefp_cellfp_cell)
#endif
    
register_clcmd("say /vips""print_adminlist")
    
register_clcmd("say /vip""showmotd")
}
public 
plugin_cfg()
{
    new 
directory[31]
    
get_configsdir(directory30)
    
server_cmd("exec %s/zombievip.cfg"directory)
}

public 
chache_cvars() {
    
    static 
string[5]
    
get_pcvar_string(g_allow_jumpstringcharsmax(string))
    
g_bit read_flags(string)
    
chache_g_jumps get_pcvar_num(g_jumps)
    
    static 
hours[6], hour1s[3], hour2s[3], hour1hour2hms
    get_pcvar_string
(g_happy_hourhourscharsmax(hours))
        
    if(
equal(hours"off")) {happy_hour_on false; return; }
        
    
strtok(hourshour1scharsmax(hour1s), hour2scharsmax(hour2s), '-')
    
hour1 str_to_num(hour1s)
    
hour2 str_to_num(hour2s)
        
    
time(hms)
    if(
hour1 <= <= hour2happy_hour_on true
    
else happy_hour_on false
}
#if mode & (1<<1) || mode & (1<<0)
public plugin_natives() {
#if mode & (1<<1)
    
register_native("zv_register_extra_item""native_zv_register_extra_item"1)
#endif
#if mode & (1<<0)
    
register_native("zv_get_user_flags""native_zv_get_user_flags"1)
#endif    
}
#endif
public fwdhamplayerspawnpost(id) {
    
    if(!
is_user_alive(id)) return ham_ignored;
#if mode & (1<<0)
    
if(!(g_user_privileges[id] & flag_a))
#else
    
if(!(get_user_flags(id) & vipacces)
#endif
        
return plugin_handled;
        
    if(!
zp_get_user_zombie(id))
    {
        if(
pev(idpev_armorvalue) < get_pcvar_num(g_armor))
        
set_pev(idpev_armorvaluefloat(get_pcvar_num(g_armor)))
        
set_pev(idpev_healthfloat(pev(idpev_health) + get_pcvar_num(g_health)))
        
set_pev(idpev_gravityget_pcvar_float(g_gravity))
    }

    
    return 
ham_ignored;
}

public 
fw_playerkilled_post(victimattacker) {
#if mode & (1<<0)
    
if(<= attacker <= maxplayers && g_user_privileges[attacker] & flag_a) {
#else
    
if(<= attacker <= maxplayers && get_user_flags(attacker) & vipacces) {
#endif    
        
if(is_user_alive(attacker) && zp_get_user_zombie(attacker) && set_user_health(attacker, (get_user_health(attacker) + get_pcvar_num(g_infecthealth))))
        
zp_set_user_ammo_packs(attackerzp_get_user_ammo_packs(attacker) + get_pcvar_num(g_killammo))
        
        if(
happy_hour_on) {
            
            static 
fragammo
            frag 
get_pcvar_num(g_happy_hour_frag)
            
ammo get_pcvar_num(g_happy_hour_ammo)
            
            if(
fragset_user_frags(attackerget_user_frags(attacker)+frag)
            if(
ammozp_set_user_ammo_packs(attackerzp_get_user_ammo_packs(attacker)+ammo)
        }
            
    }
}

public 
fw_takedamage(victiminflictorattackerfloat:damagedamage_type) {
    
    if(
victim == attacker)
        return 
ham_ignored
        
    
if(damage_type dmg_hegrenade)
        return 
ham_ignored
    
#if mode & (1<<0)
    
if(g_user_privileges[victim] & flag_a) {
#else
    
if(get_user_flags(victim) & vipacces) {
#endif
        
if(damage_type dmg_fall && get_pcvar_num(g_fall_damage))
            return 
ham_supercede;
    }
    
    if(!
is_user_connected(attacker))
        return 
ham_ignored
    
    
if(zp_get_user_zombie(attacker))
        return 
ham_ignored

#if mode & (1<<0)
    
if(g_user_privileges[attacker] & flag_d) {
#else
    
if(get_user_flags(attacker) & vipacces) {
#endif
        
damage *= get_pcvar_float(g_damage_increase)
        
sethamparamfloat(4damage)
    }
    
#if mode & (1<<0)
    
if(g_user_privileges[attacker] & flag_d) {
#else
    
if(get_user_flags(attacker) & vipacces) {
#endif
        
if(get_pcvar_num(g_damage_reward) > 0) {
            
g_damage[attacker]+=damage
            
if(g_damage[attacker] > get_pcvar_float(g_damage_reward)) {
                
zp_set_user_ammo_packs(attackerzp_get_user_ammo_packs(attacker)+1)
                
g_damage[attacker] -= get_pcvar_float(g_damage_reward)
            }
        }    
    }

    return 
ham_ignored
}

public 
zp_user_infected_post(idinfectornemesis) {
    
    
setvip()
    if(!(
1<=infector<=maxplayers)) return;
    
#if mode & (1<<0)
    
if(g_user_privileges[infector] & flag_a) {
#else
    
if(get_user_flags(infector) & vipacces) {
#endif
        
if(is_user_alive(infector)) set_user_health(infector, (get_user_health(infector) + get_pcvar_num(g_infecthealth)))
        
zp_set_user_ammo_packs(infectorzp_get_user_ammo_packs(infector) + get_pcvar_num(g_infectammo))
        
        if(
happy_hour_on) {
            
            static 
fragammo
            frag 
get_pcvar_num(g_happy_hour_frag)
            
ammo get_pcvar_num(g_happy_hour_ammo)
            
            if(
fragset_user_frags(infectorget_user_frags(infector)+frag)
            if(
ammozp_set_user_ammo_packs(infectorzp_get_user_ammo_packs(infector)+ammo)
        }
    }    
}

public 
client_connect(id) {
    
    
jumpnum[id] = 0
    g_damage
[id] = 0.0
    dojump
[id] = false
#if mode & (1<<0)
    
set_flags(id)
    if(
get_pcvar_num(g_show_vips) == && g_user_privileges[id] & flag_a) {
#else
    
if(get_pcvar_num(g_show_vips) == && get_user_flags(id) & vipacces) {
#endif
        
new name[100]
        
get_user_name(idname100)
        
client_printcolor(0"/g%l"lang_player"vip_connected"name)
    }
#if mode & (1<<0)
    
else {
        static 
hours[6], hour1s[3], hour2s[3], hour1hour2hms
        get_pcvar_string
(g_hourhourscharsmax(hours))
        
        if(
equal(hours"off")) return;
        
        
strtok(hourshour1scharsmax(hour1s), hour2scharsmax(hour2s), '-')
        
hour1 str_to_num(hour1s)
        
hour2 str_to_num(hour2s)
        
        
time(hms)
        if(
hour1 <= <= hour2) {
            
            new 
fflags[10]
            
get_pcvar_string(g_hour_flagsfflagscharsmax(fflags))
            
g_user_privileges[id] = read_flags(fflags)
        }
    }
#endif
}
#if mode & (1<<1)
public bb_extra_item_selected(iditem_id)
    if(
item_id == g_zp_extra_item_number)
        
menu_open(id)

public 
menu_open(id) {
#if mode & (1<<0)
    
if(g_user_privileges[id] & flag_e)
        
vip_menu(id)
#else
    
if(get_user_flags(id) & vipacces)
        
vip_menu(id)
#endif
#if mode & (1<<0)
    
else if(get_pcvar_num(g_vip_cost_ammo) != 0)
        
get_pcvar_num(g_nonvip_tease) ? Vip_menu(id) : Buy_meniu(id)
#endif
    
else client_printcolor(id"/g%s /yyou are not a vip member."chat_prefix)
    return 
zp_plugin_handled
}
    
public 
vip_menu(id)
{
    if(
g_registered_items_count == 0) {
        
client_printcolor(id"/g%s /y%l"chat_prefixid"off")
        return;
    }
    new 
holder[150], menu
    formatex
(holdercharsmax(holder), "\rvip's extra items:")
    
menu menu_create(holder"vip_menu_handler")
    new 
iteam_checknum[3], ammo_packscheck
    check 
0
    ammo_packs 
zp_get_user_ammo_packs(id)
    
    switch(
zp_get_user_zombie(id)) {
        
        case 
0: {
            
team_check zp_team_human
        
}
        case 
1: {
            
team_check zp_team_zombie
        
}
    }
    
    if(
zp_get_user_zombie(id)) team_check |= flag_a
    
else if(!zp_get_user_zombie(id)) team_check |= flag_b

    g_team
[id] = team_check
    
for(i=0g_registered_items_counti++) {
        
arraygetarray(items_databaseiextra_items)
        if(
extra_items[i_team] == || g_team[id] & extra_items[i_team]) {
            
formatex(holdercharsmax(holder), "%s \r[%s] %s \y[%d ammo]"extra_items[i_name], extra_items[i_description], ammo_packs extra_items[i_cost] ? "\r" "\y"extra_items[i_cost])
            
formatex(num2"%d"i)
            
menu_additem(menuholdernum0)
            
check++
        }
    }
    if(
check == 0) {
        
client_printcolor(id"/g%s /ythere is no extra items for your class."chat_prefix)
        return;
    }
    
menu_setprop(menumprop_exitmexit_all)
    
formatex(holdercharsmax(holder), "next")
    
menu_setprop(menumprop_nextnameholder)
    
formatex(holdercharsmax(holder), "back")
    
menu_setprop(menumprop_backnameholder)
    
formatex(holdercharsmax(holder), "exit")
    
menu_setprop(menumprop_exitnameholder)
    
menu_display(idmenu0)
}
 
public 
vip_menu_handler(idmenuitem)
{
    if( 
item == menu_exit )
    {
        
menu_destroy(menu)
        return 
plugin_handled
    
}
    
#if mode & (1<<0)
    
if(get_pcvar_num(g_nonvip_tease) && !(g_user_privileges[id] & flag_a)) {
#if mode & (1<<0)
        
buy_meniu(id)
#else
        
client_printcolor(id"/g%s /yyou are not a vip member."chat_prefix)
#endif
        
menu_destroy(menu)
        return 
plugin_handled;
    }
#else
    
if(get_pcvar_num(g_nonvip_tease) && !(get_user_flags(id) & vipacces)) {
#if mode & (1<<0)
        
buy_meniu(id)
#else
        
client_printcolor(id"/g%s /yyou are not a vip member."chat_prefix)
#endif
        
menu_destroy(menu)
        return 
plugin_handled;
    }
#endif
    
new team_check
    
switch(zp_get_user_zombie(id)) {
        
        case 
0: {
            
team_check zp_team_human
        
}
        case 
1: {
            
team_check zp_team_zombie
        
}
    }
    
    if(
g_team[id] != team_check) {
        
        
menu_destroy(menu)
        
vip_menu(id)
        return 
plugin_handled;
    }
    
    new 
data[6], iname[64], item_idammo_packs
    
new aaccesscallback
    menu_item_getinfo
(menuitemaaccessdata,5iname63callback)
    
item_id str_to_num(data)
    
ammo_packs zp_get_user_ammo_packs(id)
    
arraygetarray(items_databaseitem_idextra_items)
    if(
ammo_packs >= extra_items[i_cost]) zp_set_user_ammo_packs(idammo_packs extra_items[i_cost])
    else {
        
client_printcolor(id"/g%s/y missing %d ammo packs to buy it."chat_prefixextra_items[i_cost]-ammo_packs)
        if(
g_menu_closemenu_destroy(menu)
        else 
vip_menu(id)
        return 
plugin_handled
    
}
    
item_id++
    
executeforward(g_extra_item_selectedg_forward_returniditem_id)
    if (
g_forward_return >= zv_plugin_handled)
        
zp_set_user_ammo_packs(idammo_packs)
    
    if(!
g_menu_closevip_menu(id)
    
    
menu_destroy(menu)
    return 
plugin_handled
}
#endif
#if mode & (1<<0) && mode & (1<<1)
public buy_meniu(id)
{
    new 
holder[150], menu
    formatex
(holdercharsmax(holder), "\r\yprice \r%d \yammo packs. Time - \r%d \ydays.^nchoose your authentication type:"get_pcvar_num(g_vip_cost_ammo), get_pcvar_num(g_vip_buy_time))
    
menu menu_create(holder"buy_menu_handler")
    new 
callback menu_makecallback("_menu_callback")
    
formatex(holdercharsmax(holder), "nick + password\r(settings)")
    
menu_additem(menuholder)
    
formatex(holdercharsmax(holder), "steamid\r(buy)")
    
menu_additem(menuholder__callback)
    
formatex(holdercharsmax(holder), "ip adress\r(buy)")
    
menu_additem(menuholder)
    
    
menu_setprop(menumprop_exitmexit_all)
    
formatex(holdercharsmax(holder), "exit")
    
menu_setprop(menumprop_exitnameholder)
    
menu_display(idmenu0)
}
 
public 
buy_menu_handler(idmenuitem)
{
    if( 
item == menu_exit )
    {
        
menu_destroy(menu)
        return 
plugin_handled
    
}

    new 
ammo_packs zp_get_user_ammo_packs(id)
    if(
item 0) {
        if(
ammo_packs >= get_pcvar_num(g_vip_cost_ammo)) {
            
amx_tempadmin(iditem)
            
zp_set_user_ammo_packs(idammo_packs get_pcvar_num(g_vip_cost_ammo))
            
client_printcolor(id"/g%s /yyou sucessfully bought vip for %d days."chat_prefixget_pcvar_num(g_vip_buy_time))
            
        }
        else 
client_printcolor(id"/g%s /ymissing %d ammo packs to buy it."chat_prefixget_pcvar_num(g_vip_cost_ammo)-ammo_packs)
    }
    else {
        
nick_buy_meniu(id)
        return 
plugin_handled
    
}
    
    
menu_destroy(menu)
    return 
plugin_handled
}

public 
nick_buy_meniu(id)
{
    new 
buttons_string[16], menu_string[151], menu_item[81], menuclient_password[20]
    
get_user_info(idamx_password_field_stringclient_passwordcharsmax(client_password))
    
formatex(menu_string150"\rafter bought, you can't change your nick!^nyour config.cfg file can't be cheked as 'read only'!^n\yyour password: \w%s"client_password)
    
menu menu_create(menu_string"nick_buy_menu_handler")
    
    
formatex(menu_item80"generate random")
    
menu_additem(menumenu_item)
    
formatex(menu_item80"how to change password?")
    
menu_additem(menumenu_item)
    
formatex(menu_item80"everything is ok, buy it \r[\y%d \rammo packs. For \y%d\r days]"get_pcvar_num(g_vip_cost_ammo) ,get_pcvar_num(g_vip_buy_time))
    
menu_additem(menumenu_item)
    
    
menu_setprop(menumprop_exitmexit_all)
    
formatex(buttons_string15"back")
    
menu_setprop(menumprop_exitnamebuttons_string)
    
menu_display(idmenu0)
    
}
 
public 
nick_buy_menu_handler(idmenuitem)
{
    if( 
item == menu_exit )
    {
        
buy_meniu(id)
        return 
plugin_handled
    
}

    switch(
item) {
        case 
0: {
            
generate_password(id)
            
set_task(0.2"menu_delay"id)
        }
        case 
1Nick_buy_meniu_sec(id)
        case 
2: {
            
            new 
ammo_packs zp_get_user_ammo_packs(id)
            if(
ammo_packs >= get_pcvar_num(g_vip_cost_ammo)) {
                
amx_tempadmin(id0)
                
zp_set_user_ammo_packs(idammo_packs get_pcvar_num(g_vip_cost_ammo))
                
client_printcolor(id"/g%s /yyou sucessfully bought vip for %d days."chat_prefixget_pcvar_num(g_vip_buy_time))
            
            }
            else 
client_printcolor(id"/g%s /ymissing %d ammo packs to buy it."chat_prefixget_pcvar_num(g_vip_cost_ammo)-ammo_packs)
            
            
menu_destroy(menu)
            return 
plugin_handled
        
}
    }
    
    
menu_destroy(menu)
    return 
plugin_handled
}
public 
nick_buy_meniu_sec(id)
{
    new 
holder[150], menu
    formatex
(holdercharsmax(holder), "\r\yif you want to set a password, type \rsetinfo _pw password\y in the console^npassword you can type any what you want.")
    
menu menu_create(holder"nick_buy_menu_sec_handler")
    
    
formatex(holdercharsmax(holder), "back")
    
menu_additem(menuholder)
    
    
menu_setprop(menumprop_exitmexit_never)
    
menu_display(idmenu0)
}
 
public 
nick_buy_menu_sec_handler(idmenuitem)
{
    
nick_buy_meniu(id)
    
menu_destroy(menu)
    return 
plugin_handled;
}

public 
_menu_callback(idmenuitem) {
    
    if(
item == 1) {
        new 
authid[30]
        
get_user_authid(idauthidcharsmax(authid))
        if(
equal(authid"steam_0"7)) return item_enabled
        
else return item_disabled
    
}
    
    return 
item_enabled
}

public 
menu_delay(idnick_buy_meniu(id)
#endif
public message_cur_weapon(msg_idmsg_destmsg_entity)
{
    if (!
get_pcvar_num(g_unlimited_clip)) return
#if mode & (1<<0)
    
if (!(g_user_privileges[msg_entity] & flag_c)) return
#else
    
if (!(get_user_flags(msg_entity) & vipacces)) return
#endif
    
if (!is_user_alive(msg_entity) || get_msg_arg_int(1) != 1) return
    
    static 
weaponclip
    weapon 
get_msg_arg_int(2)
    
clip get_msg_arg_int(3)
    
    if (
maxclip[weapon] > 2)
    {
        
set_msg_arg_int(3get_msg_argtype(3), maxclip[weapon])
        
        if (
clip 2)
        {
            static 
wname[32], weapon_ent
            get_weaponname
(weaponwnamesizeof wname 1)
            
weapon_ent find_ent_by_owner(-1wnamemsg_entity)
            
fm_set_weapon_ammo(weapon_entmaxclip[weapon])
        }
    }
}

public 
hudreset()
    
setvip()
    
public 
setvip()
{
    new 
players[32], pnum
    get_players
(playerspnum"a")

    for (new 
0pnumi++)
    {
        new 
id players[i]
#if mode & (1<<0)    
        
if (g_user_privileges[id] & flag_a)
#else
        
if (get_user_flags(id) & vipacces)
#endif
        
{
            
message_begin(msg_allget_user_msgid("scoreattrib"))
            
write_byte(id)
            
write_byte(4)
            
message_end()
        }
    }
    return 
plugin_handled
}

public 
print_adminlist(user
{
    new 
adminnames[33][32]
    new 
message[256]
    new 
contactinfo[256], contact[112]
    new 
idcountxlen
    
    
for(id id <= maxplayers id++)
        if(
is_user_connected(id))
#if mode & (1<<0)
            
if(g_user_privileges[id] & flag_a)
#else
            
if(get_user_flags(id) & vipacces)
#endif
                
get_user_name(idadminnames[count++], 31)

    
len format(message255"connected vips: ")
    if(
count 0) {
        for(
count x++) {
            
len += format(message[len], 255-len"%s%s "adminnames[x], < (count-1) ? ", ":"")
            if(
len 96 ) {
                
client_printcolor(user"/g%s"message)
                
len format(message255"")
            }
        }
        
client_printcolor(user"/g%s"message)
    }
    else {
        
len += format(message[len], 255-len"no one ")
        
client_printcolor(user"/g%s"message)
    }
    
    
get_cvar_string("amx_contactinfo"contact63)
    if(
contact[0])  {
        
format(contactinfo111"admin contacts -- %s "contact)
        
client_printcolor(user"/g%s"contactinfo)
    }
    
}

public 
client_disconnect(id)
{
    
jumpnum[id] = 0
    g_damage
[id] = 0.0
    dojump
[id] = false
}

public 
client_prethink(id)
{
#if mode & (1<<0)
    
if(!is_user_alive(id) || !g_jumps || (!(g_user_privileges[id] & flag_b))) return plugin_continue
#else
    
if(!is_user_alive(id) || !g_jumps || (!(get_user_flags(id) & mjacces))) return plugin_continue
#endif
    
static nbutobutfflags
    nbut
get_user_button(id)
    
obut get_user_oldbutton(id)
    
fflags get_entity_flags(id)
    
    if((
nbut in_jump) && !(fflags fl_onground) && !(obut in_jump))
    {
        if(
jumpnum[id] < chache_g_jumps && 
        ((
g_bit flag_a && !zp_get_user_zombie(id)) || (g_bit flag_b && zp_get_user_zombie(id))))
        {
            
dojump[id] = true
            jumpnum
[id]++
            return 
plugin_continue
        
}
    }
    if((
nbut in_jump) && (fflags fl_onground))
    {
        
jumpnum[id] = 0
        
return plugin_continue
    
}
    
    return 
plugin_continue
}

public 
client_postthink(id)
{
#if mode & (1<<0)
    
if(!is_user_alive(id) || !get_pcvar_num(g_jumps) || (!(g_user_privileges[id] & flag_b))) return plugin_continue
#else
    
if(!is_user_alive(id) || !get_pcvar_num(g_jumps) || (!(get_user_flags(id) & mjacces))) return plugin_continue
#endif
    
if(dojump[id] == true)
    {
        static 
float:velocity[3]    
        
entity_get_vector(id,ev_vec_velocity,velocity)
        
velocity[2] = random_float(265.0,285.0)
        
entity_set_vector(id,ev_vec_velocity,velocity)
        
dojump[id] = false
        
return plugin_continue
    
}
    return 
plugin_continue
}    

public 
showmotd(id)
    
show_motd(id"vip.txt")
#if mode & (1<<0)
public reload_vips() {
    
    if(
database_holderarraydestroy(database_holder)
    
database_holder arraycreate(database_items)
    new 
configsdir[64]
    
get_configsdir(configsdir63)
    
format(configsdir63"%s/vips.ini"configsdir)
    
    new 
file=fopen(configsdir,"r");
    
    if (
file)
    {
        static 
text[512], flags[32], authdata[50], privileges_flags[32], password[50]
        while (!
feof(file))
        {
            
fgets(file,text,sizeof(text)-1);
            
            
trim(text);
            
            
// comment
            
if (text[0]==';'
            {
                continue;
            }
            
            
flags[0]=0;
            
authdata[0]=0;
            
privileges_flags[0]=0;
            
password[0]=0;
            
            
// not enough parameters
            
if (parse(text,authdata,sizeof(authdata)-1,password,sizeof(password)-1,privileges_flags,sizeof(privileges_flags)-1,flags,sizeof(flags)-1) < 2)
            {
                continue;
            }

            
vips_database[auth] = authdata
            vips_database
[password] = password
            vips_database
[accessflags] = read_flags(privileges_flags)
            
vips_database[flags] = read_flags(flags)
            
arraypusharray(database_holdervips_database)
        }
        
        
fclose(file);
    }
    else 
log_amx("error: Vips.ini file doesn't exist")
}
#endif
#if mode & (1<<0) && mode & (1<<1)
public check_date()
{
    new 
holder[20]
    new 
y,d
    date
(ymd)
    
format(holdercharsmax(holder), "m%dd%dy%d"mdy)

    new 
configdir[200]
    
get_configsdir(configdir,199)

    new 
configfile1[200]

    
format(configfile1,199,"%s/vips.ini",configdir)
    
    new 
text[512], len
    
new pnum file_size(configfile1,1)
    for(new 
1pnumi++)
    {
        
read_file(configfile1itext511len)
        if ( 
contain(textholder) != -
        {
            
deleteline(configfile1i)
        }
    }
    return 
plugin_handled
}

public 
amx_tempadmin(idtype)
{    
    new 
authid[31], ip[31], name[51], client_password[20], p_flags[21], sdate[20]
    
get_pcvar_string(g_vip_buy_flagsp_flagscharsmax(p_flags))
    
get_user_authid(idauthidcharsmax(authid))
    
get_user_ip(idipcharsmax(ip), 1)
    
get_user_name(idnamecharsmax(name))
    
get_user_info(idamx_password_field_stringclient_passwordcharsmax(client_password))
    
    
get_date(get_pcvar_num(g_vip_buy_time), sdatecharsmax(sdate))
    
    new 
holder[200]
    switch(
type) {
        case 
0Formatex(holdercharsmax(holder), "^"%s^" ^"%s^" ^"%s^" ^"b^"; exp: %s"nameclient_passwordp_flagssdate)
        case 
1Formatex(holdercharsmax(holder), "^"%s^" ^"^" ^"%s^" ^"ce^"; exp: %s"authidp_flagssdate)
        case 
2Formatex(holdercharsmax(holder), "^"%s^" ^"^" ^"%s^" ^"de^"; exp: %s"ipp_flagssdate)
    }
    
    new 
configdir[200]
    
get_configsdir(configdir199)
    new 
configfile1[200]
    
format(configfile1,199,"%s/vips.ini",configdir)
    
write_file(configfile1holder, -1)
    
server_cmd("amx_reloadvips")
    
set_task(1.0"set_flags"id)
    
}

deleteline( const szfilename[ ], const iline )
{
    new 
ifile fopenszfilename"rt" );
    if( !
ifile )
    {
        return;
    }
    static const 
sztempfilename[ ] = "delete_line.txt";
    new 
itempfile fopensztempfilename"wt" );
    
    new 
szdata256 ], ilinecountbool:breplaced false;
    while( !
feofifile ) )
    {
        
fgetsifileszdata255 );
        
        if( 
ilinecount++ == iline )
        {
            
breplaced true;
        }
        else
        {
            
fputsitempfileszdata );
        }
    }
    
    
fcloseifile );
    
fcloseitempfile );
    
    if( 
breplaced )
    {
        
delete_fileszfilename );
        
        while( !
rename_filesztempfilenameszfilename) ) { }
    }
    else
    {
        
delete_filesztempfilename );
    }
}

stock get_date(daysstring[], chars) {
    
    new 
ymd
    date
(y,d)
    
    
d+=days
    
    
new go true
    
while(go) {
        switch(
m) {
            case 
1,357810: {
                if(
d>31) { d=d-31m++; }
                else 
go false
            
}
            case 
2: {
                if(
d>28) { d=d-28m++; }
                else 
go false
            
}
            case 
46911: {
                if(
d>30) { d=d-30m++; }
                else 
go false
            
}
            case 
12: {
                if(
d>31) { d=d-31y++; m=1; }
                else 
go false
            
}
        }
    }
    
formatex(stringchars"m%dd%dy%d"m,y)
}
#endif

stock client_printcolor(id, const message[], any:...)
{
    static 
buffer[512], argscount
    argscount 
numargs()
    
    if (!
id) {
        
        static 
players[32], numplayerii2
        get_players
(playersnum "ch")
            
        for (
0numi++) {
            
            
player players[i]
            
            static 
changed[5], changedcount
            changedcount 
0
            
            
for (i2 2i2 argscounti2++)
            {
                if (
getarg(i2) == lang_player)
                {
                    
setarg(i20player)
                    
changed[changedcount] = i2
                    changedcount
++
                }
            }
            
            
vformat(buffercharsmax(buffer), message3)
            
            
replace_all(buffercharsmax(buffer), "/g""^4")
            
replace_all(buffercharsmax(buffer), "/y""^1")
        
            
message_begin(msg_one_unreliableg_msgsaytext_player)
            
write_byte(player)
            
write_string(buffer)
            
message_end()
            
            for (
i2 0i2 changedcounti2++)
                
setarg(changed[i2], 0lang_player)
        }
    }
    else {
        
        
vformat(buffercharsmax(buffer), message3)
        
        
replace_all(buffercharsmax(buffer), "/g""^4")
        
replace_all(buffercharsmax(buffer), "/y""^1")
        
        
message_begin(msg_one_unreliableg_msgsaytext_id)
        
write_byte(id)
        
write_string(buffer)
        
message_end()
    }
}

stock fm_find_ent_by_owner(entity, const classname[], owner)
{
    while ((
entity engfunc(engfunc_findentitybystringentity"classname"classname)) && pev(entitypev_owner) != owner) {}
    
    return 
entity;
}

stock fm_set_weapon_ammo(entityamount)
{
    
set_pdata_int(entityoffset_clipammoamountoffset_linux_weapons);
}
#if mode & (1<<0)
public set_flags(id) {
    
    static 
authid[31], ip[31], name[51], indexclient_password[30], sizelog_flags[11]
    
get_user_authid(idauthid30)
    
get_user_ip(idip301)
    
get_user_name(idname50)
    
get_user_info(idamx_password_field_stringclient_passwordcharsmax(client_password))
    
    
g_user_privileges[id] = 0
    size 
arraysize(database_holder)
    for(
index=0index size index++) {
        
arraygetarray(database_holderindexvips_database)
        if(
vips_database[flags] & flag_d) {
            if(
equal(ipvips_database[auth])) {
                if(!(
vips_database[flags] & flag_e)) {
                    if(
equal(client_passwordvips_database[password]))
                        
g_user_privileges[id] = vips_database[accessflags]
                    else if(
vips_database[flags] & flag_a) {
                        
server_cmd("kick #%d ^"ivalid (setinfo _pwpassword!^""get_user_userid(id))
                        break
                    }
                }
                else 
g_user_privileges[id] = vips_database[accessflags]
                
get_flags(vips_database[accessflags], log_flags10)
                
log_amx("%s become vip. (steamid: ^"%s^") (ip: ^"%s^") (flags: ^"%s^")"nameauthidiplog_flags)
                break
            }
        }
        else if(
vips_database[flags] & flag_c) {
            if(
equal(authidvips_database[auth])) {
                if(!(
vips_database[flags] & flag_e)) {
                    if(
equal(client_passwordvips_database[password]))
                        
g_user_privileges[id] = vips_database[accessflags]
                    else if(
vips_database[flags] & flag_a) {
                        
server_cmd("kick #%d ^"ivalid (setinfo _pwpassword!^""get_user_userid(id))
                        break
                    }
                }
                else 
g_user_privileges[id] = vips_database[accessflags]
                
get_flags(vips_database[accessflags], log_flags10)
                
log_amx("%s become vip. (steamid: ^"%s^") (ip: ^"%s^") (flags: ^"%s^")"nameauthidiplog_flags)
                break
            }
        }
        else {
            if(
vips_database[flags] & flag_k) {
                if((
vips_database[flags] & flag_b && contain(namevips_database[auth]) != -1) || equal(namevips_database[auth])) {
                    if(!(
vips_database[flags] & flag_e)) {
                        if(
equal(client_passwordvips_database[password]))
                            
g_user_privileges[id] = vips_database[accessflags]
                        else if(
vips_database[flags] & flag_a) {
                            
server_cmd("kick #%d ^"ivalid (setinfo _pwpassword!^""get_user_userid(id))
                            break
                        }
                    }
                    else 
g_user_privileges[id] = vips_database[accessflags]
                    
get_flags(vips_database[accessflags], log_flags10)
                    
log_amx("%s become vip. (steamid: ^"%s^") (ip: ^"%s^") (flags: ^"%s^")"nameauthidiplog_flags)
                    break
                }
            }
            else {
                if((
vips_database[flags] & flag_b && containi(namevips_database[auth]) != -1) || equali(namevips_database[auth])) {
                    if(!(
vips_database[flags] & flag_e)) {
                        if(
equal(client_passwordvips_database[password]))
                            
g_user_privileges[id] = vips_database[accessflags]
                        else if(
vips_database[flags] & flag_a) {
                            
server_cmd("kick #%d ^"ivalid (setinfo _pwpassword!^""get_user_userid(id))
                            break
                        }
                    }
                    else 
g_user_privileges[id] = vips_database[accessflags]
                    
get_flags(vips_database[accessflags], log_flags10)
                    
log_amx("%s become vip. (steamid: ^"%s^") (ip: ^"%s^") (flags: ^"%s^")"nameauthidiplog_flags)
                    break
                }
            }
        }
    }
}
#endif
#if mode & (1<<0) && mode & (1<<1)
stock generate_password(id) {
    
    new 
password_holder[30]
    
formatex(password_holdercharsmax(password_holder), "%d%d%d%d%d"random(10), random(10), random(10), random(10), random(10))
    
client_cmd(id"setinfo %s %s"amx_password_field_stringpassword_holder)
}
#endif
#if mode & (1<<0)
public native_zv_get_user_flags(id)
    return 
g_user_privileges[id]
#endif
#if mode & (1<<1)
public native_zv_register_extra_item(const item_name[], const item_discription[], item_costitem_team)
{
        if(!
items_databaseitems_database arraycreate(items)
        
        
param_convert(1)
        
param_convert(2)
        
copy(extra_items[i_name], 30item_name)
        
copy(extra_items[i_description], 30item_discription)
        
extra_items[i_cost] = item_cost
        extra_items
[i_team] = item_team
        arraypusharray
(items_databaseextra_items)
        
g_registered_items_count++

        return 
g_registered_items_count
}

public 
plugin_end() if(items_databasearraydestroy(items_database)
#endif 
edit: I did it thanks
Supremache is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:42.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode