Raised This Month: $51 Target: $400
 12% 

Suggestion / Subplugin Request [REQ] Show Longjump Icon when leap enabled


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
C00LSH33P
Member
Join Date: Apr 2013
Location: Meow City
Old 09-07-2014 , 12:22   [REQ] Show Longjump Icon when leap enabled
Reply With Quote #1

Hello, any good coder can make a plugin for zp508 that display the HL longjump icon constantly to any human/zombie whenever they has the leap ability enabled/given to them? No matter to first or last zombie, nemesis, survivor, or to any players that has the leap ability in any modes, let the longjump icon shows only to them(like the biohazard icon plugin). Also, don't forget to remove the icon whenever the player is dead or round end. etc.

This icon:



Thank you in advance.



Edit: Similar to this plugin but for ZP. And it display to whoever that currently has ZP leap, not item_longjump!

Last edited by C00LSH33P; 09-07-2014 at 19:55. Reason: adding stuff..
C00LSH33P is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 09-07-2014 , 13:25   Re: [REQ] Show Longjump Icon when leap enabled
Reply With Quote #2

Try this: https://forums.alliedmods.net/showthread.php?p=1653848
wicho is offline
C00LSH33P
Member
Join Date: Apr 2013
Location: Meow City
Old 09-07-2014 , 19:43   Re: [REQ] Show Longjump Icon when leap enabled
Reply With Quote #3

Quote:
Originally Posted by wicho View Post
Try this: .......oops! zZZ
Seen and tried that before making this thread. Even though it's clearly , I still tried it and like what I would expected before installing it, doesn't work. Should have linked it before in first post.

Btw, that is a good example for what I'm requesting here. But I want it as addon for ZP50+!


Thank you anyway.
C00LSH33P is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 09-08-2014 , 05:37   Re: [REQ] Show Longjump Icon when leap enabled
Reply With Quote #4

Quote:
if leap -> meassage_begin
ZASTRELIS is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 09-09-2014 , 01:22   Re: [REQ] Show Longjump Icon when leap enabled
Reply With Quote #5

Replace your zp50_leap with this and try..

PHP Code:
/*================================================================================
    
    --------------------------
    -*- [ZP] Leap/Longjump -*-
    --------------------------
    
    This plugin is part of Zombie Plague Mod and is distributed under the
    terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
    
================================================================================*/

#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#include <zp50_gamemodes>
#define LIBRARY_NEMESIS "zp50_class_nemesis"
#include <zp50_class_nemesis>
#define LIBRARY_SURVIVOR "zp50_class_survivor"
#include <zp50_class_survivor>

#define MAXPLAYERS 32

new g_GameModeInfectionID
new Float:g_LeapLastTime[MAXPLAYERS+1]

new 
cvar_leap_zombiecvar_leap_zombie_forcecvar_leap_zombie_heightcvar_leap_zombie_cooldown
new cvar_leap_nemesiscvar_leap_nemesis_forcecvar_leap_nemesis_heightcvar_leap_nemesis_cooldown
new cvar_leap_survivorcvar_leap_survivor_forcecvar_leap_survivor_heightcvar_leap_survivor_cooldown

new iconstatus

public plugin_init()
{
    
register_plugin("[ZP] Leap/Longjump"ZP_VERSION_STRING"ZP Dev Team")
    
    
cvar_leap_zombie register_cvar("zp_leap_zombie""3"// 1-all // 2-first only // 3-last only
    
cvar_leap_zombie_force register_cvar("zp_leap_zombie_force""500")
    
cvar_leap_zombie_height register_cvar("zp_leap_zombie_height""300")
    
cvar_leap_zombie_cooldown register_cvar("zp_leap_zombie_cooldown""10.0")
    
    
// Nemesis Class loaded?
    
if (LibraryExists(LIBRARY_NEMESISLibType_Library))
    {
        
cvar_leap_nemesis register_cvar("zp_leap_nemesis""1")
        
cvar_leap_nemesis_force register_cvar("zp_leap_nemesis_force""500")
        
cvar_leap_nemesis_height register_cvar("zp_leap_nemesis_height""300")
        
cvar_leap_nemesis_cooldown register_cvar("zp_leap_nemesis_cooldown""5.0")
    }
    
    
// Survivor Class loaded?
    
if (LibraryExists(LIBRARY_SURVIVORLibType_Library))
    {
        
cvar_leap_survivor register_cvar("zp_leap_survivor""0")
        
cvar_leap_survivor_force register_cvar("zp_leap_survivor_force""500")
        
cvar_leap_survivor_height register_cvar("zp_leap_survivor_height""300")
        
cvar_leap_survivor_cooldown register_cvar("zp_leap_survivor_cooldown""5.0")
    }
    
    
register_forward(FM_PlayerPreThink"fw_PlayerPreThink")
        
RegisterHamHam_Killed"player""fw_PlayerKilled" )
        
iconstatus get_user_msgid("StatusIcon")
}

