Converted Leap Jump

Zombies/Humans Extra-Items
Post Reply
johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

Leap Jump

#1

Post by johnnysins2000 » 2 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 91 times
    Leap.zip
    [ZE] Extra-Item: Leap Jump
    (6.34 KiB) Downloaded 91 times
Last edited by Raheem on 28 Jul 2017, 02:23, 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
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#2

Post by Raheem » 2 Years Ago

Nice work bro :D.
You don't know? Learn and you will know.

User avatar
Mohamed Alaa
Mod Developer
Mod Developer
Egypt
Posts: 622
Joined: 2 Years Ago
Location: Egypt
Has thanked: 34 times
Been thanked: 48 times
Age: 19
Contact:

#3

Post by Mohamed Alaa » 2 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 web projects.
CS 1.6 hosting: powergamingtech.com

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#4

Post by johnnysins2000 » 2 Years Ago

Jack GamePlay wrote:
2 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 on 27 Mar 2017, 10:57, edited 1 time in total.
Nobody Is That Busy If They Make Time :roll:

johnnysins2000
Veteran Member
Veteran Member
Pakistan
Posts: 672
Joined: 2 Years Ago
Location: Lahore
Has thanked: 11 times
Been thanked: 10 times
Age: 22
Contact:

#5

Post by johnnysins2000 » 2 Years Ago

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

User avatar
Raheem
Mod Developer
Mod Developer
Egypt
Posts: 1972
Joined: 2 Years Ago
Location: Egypt
Has thanked: 32 times
Been thanked: 108 times
Age: 22
Contact:

#6

Post by Raheem » 2 Years Ago

Nice johnny.
You don't know? Learn and you will know.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests