Thread: [API Scripting Help] [Errors] ON Zp 5.0.8
View Single Post
zmd94
Veteran Member
Join Date: Nov 2013
Location: Malaysia (9w2zow).
Old 11-03-2014 , 18:45   Re: [Errors] ON Zp 5.0.8
Reply With Quote #2

In my opinion this problem happen because of the zombie light class plugin. Just use below, then tell me the result:
PHP Code:
#include <amxmodx>
#include <fun>
#include <fakemeta_util>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <engine>
#include <dhudmessage>

#define PLUGIN "[CSO:Ghost Zombie]"
#define VERSION "1.4"
#define AUTHOR "HoRRoR, Fry!,tERoR Edit/"

new g_zclass_ghost
new const zclass_name[] = "Light Zombie" // name
new const zclass_info[] = "\yInvizibilitate \w-> \r[G]" // description
new const zclass_model[] = "ghost" // model
new const zclass_clawmodel[] = "v_knife_ghost.mdl" // claw model
new KNOCKBOMB_GHOST[] = "models/zombie_plague/zm_hands/v_bomb_ghost.mdl"
const zclass_health 5800 // health
const zclass_speed 250 // speed
const Float:zclass_gravity 0.6// gravity
const Float:zclass_knockback 2.8// knockback

new i_stealth_time_hud[33]
new 
g_cooldown[33]
new 
g_infections[33]
new 
Float:g_stealth_time[33]
new 
i_cooldown_time[33]
new 
g_maxplayers

new Float:g_stealth_time_standart 7.0 //first stealth time
new Float:g_stealth_cooldown_standart 30.0 //cooldown time
new const sound_ghost_stealth[] = "zombie_plague/ghost/invisup.wav" //stealth sound
new const sound_ghost_stealth_end[] = "zombie_plague/ghost/invisdown.wav" //end stealth sound
new const infect_ghost_sound[] = "zombie_plague/ghost/infect_01.wav" 
new const pain_ghost_sound[] = "zombie_plague/ghost/pain_01.wav" 
new const pain_ghost_sound2[] = "zombie_plague/ghost/pain_01.wav"
new const death_ghost_sound[] = "zombie_plague/ghost/die_01.wav" 


public plugin_init()
{    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_cvar("zp_zclass_ghost_zombie",VERSION,FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
    
register_clcmd("drop""use_ability_one")
    
register_forward(FM_PlayerPreThink"fw_PlayerPreThink")
    
register_event("CurWeapon","handle_gun","be","1=1")
    
RegisterHam(Ham_TakeDamage"player""CPlayer__TakeDamage");
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
register_forward(FM_EmitSound"fw_EmitSound")
    
register_logevent("roundStart"2"1=Round_Start")
    
g_maxplayers get_maxplayers()
}

public 
plugin_precache()
{
    
g_zclass_ghost zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)
    
precache_sound(sound_ghost_stealth)
    
precache_sound(sound_ghost_stealth_end)
    
precache_sound(pain_ghost_sound[0])
    
precache_sound(pain_ghost_sound2[0])
    
precache_sound(infect_ghost_sound[0])
    
precache_sound(death_ghost_sound[0])
    
precache_model(KNOCKBOMB_GHOST)        
}

