AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   long jump plugin (https://forums.alliedmods.net/showthread.php?t=342752)

AlexWinchester 05-10-2023 18:13

long jump plugin
 
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_forceg_LongJump_heightg_LongJump_cooldown

public plugin_init()
{
   
register_plugin(PLUGINVERSIONAUTHOR)
   
   
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 
1<= 32i++)
      
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(idget_pcvar_num(g_LongJump_force), velocity)
      
      
velocity[2] = get_pcvar_float(g_LongJump_height)
      
      
set_pev(idpev_velocityvelocity)
      
      
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(idpev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
      return 
false
   
   
static buttons
   buttons 
pev(idpev_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(entitypev_velocityvelocity)
   
   return 
floatround(vector_length(velocity));



1xAero 05-11-2023 00:13

Re: long jump plugin
 
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_forceg_LongJump_heightg_LongJump_cooldown

public plugin_init()
{
   
register_plugin(PLUGINVERSIONAUTHOR)
   
   
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_disconnected(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 
1<= 32i++)
      
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(idget_pcvar_num(g_LongJump_force), velocity)
      
      
velocity[2] = get_pcvar_float(g_LongJump_height)
      
      
set_pev(idpev_velocityvelocity)
      
      
g_last_LongJump_time[id] = get_gametime()
   }
   
   return 
FMRES_IGNORED
}

// Check if the player can longjump
public boolallow_LongJump(id)
{
   if (!
g_hasLongJump[id])
      return 
false;
   
   if (!(
pev(idpev_flags) & FL_ONGROUND) || fm_get_speed(id) < 80)
      return 
false;
   
   static 
buttons
   buttons 
pev(idpev_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 
false;
   }
    
   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(entitypev_velocityvelocity)
   
   return 
floatround(vector_length(velocity));



AlexWinchester 05-11-2023 06:40

Re: long jump plugin
 
hey

it successfully compiled

But it doesn't display two CC_SendMessage like i intended it to do,

here's a video of me testing it: https://www.youtube.com/watch?v=kV2GVNl2zLs


All times are GMT -4. The time now is 19:09.

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