Page 1 of 1
Leap Jump
Posted: 24 Mar 2017, 17:39
by johnnysins2000
Leap Jump
Description:
- Hello Guyz This Is my First Time converting Extra Item for Zombies only. It is Working Fine Without Any Problem. This Extra Item will allow You to have a long jump after every 10 seconds.
Installation & Instructions:
- Simply install it like any plugin
Downloads:
- Leap.zip
- [ZE] Extra-Item: Leap Jump
- (6.34 KiB) Downloaded 529 times
Re: Leap Jump
Posted: 24 Mar 2017, 18:30
by Raheem
Nice work bro
.
Re: Leap Jump
Posted: 24 Mar 2017, 22:27
by Night Fury
Better code:
Code: Select all
#include <zombie_escape>
new bool:g_hasLongJump[33], Float:g_last_LongJump_time[33]
new g_iItemID, g_LongJump_cost, g_LongJump_force, g_LongJump_height, g_LongJump_cooldown , g_iLimit[33] , cvar_limit
public plugin_init()
{
register_plugin("[ZE] Extra Item: Leap", "1.0", "Whoever")
g_iItemID = ze_register_item("Leap", 20)
g_LongJump_force = register_cvar("ze_longjump_force", "580")
g_LongJump_height = register_cvar("ze_longjump_height", "320")
g_LongJump_cooldown = register_cvar("ze_longjump_cooldown", "10.0")
g_LongJump_cost = register_cvar("ze_longjump_cost", "20")
cvar_limit = register_cvar("ze_longjump_limit", "3")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_event("DeathMsg", "death", "a")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}
public client_disconnect(id) g_hasLongJump[id] = false // Reset on disconnection
public death() g_hasLongJump[read_data(2)] = false // Reset on death
public ze_user_humanized(id) g_hasLongJump[id] = false // Reset if turned into human
public event_round_start() // Reset at round start (for everyone)
{
for (new i = 1; i <= get_maxplayers(); i++)
{
g_hasLongJump[i] = false
}
}
public ze_select_item_pre(id, itemid)
{
if (itemid != g_iItemID) // Return Available and we will block it in Post, So it dosen't affect other plugins
return ZE_ITEM_AVAILABLE
if (!ze_is_user_zombie(id)) // Available for Zombies only, So don't show it for Humans
return ZE_ITEM_DONT_SHOW
if (g_iLimit[id] >= get_pcvar_num(cvar_limit) || g_hasLongJump[id])
return ZE_ITEM_UNAVAILABLE
return ZE_ITEM_AVAILABLE
}
public ze_select_item_post(id, itemid)
{
if (itemid != g_iItemID)
return
g_iLimit[id]++
g_hasLongJump[id] = true
client_print(id, print_chat, "[ZE] You have bought a Leap Jump. To use it, press duck and jump while moving forward.")
}
public fw_PlayerPreThink(id)
{
if (!is_user_alive(id))
return
if (allow_LongJump(id))
{
static Float:velocity[3]
velocity_by_aim(id, get_pcvar_num(g_LongJump_force), velocity)
velocity[2] = get_pcvar_float(g_LongJump_height)
set_pev(id, pev_velocity, velocity)
g_last_LongJump_time[id] = get_gametime()
}
}
allow_LongJump(id) // Check if the player can longjump
{
if (!g_hasLongJump[id] || !(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80 || !is_user_bot(id) && (!(pev(id, pev_button) & IN_JUMP) || !(pev(id, pev_button) & IN_DUCK)) || get_gametime() - g_last_LongJump_time[id] < get_pcvar_float(g_LongJump_cooldown))
return false
return true
}
stock fm_get_speed(entity) // Get entity's speed (from fakemeta_util)
{
static Float:velocity[3]
pev(entity, pev_velocity, velocity)
return floatround(vector_length(velocity))
}
Re: Leap Jump
Posted: 25 Mar 2017, 04:36
by johnnysins2000
Jack GamePlay wrote: ↑7 years ago
Better code:
Code: Select all
#include <zombie_escape>
new bool:g_hasLongJump[33], Float:g_last_LongJump_time[33]
new g_iItemID, g_LongJump_cost, g_LongJump_force, g_LongJump_height, g_LongJump_cooldown , g_iLimit[33] , cvar_limit
public plugin_init()
{
register_plugin("[ZE] Extra Item: Leap", "1.0", "Whoever")
g_iItemID = ze_register_item("Leap", 20)
g_LongJump_force = register_cvar("ze_longjump_force", "580")
g_LongJump_height = register_cvar("ze_longjump_height", "320")
g_LongJump_cooldown = register_cvar("ze_longjump_cooldown", "10.0")
g_LongJump_cost = register_cvar("ze_longjump_cost", "20")
cvar_limit = register_cvar("ze_longjump_limit", "3")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_event("DeathMsg", "death", "a")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}
public client_disconnect(id) g_hasLongJump[id] = false // Reset on disconnection
public death() g_hasLongJump[read_data(2)] = false // Reset on death
public ze_user_humanized(id) g_hasLongJump[id] = false // Reset if turned into human
public event_round_start() // Reset at round start (for everyone)
{
for (new i = 1; i <= get_maxplayers(); i++)
{
g_hasLongJump[i] = false
}
}
public ze_select_item_pre(id, itemid)
{
if (itemid != g_iItemID) // Return Available and we will block it in Post, So it dosen't affect other plugins
return ZE_ITEM_AVAILABLE
if (!ze_is_user_zombie(id)) // Available for Zombies only, So don't show it for Humans
return ZE_ITEM_DONT_SHOW
if (g_iLimit[id] >= get_pcvar_num(cvar_limit) || g_hasLongJump[id])
return ZE_ITEM_UNAVAILABLE
return ZE_ITEM_AVAILABLE
}
public ze_select_item_post(id, itemid)
{
if (itemid != g_iItemID)
return
g_iLimit[id]++
g_hasLongJump[id] = true
client_print(id, print_chat, "[ZE] You have bought a Leap Jump. To use it, press duck and jump while moving forward.")
}
public fw_PlayerPreThink(id)
{
if (!is_user_alive(id))
return
if (allow_LongJump(id))
{
static Float:velocity[3]
velocity_by_aim(id, get_pcvar_num(g_LongJump_force), velocity)
velocity[2] = get_pcvar_float(g_LongJump_height)
set_pev(id, pev_velocity, velocity)
g_last_LongJump_time[id] = get_gametime()
}
}
allow_LongJump(id) // Check if the player can longjump
{
if (!g_hasLongJump[id] || !(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80 || !is_user_bot(id) && (!(pev(id, pev_button) & IN_JUMP) || !(pev(id, pev_button) & IN_DUCK)) || get_gametime() - g_last_LongJump_time[id] < get_pcvar_float(g_LongJump_cooldown))
return false
return true
}
stock fm_get_speed(entity) // Get entity's speed (from fakemeta_util)
{
static Float:velocity[3]
pev(entity, pev_velocity, velocity)
return floatround(vector_length(velocity))
}
OK Jack I will Update The Code
Re: Leap Jump
Posted: 25 Mar 2017, 10:51
by johnnysins2000
Ok Code is Updated Guyz . Enjoy !
Re: Leap Jump
Posted: 25 Mar 2017, 17:45
by Raheem
Nice johnny.