public 
zp_user_infected_post(idinfector)
{
    if ((
zp_get_user_zombie_class(id) == g_zclass_ghost) && !zp_get_user_nemesis(id))
    {
        new 
text[100]
        new 
note_cooldown floatround(g_stealth_cooldown_standart)
        new 
note_stealthtime floatround(g_stealth_time_standart)
        
format(text,99,"^x04[Ghost]^x01 Puterea ^x04[Invizibilitate]^x01. | Timp:^x04 %d ^x01secunde.",note_cooldown,note_stealthtime)
        
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id
        
write_byte(id
        
write_string(text
        
message_end()

        
i_cooldown_time[id] = floatround(g_stealth_cooldown_standart)
        
remove_task(id)

        
g_stealth_time[id] = g_stealth_time_standart
        g_cooldown
[id] = 0
        g_infections
[id] = 0
        
        emit_sound
(idCHAN_WEAPONinfect_ghost_sound[0], 1.0ATTN_NORM0PITCH_LOW)
    }

    if((
zp_get_user_zombie_class(id) == g_zclass_ghost) && !zp_get_user_nemesis(id))
    {
        
g_stealth_time[infector] = g_stealth_time[infector] + 1;
        
infections_hud(infector)
    }
}

public 
zp_user_humanized_post(id)
{
    
remove_task(id)
    
fm_set_user_rendering(idkRenderFxNone000kRenderNormal0)
    
fm_set_user_rendering(idkRenderFxNone000kRenderTransAlpha255)
}

public 
zp_user_unfrozen(id)
{
    if(
is_valid_ent(id) && is_user_alive(id) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id) && zp_get_user_zombie_class(id) == g_zclass_ghost)
    {
        
fm_set_user_rendering(id)
    }
}

public 
roundStart()
{
    for (new 
1<= g_maxplayersi++)
    {
        
i_cooldown_time[i] = floatround(g_stealth_cooldown_standart)
        
g_cooldown[i] = 0
        remove_task
(i)
    }
}

public 
use_ability_one(id)
{
    if(!
is_valid_ent(id) || !is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) 
        return
    
    if(
zp_get_user_zombie_class(id) == g_zclass_ghost)
    {
        if(
g_cooldown[id] == 0)
        {
            
fm_set_user_rendering(idkRenderFxNone000kRenderTransAlpha0)
            
emit_sound(idCHAN_STREAMsound_ghost_stealth1.0ATTN_NORM0PITCH_NORM)
            
set_task(g_stealth_time[id],"ghost_make_visible",id)
            
set_task(g_stealth_cooldown_standart,"reset_cooldown",id)
            
g_cooldown[id] = 1
            
            i_cooldown_time
[id] = floatround(g_stealth_cooldown_standart)
            
i_stealth_time_hud[id] = floatround(g_stealth_time[id])
            
            
set_task(1.0"ShowHUD"id__"a",i_cooldown_time[id])
            
set_task(1.0"ShowHUDstealthes"id__"a",i_stealth_time_hud[id])
        }
    }
}


public 
ShowHUD(id)
{
    if(
is_valid_ent(id) && is_user_alive(id))
    {
        
i_cooldown_time[id] = i_cooldown_time[id] - 1;
        
set_hudmessage(025500.750.9201.01.10.00.0, -1)
        
show_hudmessage(id"Timp ramas: %d",i_cooldown_time[id])
    }else{
        
remove_task(id)
    }
}

public 
ShowHUDstealthes(id)
{
    if(
is_valid_ent(id) && is_user_alive(id))
    {
        
i_stealth_time_hud[id] = i_stealth_time_hud[id] - 1;
        
set_hudmessage(25500, -1.00.9201.01.10.00.0, -1)
        
show_hudmessage(id"Timp ramas: %d",i_stealth_time_hud[id])
    }else{
        
remove_task(id)
    }
}

public 
ghost_make_visible(id)
{
    if(!
is_valid_ent(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) 
        return
    
    if(
zp_get_user_zombie_class(id) == g_zclass_ghost)
    {
        
fm_set_user_rendering(id)
        
emit_sound(idCHAN_STREAMsound_ghost_stealth_end1.0ATTN_NORM0PITCH_NORM)
    }
}

public 
reset_cooldown(id)
{
    if(!
is_valid_ent(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) 
        return
    
    if(
zp_get_user_zombie_class(id) == g_zclass_ghost)
    {
        
g_cooldown[id] = 0
        
        
new text[100]
        
format(text,99,"^x04[Ghost]^x01 Capacitatea ^x04[Invizibilitate]^x01 este gata.")
        
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id
        
write_byte(id
        
write_string(text
        
message_end()
    }
}

public 
infections_hud(id)
{
    if(!
is_valid_ent(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) 
        return
    
    if(
zp_get_user_zombie_class(id) == g_zclass_ghost)
    {
        new 
i_stealth_time floatround(g_stealth_time[id])
        new 
text[100]
        
format(text,99,"^x04[Ghost]^x01 Invizibilitatea a ajuns la ^x04[ %d ]^x01secunde.",i_stealth_time)
        
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id
        
write_byte(id
        
write_string(text
        
message_end() 
    }
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    if (!(
damage_type DMG_FALL) || !zp_get_user_zombie(victim) || zp_get_user_zombie_class(victim) != g_zclass_ghost)
        return 
HAM_IGNORED
    
    SetHamParamFloat
(40.0)
    return 
HAM_HANDLED
}

public 
fw_PlayerPreThink(player)
{
    if(!
is_user_alive(player) || !zp_get_user_zombie(player))
        return 
FMRES_IGNORED
        
    
if(zp_get_user_zombie_class(player) == g_zclass_ghost)
        
set_pev(playerpev_flTimeStepSound999)
        
    return 
FMRES_IGNORED
}

public 
CPlayer__TakeDamage(idiVictimiInflictoriAttackerFloat:flDamagebitsDamage)
{
    if(!
is_user_alive(iAttacker) || iVictim == iAttacker)
        return
    
    if(!
zp_get_user_zombie(id) || zp_get_user_nemesis(id) || zp_get_user_survivor(id))
        return
    
    if (
zp_get_user_zombie_class(id) == g_zclass_ghost)
    {
        new 
rand random_num(1,2)
        switch(
rand)
          {
            case 
1emit_sound(idCHAN_WEAPONpain_ghost_sound[0], 1.0ATTN_NORM0PITCH_LOW)
            case 
2emit_sound(idCHAN_WEAPONpain_ghost_sound2[0], 1.0ATTN_NORM0PITCH_LOW)
        }
    }


public 
handle_gun(id)
{
    new 
weap get_user_weapon(id)

    if(
weap == CSW_FLASHBANG && zp_get_user_zombie_class(id) == g_zclass_ghost && zp_get_user_zombie(id))
    {
        
entity_set_string(idEV_SZ_viewmodelKNOCKBOMB_GHOST)
    }
    else if(
weap == CSW_SMOKEGRENADE && zp_get_user_zombie_class(id) == g_zclass_ghost && zp_get_user_zombie(id))
    {
        
entity_set_string(idEV_SZ_viewmodelKNOCKBOMB_GHOST)
    }
    return 
PLUGIN_HANDLED
}

public 
fw_EmitSound(idchannel, const sample[], Float:volumeFloat:attnflagspitch)
{
    if(!
is_user_connected(id))
        return 
FMRES_HANDLED;
        
    if (
sample[0] == 'h' && sample[1] == 'o' && sample[2] == 's' && sample[3] == 't' && sample[4] == 'a' && sample[5] == 'g' && sample[6] == 'e')
        return 
FMRES_SUPERCEDE;
    
    if(
zp_get_user_zombie(id) && zp_get_user_zombie_class(id) == g_zclass_ghost && !zp_get_user_nemesis(id))
    {
        if (
sample[7] == 'd' && ((sample[8] == 'i' && sample[9] == 'e') || (sample[8] == 'e' && sample[9] == 'a')))
        {
            
emit_sound(idCHAN_WEAPONdeath_ghost_sound[0], 1.0ATTN_NORM0PITCH_LOW)
        }
    }
    return 
FMRES_IGNORED;

If it is working well, then I will tell you what have I done. ;)

Last edited by zmd94; 11-03-2014 at 18:51.
zmd94 is offline