Converted Leap Jump

Zombies/Humans Extra-Items
Post Reply
johnnysins2000
Veteran Member
Veteran Member
Paraguay
Posts: 678
Joined: 7 years ago
Location: Paraguay
Contact:

Leap Jump

#1

Post by johnnysins2000 » 7 years ago

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
    Leap.zip
    [ZE] Extra-Item: Leap Jump
    (6.34 KiB) Downloaded 529 times
Last edited by Raheem 6 years ago, edited 3 times in total.
Reason: Updating to work with Zombie Escape v1.1
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 7 years ago

Nice work bro :D.
He who fails to plan is planning to fail

User avatar
Night Fury
Mod Developer
Mod Developer
Posts: 677
Joined: 7 years ago
Contact:

#3

Post by Night Fury » 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))
}
 
Want your own mod edition? PM me.
Accepting private projects.
Discord: Fury#7469
Image

johnnysins2000
Veteran Member
Veteran Member
Paraguay
Posts: 678
Joined: 7 years ago
Location: Paraguay
Contact:

#4

Post by johnnysins2000 » 7 years ago

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
Last edited by johnnysins2000 7 years ago, edited 1 time in total.
Nobody Is That Busy If They Make Time :roll:

johnnysins2000
Veteran Member
Veteran Member
Paraguay
Posts: 678
Joined: 7 years ago
Location: Paraguay
Contact:

#5

Post by johnnysins2000 » 7 years ago

Ok Code is Updated Guyz . Enjoy !
Nobody Is That Busy If They Make Time :roll:

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#6

Post by Raheem » 7 years ago

Nice johnny.
He who fails to plan is planning to fail

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 4 guests