Raised This Month: $ Target: $400
 0% 

What is problem?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Keistas
Member
Join Date: Feb 2010
Old 05-06-2011 , 10:45   What is problem?
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>
#include <fun>
#include <engine>

#define Keysrod (1<<0) | (1<<1) | (1<<9)
#define DAMAGE_RECIEVED

static const COLOR[] = "^x04"
static const CONTACT[] = "mindzekas.nu arba reduskinas2"

new const VIP_STATUS[] = "Prisijunge vipai"
new const VIP_STATUS_N[] = "Dabar vipu nera prisijungusiu"

new gravity

new health_add
new health_add_hs
new health_max

new nKiller
new nKiller_hp
new nHp_add
new nHp_max

new AWP_Active

new SayTxT
new msgSayText
new g_maxplayers
new g_HudSyncObj

#if defined DAMAGE_RECIEVED
//new g_HudSync_Damage2
#endif

public plugin_init()
{
    
register_plugin("VIP""2.06""CesoZona.eu")
    
register_cvar("amx_contactinfo"CONTACTFCVAR_SERVER)
    
    
gravity register_cvar("amx_vip_gravity""0.5")

    
health_add    register_cvar("amx_vip_hp""15")
    
health_add_hs    register_cvar("amx_vip_hp_hs""25")
    
health_max    register_cvar("amx_vip_hp_max""350")
    
    
RegisterHam(Ham_Spawn"player""Ham_PlayerSpawn"1)

    
AWP_Active    register_cvar("amx_vip_awp_active""1")

    
register_event("Damage""Damage""b""2!0""3=0""4!0")
//register_event("Damage", "Damage", "b")
//register_event("DeathMsg", "death_msg", "a")
    
register_event("DeathMsg""hook_death""a""1>0")
    
register_event("CurWeapon""Cur_Weapon""be""1=1")
    
    
    
register_clcmd("awp""HandleCmd")
//register_clcmd("sg550", "HandleCmd")
//register_clcmd("g3sg1", "HandleCmd")

    
register_clcmd("say /vip""VipInformation")
    
register_clcmd("say""vip_show")
    
    
SayTxT get_user_msgid("SayText");
    
msgSayText get_user_msgid("SayText")
    
g_maxplayers get_maxplayers()
    
}

public 
plugin_cfg()
        
g_HudSyncObj CreateHudSyncObj();
    
    public 
Damage(Cl)
{
        static 
Attacker;
        
Attacker get_user_attacker(Cl);
    
    if (!
is_user_alive(id))
    return
 
        if (
get_user_flags(Attacker) & ADMIN_LEVEL_H)
        {
                
set_hudmessage(0100200, -1.00.5520.14.00.020.027);
                
ShowSyncHudMsg(Attackerg_HudSyncObj"%d^n"read_data(2));
        }
}

public 
hook_death()
{
    
nKiller read_data(1)

    if ((
read_data(3) == 1) && (read_data(5) == 0))
    {
        
nHp_add get_pcvar_num(health_add_hs)
    }

    else
        
nHp_add get_pcvar_num(health_add)

    
nHp_max get_pcvar_num(health_max)

    if(!(
get_user_flags(nKiller) & ADMIN_LEVEL_H))
        return

    
nKiller_hp get_user_health(nKiller)
    
nKiller_hp += nHp_add

    
if(nKiller_hp nHp_max)
        
nKiller_hp nHp_max

    set_user_health
(nKillernKiller_hp)

    
message_begin(MSG_ONEget_user_msgid("ScreenFade"), {0,0,0}, nKiller)
    
write_short(1<<10)
    
write_short(1<<10)
    
write_short(0x0000)
    
write_byte(0)
    
write_byte(0)
    
write_byte(200)
    
write_byte(75)
    
message_end()
}

