Raised This Month: $ Target: $400
 0% 

Player invisibility and speed problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 12-04-2014 , 09:11   Player invisibility and speed problem
Reply With Quote #1

When edit original plugin,I make this ( and work fine ):

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <biohazard>

#define PLUGIN "VIP ivisibility"
#define VERSION "1.0.1"
#define AUTHOR "NST"

#define VipFlag ADMIN_LEVEL_H

new const vip_invisible[] = "biohazard/vip_invisibility.wav"

const Float:invisible_time 15.0
const Float:invisible_timewait 55.0
const invisible_dmg 15
const invisible_alpha 10

new g_invisible[33], g_invisible_wait[33]

new 
g_maxplayers
new g_roundend

enum 
(+= 100)
{
    
TASK_INVISIBLE 2000,
    
TASK_WAIT_INVISIBLE
}

#define ID_INVISIBLE (taskid - TASK_INVISIBLE)
#define ID_WAIT_INVISIBLE (taskid - TASK_WAIT_INVISIBLE)

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_event("DeathMsg""Death""a")
    
    
register_logevent("logevent_round_end"2"1=Round_End")
    
    
register_clcmd("drop""cmd_invisible")
    
    
g_maxplayers get_maxplayers()
}

public 
plugin_precache()
{
    
precache_sound(vip_invisible)
}

public 
client_putinserver(id)
{
    
reset_value_player(id)
}

public 
client_disconnect(id)
{
    
reset_value_player(id)
}

public 
event_round_start()
{
    
g_roundend 0
    
    
for (new id=1id<=g_maxplayersid++)
    {
        if (!
is_user_connected(id)) continue;
        
        
reset_value_player(id)
    }
}

public 
logevent_round_end()
{
    
g_roundend 1
}

public 
Death()
{
    new 
victim read_data(2
    
reset_value_player(victim)
}

public 
event_infect(id)
{
        
reset_value_player(id)
}

public 
cmd_invisible(id)
{
    if (
g_roundend) return PLUGIN_CONTINUE
    
    
if (!is_user_alive(id) || is_user_zombie(id) || !(get_user_flags(id) & VipFlag)) return PLUGIN_CONTINUE

    
new health get_user_health(id) - invisible_dmg
    
if ((get_user_flags(id) & VipFlag) && health>&& !g_invisible[id] && !g_invisible_wait[id])
    {
        
g_invisible[id] = 1
        
        set_user_health
(idhealth)

        
set_user_rendering(id,kRenderFxGlowShell,20,20,20,kRenderTransAlphainvisible_alpha)

        
set_user_footsteps(id1)

                
client_cmd(id"spk %s"vip_invisible)
                            
        
set_task(invisible_time"RemoveInvisible"id+TASK_INVISIBLE)
        
        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_CONTINUE
}

public 
RemoveInvisible(taskid)
{
    new 
id ID_INVISIBLE
    
    g_invisible
[id] = 0
    
    set_user_rendering
(id)
    
set_user_footsteps(id0)
    
    
g_invisible_wait[id] = 1
    
    set_task
(invisible_timewait"RemoveWaitInvisible"id+TASK_WAIT_INVISIBLE)

        
client_print(idprint_center"Your invisibility is over.")
}

public 
RemoveWaitInvisible(taskid)
{
    new 
id ID_WAIT_INVISIBLE
    
    g_invisible_wait
[id] = 0

        client_print
(idprint_center"Your invisibility is ready. Press G to use it.")
}

reset_value_player(id)
{
    
g_invisible[id] = 0
    g_invisible_wait
[id] = 0
    
    remove_task
(id+TASK_INVISIBLE)
    
remove_task(id+TASK_WAIT_INVISIBLE)

This gives you a VIP player ( only humans ) invisibility ( when press G )
In the original this is zombie class,and also when is in invisibility that class have speed boost.
In my VIP version I delete that speed boost option because I do not know how to get back player normal speed when invisibility time pass.
How to Restore the player speed when the invisibility is over??
This is the original plugin:

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <zombieplague>

#define PLUGIN "NST Zombie Class Speed"
#define VERSION "1.0.1"
#define AUTHOR "NST"

new const zclass_name[] = "Light"
new const zclass_info[] = "Press G To Stealth"
new const zclass_model[] = "speed_zombi_origin"
new const zclass_clawmodel[] = "v_knife_speed_zombi.mdl"
new const zclass_clawmodel_invi[] = "models/zombie_plague/v_knife_speed_zombi_invisible.mdl"
const zclass_health 1000
const zclass_speed 295
const Float:zclass_gravity 0.7
const Float:zclass_knockback 6.0

new const zombie_sound_invisible[] = "zombie_plague/zombi_pressure_female.wav"

new idclass
const Float:invisible_time 10.0
const Float:invisible_timewait 10.0
const invisible_dmg 200
const Float:invisible_speed 215.0
const Float:invisible_gravity 0.9
const invisible_alpha 10

new g_invisible[33], g_invisible_wait[33]

new 
g_msgSayText
new g_maxplayers
new g_roundend

enum 
(+= 100)
{
    
TASK_INVISIBLE 2000,
    
TASK_WAIT_INVISIBLE,
    
TASK_INVISIBLE_SOUND,
    
TASK_BOT_USE_SKILL
}

#define ID_INVISIBLE (taskid - TASK_INVISIBLE)
#define ID_WAIT_INVISIBLE (taskid - TASK_WAIT_INVISIBLE)
#define ID_INVISIBLE_SOUND (taskid - TASK_INVISIBLE_SOUND)
#define ID_BOT_USE_SKILL (taskid - TASK_BOT_USE_SKILL)

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_event("DeathMsg""Death""a")
    
register_event("CurWeapon""EventCurWeapon""be""1=1")
    
register_logevent("logevent_round_end"2"1=Round_End")
    
    
register_clcmd("drop""cmd_invisible")
    
    
g_msgSayText get_user_msgid("SayText")
    
g_maxplayers get_maxplayers()
}

public 
plugin_precache()
{
    
precache_model(zclass_clawmodel_invi)
    
precache_sound(zombie_sound_invisible)
    
    
idclass zp_register_zombie_class(zclass_namezclass_infozclass_modelzclass_clawmodelzclass_healthzclass_speedzclass_gravityzclass_knockback)
}

public 
client_putinserver(id)
{
    
reset_value_player(id)
}

public 
client_disconnect(id)
{
    
reset_value_player(id)
}

public 
event_round_start()
{
    
g_roundend 0
    
    
for (new id=1id<=g_maxplayersid++)
    {
        if (!
is_user_connected(id)) continue;
        
        
reset_value_player(id)
    }
}

public 
logevent_round_end()
{
    
g_roundend 1
}

public 
Death()
{
    new 
victim read_data(2
    
reset_value_player(victim)
}

public 
EventCurWeapon(id)
{
    if(!
is_user_alive(id)) return PLUGIN_CONTINUE;
    
    if(
g_invisible[id]) set_user_maxspeed(idinvisible_speed);
    
    return 
PLUGIN_CONTINUE;
}

public 
zp_user_infected_post(id)
{
    
reset_value_player(id)
    
    if(
zp_get_user_nemesis(id)) return;
    
    if(
zp_get_user_zombie_class(id) == idclass)
    {
        if(
is_user_bot(id))
        {
            
set_task(random_float(5.0,15.0), "bot_use_skill"id+TASK_BOT_USE_SKILL)
            return
        }
        
        
zp_colored_print(id"^x04[ZP]^x01 Your skill is^x04 Stealth^x01. Cooldown^x04 %.1f ^x01seconds."invisible_timewait)
    }
}

public 
zp_user_humanized_post(id)
{
    
reset_value_player(id)
}

public 
zp_user_unfrozen(id)
{
    if(
g_invisible[id])
    {
        
set_user_rendering(id,kRenderFxGlowShell,20,20,20,kRenderTransAlphainvisible_alpha)
        
set_user_maxspeed(idinvisible_speed)
        
set_user_gravity(idinvisible_gravity)
    }
}

public 
cmd_invisible(id)
{
    if (
g_roundend) return PLUGIN_CONTINUE
    
    
if (!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) return PLUGIN_CONTINUE

    
new health get_user_health(id) - invisible_dmg
    
if (zp_get_user_zombie_class(id) == idclass && health>&& !g_invisible[id] && !g_invisible_wait[id])
    {
        
g_invisible[id] = 1
        
        set_wpnmodel
(id)
        
set_user_health(idhealth)
        
set_user_rendering(id,kRenderFxGlowShell,20,20,20,kRenderTransAlphainvisible_alpha)
        
set_user_footsteps(id1)
        
set_user_maxspeed(idinvisible_speed)
        
set_user_gravity(idinvisible_gravity)
        
PlayEmitSound(idzombie_sound_invisible)
        
        
set_task(invisible_time"RemoveInvisible"id+TASK_INVISIBLE)
        
set_task(2.0"InvisibleSound"id+TASK_INVISIBLE_SOUND__"b")

        
zp_colored_print(id"^x04[ZP]^x01 You will^x04 Stealth^x01 for^x04 %.1f ^x01seconds."invisible_time)
        
        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_CONTINUE
}

public 
bot_use_skill(taskid)
{
    new 
id ID_BOT_USE_SKILL
    
    
if (!is_user_alive(id)) return;

    
cmd_invisible(id)
    
    
set_task(random_float(5.0,15.0), "bot_use_skill"id+TASK_BOT_USE_SKILL)
}

public 
InvisibleSound(taskid)
{
    new 
id ID_INVISIBLE_SOUND
    
    
if (g_invisible[id]) PlayEmitSound(idzombie_sound_invisible)
    else 
remove_task(taskid)
}

public 
RemoveInvisible(taskid)
{
    new 
id ID_INVISIBLE
    
    g_invisible
[id] = 0
    
    set_wpnmodel
(id)
    
set_user_rendering(id)
    
set_user_footsteps(id0)
    
set_user_maxspeed(idfloat(zclass_speed))
    
set_user_gravity(idzclass_gravity)
    
zp_colored_print(id"^x04[ZP]^x01 Your^x04 Stealth^x01 skill is over.")
    
    
g_invisible_wait[id] = 1
    
    set_task
(invisible_timewait"RemoveWaitInvisible"id+TASK_WAIT_INVISIBLE)
}

public 
RemoveWaitInvisible(taskid)
{
    new 
id ID_WAIT_INVISIBLE
    
    g_invisible_wait
[id] = 0
    
    zp_colored_print
(id"^x04[ZP]^x01 Your skill^x04 Stealth^x01 is ready.")
}

set_wpnmodel(id)
{
    if (!
is_user_alive(id)) return;
    
    if (
get_user_weapon(id) == CSW_KNIFE)
    {
        if (
g_invisible[id])
        {
            
set_pev(idpev_viewmodel2zclass_clawmodel_invi)
        }
        else
        {
            static 
temp[100]
            
format(tempcharsmax(temp), "models/zombie_plague/%s"zclass_clawmodel)
            
set_pev(idpev_viewmodel2temp)
        }
    }    
}

PlayEmitSound(id, const sound[])
{
    
emit_sound(idCHAN_VOICEsound1.0ATTN_NORM0PITCH_NORM)
}

reset_value_player(id)
{
    
g_invisible[id] = 0
    g_invisible_wait
[id] = 0
    
    remove_task
(id+TASK_INVISIBLE)
    
remove_task(id+TASK_WAIT_INVISIBLE)
    
remove_task(id+TASK_BOT_USE_SKILL)
}

zp_colored_print(target, const message[], any:...)
{
    static 
buffer[512], iargscount
    argscount 
numargs()
    
    if (!
target)
    {
        static 
player
        
for (player 1player <= g_maxplayersplayer++)
        {
            if (!
is_user_connected(player))
                continue;
            
            static 
changed[5], changedcount
            changedcount 
0
            
            
for (2argscounti++)
            {
                if (
getarg(i) == LANG_PLAYER)
                {
                    
setarg(i0player)
                    
changed[changedcount] = i
                    changedcount
++
                }
            }
            
            
vformat(buffercharsmax(buffer), message3)
            
            
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_player)
            
write_byte(player)
            
write_string(buffer)
            
message_end()
            
            for (
0changedcounti++)
                
setarg(changed[i], 0LANG_PLAYER)
        }
    }
    else
    {
        
vformat(buffercharsmax(buffer), message3)
        
        
message_begin(MSG_ONEg_msgSayText_target)
        
write_byte(target)
        
write_string(buffer)
        
message_end()
    }
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/ 
You should look on:
PHP Code:
public RemoveInvisible(taskid)
{
    new 
id ID_INVISIBLE
    
    g_invisible
[id] = 0
    
    set_wpnmodel
(id)
    
set_user_rendering(id)
    
set_user_footsteps(id0)
    
set_user_maxspeed(idfloat(zclass_speed))
    
set_user_gravity(idzclass_gravity)
    
zp_colored_print(id"^x04[ZP]^x01 Your^x04 Stealth^x01 skill is over.")
    
    
g_invisible_wait[id] = 1
    
    set_task
(invisible_timewait"RemoveWaitInvisible"id+TASK_WAIT_INVISIBLE)

Here we see that the zombie speed returned to normal.
PHP Code:
set_user_maxspeed(idfloat(zclass_speed)) 
I do not know how to do it for VIP ( human ) players?

Last edited by Krtola; 12-04-2014 at 09:13.
Krtola is offline
Send a message via Skype™ to Krtola
 



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 15:24.


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