Raised This Month: $ Target: $400
 0% 

request to add code to a run/sprint plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Tote
Senior Member
Join Date: Jul 2023
Old 08-24-2023 , 11:44   Re: request to add code to a run/sprint plugin
Reply With Quote #20

Quote:
Originally Posted by Siska1 View Post
Again no work and no run. In my code everything works for me and I wanted to add a simple constraint so I don't waste my runs. There should be no sound when I switch to a weapon and the message should be to every player when he enters the server, and not at the beginning of the map as it is now. if I switch quickly to a knife and then to a weapon, it shouldn't be considered running, for example. And that's why I want to add that it's on the W button, not just by pulling out the knife. I deleted the Sprint plugin you showed me and would never use it again no matter what, so I set out to make my own better one.
I hope you understand me, because I use google for translations. I'll certainly keep trying to get your code into mine, but whether I'll succeed is rather doubtful.
(1): The sound when you switch weapon is not because you are switching the weapons, it's because the sprint works only when Player has knife in hand, so if player changes to any other weapon when last weapon was knife so it will execute the sprint end sound.
(2): The message is not at the beginning of the map, It shows every 20 seconds as you set in the cvar.
(3): I edited your plugin and made it to show message when player has joined to the server.
(4): there was not even need to put Fourth jump or some other to count the sprints, I've added the limit, You can change sprint limits by changing cvar "sprint_limit"

PHP Code:
#include <amxmodx>
#include <fun>
#include <hamsandwich>

#define PLUGIN_VERSION "1.0.1"
new g_pSpeed
new g_pSprintDuration
new delaymsgtime
//limit
new g_Limit[33]; // used to count limits
new g_pSprintLimit// used to check limits

// Add a new sound constant for the sprint end sound
#define SPRINT_END_SOUND "sound/breathe2.wav"

public plugin_init()
{
    
register_plugin("Fast Knife"PLUGIN_VERSION"OciXCrom")
    
register_cvar("CRXFastKnife"PLUGIN_VERSIONFCVAR_SERVER FCVAR_SPONLY FCVAR_UNLOGGED)
    
register_event("CurWeapon""OnSelectKnife""be""1=1""2=29")
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
    
    
g_pSpeed register_cvar("fastknife_speed""150.0");
    
g_pSprintDuration register_cvar("sprint_duration""2.0");
    
g_pSprintLimit register_cvar("sprint_limit""3");
        
delaymsgtime register_cvar("cmessage_delay""10.0");
}

public 
client_putinserver(id)
{
        
set_task(get_pcvar_float(delaymsgtime), "ShowSprintMessage"id)
}
public 
fwHamPlayerSpawnPost(id)
{
    
g_Limit[id] = 0;
}

public 
OnSelectKnife(id)
{
    if (
is_user_alive(id))
    {
        if (
g_Limit[id] >= get_pcvar_num(g_pSprintLimit)) // checking if player has reached maximum sprint numbers (which is in cvar sprint_limit)
        
{
            return 
PLUGIN_HANDLED// means the player has reached maximum limit of sprints!
        
}
        else
        {
            
set_user_maxspeed(idget_user_maxspeed(id) + get_pcvar_float(g_pSpeed));
            
set_task(get_pcvar_float(g_pSprintDuration), "EndFastKnife"id);
            
g_Limit[id]++; // counting +1 for player limit
        
}
    }
    return 
PLUGIN_HANDLED;
}

public 
EndFastKnife(id)
{
    if (
is_user_alive(id))
    {
        
set_user_maxspeed(id250.0);
        
// Play the sprint end sound
        
client_cmd(id"spk %s"SPRINT_END_SOUND);
    }
}

public 
ShowSprintMessage(id)
{
    
client_print(idprint_chat"You can sprint with a knife in hand for %d seconds!"get_pcvar_num(g_pSprintDuration))
}

public 
plugin_precache()
{
    
// Precache the sprint end sound
    
precache_sound(SPRINT_END_SOUND);


Last edited by Tote; 08-24-2023 at 11:44.
Tote is offline
 



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 00:58.


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