Quote:
Originally Posted by Siska1
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_VERSION, FCVAR_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(id, get_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(id, 250.0);
// Play the sprint end sound
client_cmd(id, "spk %s", SPRINT_END_SOUND);
}
}
public ShowSprintMessage(id)
{
client_print(id, print_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);
}