Hello,
This is the 1st time i've written a message here,
But i'm having a small problem to get my long jump plugin to work properly that i saw from zombie plague
I'm trying to make a CC_SendMessage for the cooldowns, For how many seconds i need to wait before i can jump again.
and CC_SendMessage for when i can jump again,
But it doesn't display any of those 2 messages when i try to use it.
only when i spawn with jump pack,
This is the error im getting when i compile the sma file:
PHP Code:
//// longjump.sma
//
// E:\steamServer3\condzero\cstrike\addons\amxmodx\scripting\longjump.sma(32) : warning 233: symbol "client_disconnect" is marked as deprecated: Use client_disconnected() instead.
//
// E:\steamServer3\condzero\cstrike\addons\amxmodx\scripting\longjump.sma(99) : warning 209: function "allow_LongJump" should return a value
// E:\steamServer3\condzero\cstrike\addons\amxmodx\scripting\longjump.sma(107) : error 078: function uses both "return" and "return <value>"
//
// 1 Error.
// Could not locate output file compiled\longjump.amx (compile failed).
//
// Compilation Time: 0,2 sec
// ----------------------------------------
Here is the code:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <cromchat>
#define PLUGIN "Long Jump"
#define VERSION "1.0"
#define AUTHOR "Alex Winchester"
new bool:g_hasLongJump[33]
new Float:g_last_LongJump_time[33]
new g_LongJump_force, g_LongJump_height, g_LongJump_cooldown
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Spawn, "player", "Player_Spawn", 1)
g_LongJump_force = register_cvar("lj_longjump_force", "550")
g_LongJump_height = register_cvar("lj_longjump_height", "255")
g_LongJump_cooldown = register_cvar("lj_longjump_cooldown", "5.0")
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_event("DeathMsg", "death", "a")
register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
CC_SetPrefix("&x07[LJ]")
}
// Reset on disconnection
public client_disconnect(id)
{
g_hasLongJump[id] = false
}
// Reset on death
public death()
{
g_hasLongJump[read_data(2)] = false
}
// Reset at round start (for everyone)
public event_round_start()
{
for (new i = 1; i <= 32; i++)
g_hasLongJump[i] = true
}
public Player_Spawn(id)
{
if (is_user_alive(id))
{
g_hasLongJump[id] = true
CC_SendMessage(id, "&x01You have recieved a Jump Pack. To use it, press duck and jump while moving forward.")
}
}
public fw_PlayerPreThink(id)
{
if (!is_user_alive(id))
return FMRES_IGNORED
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()
}
return FMRES_IGNORED
}
// Check if the player can longjump
allow_LongJump(id)
{
if (!g_hasLongJump[id])
return false
if (!(pev(id, pev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
return false
static buttons
buttons = pev(id, pev_button)
if (!is_user_bot(id) && (!(buttons & IN_JUMP) || !(buttons & IN_DUCK)))
return false
static Float:cooldown
cooldown = get_pcvar_float(g_LongJump_cooldown)
if (get_gametime() - g_last_LongJump_time[id] < cooldown)
{
CC_SendMessage(id, "&x01Please wait &x07%i &x01seconds to do &x07leap &x01again!")
return;
}
if(g_last_LongJump_time[id] == cooldown)
{
CC_SendMessage(id, "&x01Now you can do &x07leap &x01again!")
}
return true
}
// Get entity's speed (from fakemeta_util)
stock fm_get_speed(entity)
{
static Float:velocity[3]
pev(entity, pev_velocity, velocity)
return floatround(vector_length(velocity));
}