public 
Ham_PlayerSpawn(id) {
   if (!
is_user_alive(id))
      return
 
   if(
get_user_flags(id) & ADMIN_LEVEL_H
      
set_user_gravity(idget_pcvar_float(gravity))

}


public 
HandleCmd(id)
{
    if (!
get_pcvar_num(AWP_Active))
        return 
PLUGIN_CONTINUE

    
if(get_user_flags(id) & ADMIN_LEVEL_H)
        return 
PLUGIN_CONTINUE

    client_print
(idprint_center"* AWP - Tik Vipams, daugiau info /vip *")
    return 
PLUGIN_HANDLED
}

public 
Cur_Weapon(id)
{
    if (!
get_pcvar_num(AWP_Active))
        return 
PLUGIN_CONTINUE

    
new WeaponID read_data(2)

    new 
mapname[32]
    
get_mapname(mapname31)

    if (
equali(mapname"awp_"3))
        return 
PLUGIN_CONTINUE

    
else
    {
        if (
WeaponID == CSW_AWP)
        {
            if (!(
get_user_flags(id) & ADMIN_LEVEL_H))
            {
                
client_print(idprint_center"* AWP - Tik Vipams, daugiau info /vip *")
                
client_cmd(id"drop")
            }
        }
    }

    return 
PLUGIN_HANDLED
}


public 
VipInformation(id)
{
     
show_motd(id"vipas.txt""Vipo INFORMACIJA")
}

public 
vip_show(id
{
    new 
said[192]
    
read_args(said,192)
    if( ( 
containi(said"donators") != -&& containi(said"vips") != -) || contain(said"/vips") != -)
        
set_task(0.1"viplist"id)
}

public 
viplist(user
{
    new 
vipnames[33][32]
    new 
message[256]
    new 
idcountxlen
    
    
for(id id <= g_maxplayers id++)
        if(
is_user_connected(id))
            if(
get_user_flags(id) & ADMIN_LEVEL_H)
                
get_user_name(idvipnames[count++], 31)

    
len format(message255"%s %s: ",COLORVIP_STATUS)
    if(
count 0) {
        for(
count x++) {
            
len += format(message[len], 255-len"%s%s "vipnames[x], < (count-1) ? ", ":"")
            if(
len 96 ) {
                
print_message(usermessage)
                
len format(message255"%s ",COLOR)
            }
        }
        
print_message(usermessage)
    }
    else {
        
len += format(message[len], 255-len"%s."VIP_STATUS_N)
        
print_message(usermessage)
    }
}

public 
client_authorized(id)
{
    
set_task(5.0"PrintText"id)
}

public 
PrintText(id)
{
    new 
message[256]
    
format(message255"^x04[CesoZona-VIP]^x01 Rasyk:^x03 /vip^x01 kad pamatytum kokias teises turi ^x04 VIP.")
    
print_message(idmessage)

    return 
PLUGIN_CONTINUE
}

print_message(idmsg[])
{
    
message_begin(MSG_ONEmsgSayText, {0,0,0}, id)
    
write_byte(id)
    
write_string(msg)
    
message_end()
}

stock client_printcolor(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg,190,input,3);
    
replace_all(msg,190,"/g","^4");// green txt
    
replace_all(msg,190,"/y","^1");// orange txt
    
replace_all(msg,190,"/ctr","^3");// team txt
    
replace_all(msg,190,"/w","^0");// team txt
    
if (idplayers[0] = id; else get_players(players,count,"ch");
    for (new 
0counti++)
        if (
is_user_connected(players[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLESayTxT_players[i]);
            
write_byte(players[i]);
            
write_string(msg);
            
message_end();
        }
}

public 
client_connect(id)
{
new 
name[32]
get_user_info(id"name"name31)
if(
get_user_flags(id) & ADMIN_LEVEL_H) {
set_hudmessage(200000.050.6520.0230.00.030.35)
show_hudmessage(0"VIPAS %s prisijunge!",name)
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\
\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/ 
L 05/06/2011 - 14:10:13: [AMXX] Displaying debug trace (plugin "Vipas.amxx")
L 05/06/2011 - 14:10:13: [AMXX] Run time error 10: native error (native "get_user_flags")
L 05/06/2011 - 14:10:13: [AMXX] [0] Vipas.sma:amage (line 86)
Keistas is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-06-2011 , 12:28   Re: What is problem?
Reply With Quote #2

1) Use ham to hook damage:
PHP Code:
RegisterHam(Ham_TakeDamage"player",  "ham_TakeDamage"
2) Check if user is valid:
PHP Code:
public ham_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    static 
Float:armor
        
    
if (!is_user_connected(attacker)||victim<1||victim>g_maxplayers||attacker<1||attacker>g_maxplayers||victim==attacker)
        return 
HAM_IGNORED

    client_print
(attackerprint_chat"You hit player %d !"victim)
    
client_print(victimprint_chat"You were hit by player %d !"attacker)

__________________

SonicSonedit is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-06-2011 , 17:58   Re: What is problem?
Reply With Quote #3

SonicSonedit:

Use ( 1 <= id <= MaxPlayers ) and do all non-native checks first since they are cheaper to call and execution/condition-checks stop at the first false conditional.
__________________

Last edited by Bugsy; 05-06-2011 at 18:01.
Bugsy is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-07-2011 , 10:55   Re: What is problem?
Reply With Quote #4

Bugsy
There were some cases, after which I have a habit now to put (is_user_connect) at the beggining of all other checks. I guess it's a bad habit sometimes
But about ( 1 <= id <= MaxPlayers ) - do you suggest using
PHP Code:
if (!(0<victim<=g_maxplayers)||!(0<attacker<=g_maxplayers)||victim==attacker||!is_user_connected(attacker))
        return 
HAM_IGNORED 
? Is it easier to understand for processor? Doesn't using "!" the same as using any other operator?
__________________

SonicSonedit is offline
Reply



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 04:18.


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