Raised This Month: $51 Target: $400
 12% 

long jump plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AlexWinchester
Junior Member
Join Date: May 2023
Old 05-10-2023 , 18:13   long jump plugin
Reply With Quote #1

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));

AlexWinchester is offline
1xAero
Member
Join Date: Feb 2018
Location: Sakha, Russia
Old 05-11-2023 , 00:13   Re: long jump plugin
Reply With Quote #2

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));


Last edited by 1xAero; 05-11-2023 at 00:16. Reason: Wrong helping section
1xAero is offline
AlexWinchester
Junior Member
Join Date: May 2023
Old 05-11-2023 , 06:40   Re: long jump plugin
Reply With Quote #3

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

Last edited by AlexWinchester; 05-11-2023 at 06:41. Reason: video wasn't working
AlexWinchester is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:08.


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