public 
plugin_natives()
{
    
set_module_filter("module_filter")
    
set_native_filter("native_filter")
}
public 
module_filter(const module[])
{
    if (
equal(moduleLIBRARY_NEMESIS) || equal(moduleLIBRARY_SURVIVOR))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}
public 
native_filter(const name[], indextrap)
{
    if (!
trap)
        return 
PLUGIN_HANDLED;
        
    return 
PLUGIN_CONTINUE;
}

public 
plugin_cfg()
{
    
g_GameModeInfectionID zp_gamemodes_get_id("Infection Mode")
}

// Forward Player PreThink
public fw_PlayerPreThink(id)
{
    
// Not alive
    
if (!is_user_alive(id))
        return;
    
    
// Don't allow leap if player is frozen (e.g. freezetime)
    
if (get_user_maxspeed(id) == 1.0)
        return;
    
    static 
Float:cooldownforceFloat:height
    
    
// Nemesis Class loaded?
    
if (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(id))
    {
        
// Check if nemesis should leap
        
if (!get_pcvar_num(cvar_leap_nemesis)) return;
        
cooldown get_pcvar_float(cvar_leap_nemesis_cooldown)
        
force get_pcvar_num(cvar_leap_nemesis_force)
        
height get_pcvar_float(cvar_leap_nemesis_height)
    }

    
// Survivor Class loaded?
    
else if (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(id))
    {
        
// Check if survivor should leap
        
if (!get_pcvar_num(cvar_leap_survivor)) return;
        
cooldown get_pcvar_float(cvar_leap_survivor_cooldown)
        
force get_pcvar_num(cvar_leap_survivor_force)
        
height get_pcvar_float(cvar_leap_survivor_height)
    }
    else
    {
        
// Not a zombie
        
if (!zp_core_is_zombie(id))
            return;
        
        
// Check if zombie should leap
        
switch (get_pcvar_num(cvar_leap_zombie))
        {
            
// Disabled
            
case 0: return;
            
// First zombie (only on infection rounds)
            
case 2: if (!zp_core_is_first_zombie(id) || (zp_gamemodes_get_current() != g_GameModeInfectionID)) return;
            
// Last zombie
            
case 3: if (!zp_core_is_last_zombie(id)) return;
        }
        
cooldown get_pcvar_float(cvar_leap_zombie_cooldown)
        
force get_pcvar_num(cvar_leap_zombie_force)
        
height get_pcvar_float(cvar_leap_zombie_height)
    }
    
    static 
Float:current_time
    current_time 
get_gametime()
    
    
// Cooldown not over yet
    
if (current_time g_LeapLastTime[id] < cooldown)
        return;
    
    
// Not doing a longjump (don't perform check for bots, they leap automatically)
    
if (!is_user_bot(id) && !(pev(idpev_button) & (IN_JUMP IN_DUCK) == (IN_JUMP IN_DUCK)))
        return;
    
    
// Not on ground or not enough speed
    
if (!(pev(idpev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
        return;
    
    static 
Float:velocity[3]
    
    
// Make velocity vector
    
velocity_by_aim(idforcevelocity)
    
    
// Set custom height
    
velocity[2] = height
    
    
// Apply the new velocity
    
set_pev(idpev_velocityvelocity)

        
// Set longjump icon
       
Icon_On(id)
    
    
// Update last leap time
    
g_LeapLastTime[id] = current_time
}

public 
fw_PlayerKilled(id
{
    
Icon_Off(id)
}

public 
client_disconnect(id
{
    
Icon_Off(id)
}

public 
Icon_On(id
{
    
message_beginMSG_ONE_UNRELIABLEiconstatus, { 00}, id)
    
write_byte(1)
    
write_string("item_longjump")
    
write_byte(255)
    
write_byte(127)
    
write_byte(0)
    
message_end()
}

public 
Icon_Off(id
{
    
message_beginMSG_ONE_UNRELIABLEiconstatus, { 00}, id)
    
write_byte(0)
    
write_string("item_longjump")
    
message_end()
}

// Get entity's speed (from fakemeta_util)
stock fm_get_speed(entity)
{
    static 
Float:velocity[3]
    
pev(entitypev_velocityvelocity)
    
    return 
floatround(vector_length(velocity));


Last edited by wicho; 09-09-2014 at 02:15.
wicho is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 09-09-2014 , 01:48   Re: [REQ] Show Longjump Icon when leap enabled
Reply With Quote #6

Quote:
Originally Posted by wicho View Post
Replace your zp50_leap with this and try..
You must be rewrite another one script for remove this icon when leaper will be dead.
ZASTRELIS is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 09-09-2014 , 02:10   Re: [REQ] Show Longjump Icon when leap enabled
Reply With Quote #7

I edited the code, the icon should be removed when he dies and when he disconnect..
wicho is offline
C00LSH33P
Member
Join Date: Apr 2013
Location: Meow City
Old 09-09-2014 , 23:49   Re: [REQ] Show Longjump Icon when leap enabled
Reply With Quote #8

Quote:
Originally Posted by wicho View Post
Replace your zp50_leap with this and try..

PHP Code:
code 
Compiled with 3 warnings. (hate this btw)

It works but there are still a couple of issues:

1. Icon only display AFTER a player has done leap once per round. If a player has never done leap in a round, it'll never show up. So, player need to do leap first for the icon to display, in every round. Please make it display soon if player has leap and not after doing first leap and then display.

2. Icon is not removed for last zombie setting(zp_leap_zombie 3). For instance, I'm a last zombie and I have leap. Then I infect other human so I'm no longer the last zombie and leap is removed automatically. But the icon is still displayed. Please make it remove after all that.



Other than that, it works pretty good.

Last edited by C00LSH33P; 09-10-2014 at 02:30.
C00LSH33P is offline
C00LSH33P
Member
Join Date: Apr 2013
Location: Meow City
Old 10-04-2014 , 10:56   Re: [REQ] Show Longjump Icon when leap enabled
Reply With Quote #9

bump
C00LSH33P is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 10-06-2014 , 20:18   Re: [REQ] Show Longjump Icon when leap enabled
Reply With Quote #10

Try:

PHP Code:
/*================================================================================
    
    --------------------------
    -*- [ZP] Leap/Longjump -*-
    --------------------------
    
    This plugin is part of Zombie Plague Mod and is distributed under the
    terms of the GNU General Public License. Check ZP_ReadMe.txt for details.
    
================================================================================*/

#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <hamsandwich>
#include <zp50_gamemodes>
#define LIBRARY_NEMESIS "zp50_class_nemesis"
#include <zp50_class_nemesis>
#define LIBRARY_SURVIVOR "zp50_class_survivor"
#include <zp50_class_survivor>

#define MAXPLAYERS 32

new g_GameModeInfectionID
new Float:g_LeapLastTime[MAXPLAYERS+1]

new 
cvar_leap_zombiecvar_leap_zombie_forcecvar_leap_zombie_heightcvar_leap_zombie_cooldown
new cvar_leap_nemesiscvar_leap_nemesis_forcecvar_leap_nemesis_heightcvar_leap_nemesis_cooldown
new cvar_leap_survivorcvar_leap_survivor_forcecvar_leap_survivor_heightcvar_leap_survivor_cooldown

new iconstatus

public plugin_init()
{
    
register_plugin("[ZP] Leap/Longjump"ZP_VERSION_STRING"ZP Dev Team")
    
    
cvar_leap_zombie register_cvar("zp_leap_zombie""3"// 1-all // 2-first only // 3-last only
    
cvar_leap_zombie_force register_cvar("zp_leap_zombie_force""500")
    
cvar_leap_zombie_height register_cvar("zp_leap_zombie_height""300")
    
cvar_leap_zombie_cooldown register_cvar("zp_leap_zombie_cooldown""10.0")
    
    
// Nemesis Class loaded?
    
if (LibraryExists(LIBRARY_NEMESISLibType_Library))
    {
        
cvar_leap_nemesis register_cvar("zp_leap_nemesis""1")
        
cvar_leap_nemesis_force register_cvar("zp_leap_nemesis_force""500")
        
cvar_leap_nemesis_height register_cvar("zp_leap_nemesis_height""300")
        
cvar_leap_nemesis_cooldown register_cvar("zp_leap_nemesis_cooldown""5.0")
    }
    
    
// Survivor Class loaded?
    
if (LibraryExists(LIBRARY_SURVIVORLibType_Library))
    {
        
cvar_leap_survivor register_cvar("zp_leap_survivor""0")
        
cvar_leap_survivor_force register_cvar("zp_leap_survivor_force""500")
        
cvar_leap_survivor_height register_cvar("zp_leap_survivor_height""300")
        
cvar_leap_survivor_cooldown register_cvar("zp_leap_survivor_cooldown""5.0")
    }
    
    
register_forward(FM_PlayerPreThink"fw_PlayerPreThink")
        
RegisterHamHam_Killed"player""fw_PlayerKilled" )
        
iconstatus get_user_msgid("StatusIcon")
}

public 
plugin_natives()
{
    
set_module_filter("module_filter")
    
set_native_filter("native_filter")
}
public 
module_filter(const module[])
{
    if (
equal(moduleLIBRARY_NEMESIS) || equal(moduleLIBRARY_SURVIVOR))
        return 
PLUGIN_HANDLED;
    
    return 
PLUGIN_CONTINUE;
}
public 
native_filter(const name[], indextrap)
{
    if (!
trap)
        return 
PLUGIN_HANDLED;
        
    return 
PLUGIN_CONTINUE;
}

public 
plugin_cfg()
{
    
g_GameModeInfectionID zp_gamemodes_get_id("Infection Mode")
}

// Forward Player PreThink
public fw_PlayerPreThink(id)
{
    
// Not alive
    
if (!is_user_alive(id))
        return;
    
    
// Don't allow leap if player is frozen (e.g. freezetime)
    
if (get_user_maxspeed(id) == 1.0)
        return;
    
    static 
Float:cooldownforceFloat:height
    
    
// Nemesis Class loaded?
    
if (LibraryExists(LIBRARY_NEMESISLibType_Library) && zp_class_nemesis_get(id))
    {
        
// Check if nemesis should leap
        
if (!get_pcvar_num(cvar_leap_nemesis)) return;
        
cooldown get_pcvar_float(cvar_leap_nemesis_cooldown)
        
force get_pcvar_num(cvar_leap_nemesis_force)
        
height get_pcvar_float(cvar_leap_nemesis_height)
    }

    
// Survivor Class loaded?
    
else if (LibraryExists(LIBRARY_SURVIVORLibType_Library) && zp_class_survivor_get(id))
    {
        
// Check if survivor should leap
        
if (!get_pcvar_num(cvar_leap_survivor)) return;
        
cooldown get_pcvar_float(cvar_leap_survivor_cooldown)
        
force get_pcvar_num(cvar_leap_survivor_force)
        
height get_pcvar_float(cvar_leap_survivor_height)
    }
    else
    {
        
// Not a zombie
        
if (!zp_core_is_zombie(id))
            return;
        
        
// Check if zombie should leap
        
switch (get_pcvar_num(cvar_leap_zombie))
        {
            
// Disabled
            
case 0: return;
            
// First zombie (only on infection rounds)
            
case 2: if (!zp_core_is_first_zombie(id) || (zp_gamemodes_get_current() != g_GameModeInfectionID)) return;
            
// Last zombie
            
case 3: if (!zp_core_is_last_zombie(id))  Icon_Off(id) return;
        }
        
cooldown get_pcvar_float(cvar_leap_zombie_cooldown)
        
force get_pcvar_num(cvar_leap_zombie_force)
        
height get_pcvar_float(cvar_leap_zombie_height)
    }
    
    static 
Float:current_time
    current_time 
get_gametime()
    
    
// Cooldown not over yet
    
if (current_time g_LeapLastTime[id] < cooldown)
        return;
    
    
// Not doing a longjump (don't perform check for bots, they leap automatically)
    
if (!is_user_bot(id) && !(pev(idpev_button) & (IN_JUMP IN_DUCK) == (IN_JUMP IN_DUCK)))
        return;
    
    
// Not on ground or not enough speed
    
if (!(pev(idpev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
        return;
    
    static 
Float:velocity[3]
    
    
// Make velocity vector
    
velocity_by_aim(idforcevelocity)
    
    
// Set custom height
    
velocity[2] = height
    
    
// Apply the new velocity
    
set_pev(idpev_velocityvelocity)

    
// Set longjump icon
    
Icon_On(id)
    
    
// Update last leap time
    
g_LeapLastTime[id] = current_time
}

public 
fw_PlayerKilled(id
{
    
Icon_Off(id)
}

public 
client_disconnect(id
{
    
Icon_Off(id)
}

public 
Icon_On(id
{
    
message_beginMSG_ONE_UNRELIABLEiconstatus, { 00}, id)
    
write_byte(1)
    
write_string("item_longjump")
    
write_byte(255)
    
write_byte(127)
    
write_byte(0)
    
message_end()
}

public 
Icon_Off(id
{
    
message_beginMSG_ONE_UNRELIABLEiconstatus, { 00}, id)
    
write_byte(0)
    
write_string("item_longjump")
    
message_end()
}

// Get entity's speed (from fakemeta_util)
stock fm_get_speed(entity)
{
    static 
Float:velocity[3]
    
pev(entitypev_velocityvelocity)
    
    return 
floatround(vector_length(velocity));

Test if the icon removes to the last zombie..

Last edited by wicho; 10-06-2014 at 20:56.
wicho 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 11:16.


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