Този плъгин ни позволява да бягаме с нож в ръка :
Cvars -
- Код за потвърждение: Избери целия код
fastknife_speed "150.0" - Това е бързината на бягането + тази по подразбиране 250
(значи в случая имаме 400)
sprint_duration "2.0" - Колко време да продължи бягането
sprint_coundown "10.0" - След колко време може да се бяга отново
max_sprints "3" - На колко спринта имаме право за едно прераждане
- Код за потвърждение: Избери целия код
#include <amxmodx>
#include <fun>
#include <engine>
#include <hamsandwich>
#include <cromchat>
#define PLUGIN_VERSION "1.0.1"
#define SPRINT_END_SOUND "misc/breathe2.wav"
#define SPRINT_MESSAGE_INTERVAL 300.0
#define FAST_KNIFE_DELAY 20.0
#define SPRINT_MESSAGE_FORMAT "&x03%s&x01, you can &x04sprint &x01with a knife in hand &x04%d &x01times for &x04%0.1f &x01seconds. Next &x04sprint &x01every &x04%.1f &x01seconds."
new g_pSpeed[3];
new g_Limit[33];
new g_sprint[33];
new g_LastSprint[33];
new Float:g_LastJoinTime[33];
new Float:g_LastMessageTime[33];
new g_MaxSprints;
new g_ReachedMaxSprint[33];
public plugin_init()
{
register_plugin("Fast Knife", PLUGIN_VERSION, "OciXCrom, tes-onez crew");
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[0] = register_cvar("fastknife_speed", "150.0");
g_pSpeed[1] = register_cvar("sprint_duration", "2.0");
g_pSpeed[2] = register_cvar("sprint_coundown", "10.0");
g_MaxSprints = register_cvar("max_sprints", "3");
}
public plugin_precache()
{
// Precache the sprint end sound
precache_sound(SPRINT_END_SOUND);
}
public fwHamPlayerSpawnPost(id)
{
g_Limit[id] = 0;
g_LastSprint[id] = false;
g_sprint[id] = true;
g_LastJoinTime[id] = get_gametime();
g_ReachedMaxSprint[id] = false;
set_task(FAST_KNIFE_DELAY, "ShowSprintMessage", id);
}
public OnSelectKnife(id)
{
if (is_user_alive(id) && get_user_button(id) && IN_FORWARD && get_user_oldbutton(id) && IN_FORWARD)
{
if(g_sprint[id])
{
if(g_Limit[id] >= get_pcvar_num(g_MaxSprints))
{
if (!g_ReachedMaxSprint[id])
{
new szName[33];
get_user_name(id, szName, charsmax(szName));
CC_SendMatched(id, CC_COLOR_TEAM, "&x03%s&x01, you've reached the maximum &x04sprint &x01limit. Again on next spawn !!!", szName);
g_ReachedMaxSprint[id] = true;
}
return PLUGIN_HANDLED;
}
g_sprint[id] = false;
set_user_maxspeed(id, get_user_maxspeed(id) + get_pcvar_float(g_pSpeed[0]));
set_task(get_pcvar_float(g_pSpeed[1]), "EndFastKnife", id);
g_Limit[id]++;
}
}
return PLUGIN_HANDLED;
}
public RefreshFastKnife(id)
{
if(is_user_connected(id) && !g_sprint[id])
{
g_sprint[id] = true;
}
}
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);
set_task(get_pcvar_float(g_pSpeed[2]), "RefreshFastKnife", id);
}
}
public ShowSprintMessage(id) {
if (!g_LastMessageTime[id] || get_gametime() - g_LastMessageTime[id] >= SPRINT_MESSAGE_INTERVAL) {
new playerName[32];
get_user_name(id, playerName, sizeof(playerName));
CC_SendMatched(id, CC_COLOR_TEAM, SPRINT_MESSAGE_FORMAT, playerName, get_pcvar_num(g_MaxSprints), get_pcvar_float(g_pSpeed[1]), get_pcvar_float(g_pSpeed[2]));
g_LastMessageTime[id] = get_gametime();
}
}
Вариант, който работи само за ВИП играчи :
- Код за потвърждение: Избери целия код
#define VIP_FLAG ADMIN_LEVEL_B
- Код за потвърждение: Избери целия код
#include <amxmodx>
#include <fun>
#include <engine>
#include <hamsandwich>
#include <cromchat>
#define PLUGIN_VERSION "1.0.1"
#define SPRINT_END_SOUND "misc/breathe2.wav"
#define SPRINT_MESSAGE_INTERVAL 300.0
#define FAST_KNIFE_DELAY 20.0
#define SPRINT_MESSAGE_FORMAT "&x03%s&x01, you can &x04sprint &x01with a knife in hand &x04%d &x01times for &x04%0.1f &x01seconds. Next &x04sprint &x01every &x04%.1f &x01seconds."
#define VIP_FLAG ADMIN_LEVEL_B
new g_pSpeed[3];
new g_Limit[33];
new g_sprint[33];
new g_LastSprint[33];
new Float:g_LastJoinTime[33];
new Float:g_LastMessageTime[33];
new g_MaxSprints;
new g_ReachedMaxSprint[33];
public plugin_init()
{
register_plugin("Fast Knife", PLUGIN_VERSION, "OciXCrom, tes-onez crew");
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[0] = register_cvar("fastknife_speed", "150.0");
g_pSpeed[1] = register_cvar("sprint_duration", "2.0");
g_pSpeed[2] = register_cvar("sprint_coundown", "10.0");
g_MaxSprints = register_cvar("max_sprints", "3");
}
public plugin_precache()
{
// Precache the sprint end sound
precache_sound(SPRINT_END_SOUND);
}
public fwHamPlayerSpawnPost(id)
{
g_Limit[id] = 0;
g_LastSprint[id] = false;
g_sprint[id] = true;
g_LastJoinTime[id] = get_gametime();
g_ReachedMaxSprint[id] = false;
set_task(FAST_KNIFE_DELAY, "ShowSprintMessage", id);
}
public OnSelectKnife(id)
{
new flags = get_user_flags(id);
// Check if the player has the VIP flag
if (!(flags & VIP_FLAG))
{
return PLUGIN_HANDLED;
}
if (is_user_alive(id) && get_user_button(id) && IN_FORWARD && get_user_oldbutton(id) && IN_FORWARD)
{
if(g_sprint[id])
{
if(g_Limit[id] >= get_pcvar_num(g_MaxSprints))
{
if (!g_ReachedMaxSprint[id])
{
new playerName[32];
get_user_name(id, playerName, sizeof(playerName));
CC_SendMatched(id, CC_COLOR_TEAM, "&x03%s&x01, you've reached the maximum &x04sprint &x01limit. Again on next spawn !!!", playerName);
g_ReachedMaxSprint[id] = true;
}
return PLUGIN_HANDLED;
}
g_sprint[id] = false;
set_user_maxspeed(id, get_user_maxspeed(id) + get_pcvar_float(g_pSpeed[0]));
set_task(get_pcvar_float(g_pSpeed[1]), "EndFastKnife", id);
g_Limit[id]++;
}
}
return PLUGIN_HANDLED;
}
public RefreshFastKnife(id)
{
if(is_user_connected(id) && !g_sprint[id])
{
g_sprint[id] = true;
}
}
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);
set_task(get_pcvar_float(g_pSpeed[2]), "RefreshFastKnife", id);
}
}
public ShowSprintMessage(id) {
if (!g_LastMessageTime[id] || get_gametime() - g_LastMessageTime[id] >= SPRINT_MESSAGE_INTERVAL) {
new playerName[32];
get_user_name(id, playerName, sizeof(playerName));
CC_SendMatched(id, CC_COLOR_TEAM, SPRINT_MESSAGE_FORMAT, playerName, get_pcvar_num(g_MaxSprints), get_pcvar_float(g_pSpeed[1]), get_pcvar_float(g_pSpeed[2]));
g_LastMessageTime[id] = get_gametime();
}
}