BANNED
Join Date: Dec 2012
Location: Stockholm
|
06-01-2013
, 20:34
Re: SPRINT a like
|
#5
|
Quote:
Originally Posted by myusername
Hello, i need plugin that makes if player press "shift" key then player will run fast like a sprint. But there is no limit. Only if you running fast then you cant attack.
Thank you.
|
Check this bro.
PHP Code:
#include <amxmodx>
#include <fakemeta>
#define VERSION "0.1"
#define LEET 1337
//#define DEBUG 1
const g_iProg = (0xFF);
const g_iWeaps = (0x1E);
const g_iMaxSpeed = (0x2EE);
const g_iMaxCzas = (0xA);
new g_iMaxPlayers;
new Float:g_fTempMaxSpeed[0x21];
new Float:g_fSprintLeft[0x21];
new const Float:g_fWeaponsSpeed[g_iWeaps + 1]={
000.0,
250.0, 000.0, 260.0, 250.0, 240.0,
250.0, 250.0, 240.0, 250.0, 250.0,
250.0, 250.0, 210.0, 240.0, 240.0,
250.0, 250.0, 210.0, 250.0, 220.0,
230.0, 230.0, 250.0, 210.0, 250.0,
250.0, 235.0, 221.0, 250.0, 245.0
};
public plugin_init() {
register_plugin("Sprint", VERSION, "nevermore")
g_iMaxPlayers = get_maxplayers();
register_forward(FM_CmdStart, "fwCmdStart", 0);
register_event("CurWeapon", "eventCurWeapon", "be", "1=1");
set_task(0.4, "taskPrintAmmount", _, _, _, "b");
}
public plugin_cfg() set_cvar_num("sv_maxspeed", g_iMaxSpeed);
public eventCurWeapon(id){
if(g_fTempMaxSpeed[id] >= float(g_iProg)){
set_pev(id, pev_maxspeed, g_fTempMaxSpeed[id]);
client_cmd(id, "cl_forwardspeed ^"%d^"", floatround(g_fTempMaxSpeed[id]));
#if defined DEBUG
client_print(id, 3, "%.1f", g_fTempMaxSpeed[id]);
#endif
}
else{
set_pev(id, pev_maxspeed, g_fWeaponsSpeed[get_user_weapon(id)]);
#if defined DEBUG
client_print(id, 3, "%.1f", g_fWeaponsSpeed[get_user_weapon(id)]);
#endif
}
}
public fwCmdStart(id, iHandle, iSeed){
if(!is_user_alive(id)) return FMRES_IGNORED;
new Float:fmove, Float:smove;
get_uc(iHandle, UC_ForwardMove, fmove);
get_uc(iHandle, UC_SideMove, smove);
new Float:maxspeed;
pev(id, pev_maxspeed, maxspeed);
new Float:walkspeed = (maxspeed * 0.52);
fmove = floatabs(fmove);
smove = floatabs(smove);
if(fmove <= walkspeed && smove <= walkspeed && !(fmove == 0.0 && smove == 0.0)){
if(g_fSprintLeft[id] >= 0.5){
if(task_exists(id + LEET)) remove_task(id + LEET);
g_fTempMaxSpeed[id] = g_fTempMaxSpeed[id] < 400.0 ? 400.0 : g_fTempMaxSpeed[id];
g_fTempMaxSpeed[id] = g_fTempMaxSpeed[id] < float(g_iMaxSpeed) ? g_fTempMaxSpeed[id] + 10.0 : g_fTempMaxSpeed[id];
set_pev(id, pev_maxspeed, g_fTempMaxSpeed[id]);
client_cmd(id, "cl_forwardspeed ^"%d^"", floatround(g_fTempMaxSpeed[id]));
engclient_cmd(id, "weapon_knife");
g_fSprintLeft[id] -= 0.05;
for(new i = 0 ; i < 0x10 ; i++){
new bitButtons = get_uc(iHandle, UC_Buttons);
new bitOldbuttons = pev(id, pev_oldbuttons);
if(!(((1<<3)|(1<<4)|(1<<12)) & (1<<i))){
if((bitButtons & (1<<i))){
if((1<<2) & (1<<i))
set_pev(id, pev_oldbuttons, bitOldbuttons | (1<<i));
else
set_uc(iHandle, UC_Buttons, bitButtons & (~(1<<i)));
return FMRES_SUPERCEDE;
}
}
}
}
else{
g_fTempMaxSpeed[id] = 0.0;
eventCurWeapon(id);
client_print(id, print_center, "Tired!");
}
return FMRES_IGNORED;
}
else{
if(!task_exists(id + LEET)) set_task(1.0, "taskRecoverSprint", id + LEET);
g_fTempMaxSpeed[id] = 0.0;
eventCurWeapon(id);
}
return FMRES_IGNORED;
}
public taskRecoverSprint(task_id){
new id = task_id - LEET;
g_fSprintLeft[id]++;
if(floatround(g_fSprintLeft[id]) < g_iMaxCzas || floatround(g_fSprintLeft[id]) > g_iMaxCzas){
if(floatround(g_fSprintLeft[id]) < g_iMaxCzas) set_task(1.0, "taskRecoverSprint", id + LEET);
if(floatround(g_fSprintLeft[id]) > g_iMaxCzas) g_fSprintLeft[id] = float(g_iMaxCzas);
}
}
public taskPrintAmmount(){
static id; //statyczna
for(id = 1 ; id <= g_iMaxPlayers ; id++){
if(is_user_alive(id)){
new iSprint = floatround(g_fSprintLeft[id]);
new sSprint[g_iMaxCzas];
while(iSprint >= 1){
iSprint--;
add(sSprint, sizeof sSprint - 1, "*");
}
iSprint = floatround(g_fSprintLeft[id]);
set_hudmessage(iSprint ? 0x64 : 0xFF, iSprint ? 0x48 : 0x0, iSprint ? 0xC : 0x0, 0.01, 0.77, 0, 0.000001, 0.405, 0.000001, 0.000001, -1);
show_hudmessage(id, "SPRINT : [%s]", sSprint);
}
}
}
or
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#define PLUGIN "Sprint"
#define VERSION "0.2"
#define AUTHOR "nevermore"
new const Float:g_fWeaponsSpeed[ ]={
000.0,
250.0, 000.0, 260.0, 250.0, 240.0,
250.0, 250.0, 240.0, 250.0, 250.0,
250.0, 250.0, 210.0, 240.0, 240.0,
250.0, 250.0, 210.0, 250.0, 220.0,
230.0, 230.0, 250.0, 210.0, 250.0,
250.0, 235.0, 221.0, 250.0, 245.0
};
new Float:gfPitch[33];
new Float:gfYaw[33];
new Float:gfMoveOffset[33][2];
new giMoves[33];
new bool:gFast[33];
new gZmeczenie[33];
new pSpeed,pZmeczenie;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
pSpeed = register_cvar("sprint_speed","60.0")
pZmeczenie = register_cvar("sprint_tired","5");
register_forward(FM_PlayerPreThink, "fwPreThink");
register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
RegisterHam(Ham_Spawn,"player","spawned",1)
register_event("CurWeapon","CurWeapon","be", "1=1");
register_clcmd("+fast_run","startMove")
register_clcmd("-fast_run","stopMove")
}
public client_connect(id)
client_cmd(id,"bind shift +fast_run");
public startMove(id){
if(!gFast[id] && is_user_alive(id) && cs_get_user_zoom(id) == CS_SET_NO_ZOOM){
gfPitch[id] = gfYaw[id] = 0.0;
moveTo(id, 0.0, 20.0);
gFast[id] = true;
engfunc(EngFunc_SetClientMaxspeed, id, g_fWeaponsSpeed[get_user_weapon(id)]+get_pcvar_float(pSpeed));
remove_task(id)
set_task(0.1,"addZmeczenie",id,_,_,"b")
}
return PLUGIN_HANDLED
}
public stopMove(id){
if(gFast[id] && is_user_alive(id)){
moveTo(id, 0.0, 0.0);
gFast[id] = false;
engfunc(EngFunc_SetClientMaxspeed, id, g_fWeaponsSpeed[get_user_weapon(id)]);
remove_task(id)
set_task(0.2,"odejZmecznie",id,_,_,"b")
}
return PLUGIN_HANDLED
}
moveTo(id, Float:fPitch, Float:fYaw, moves=30){
gfMoveOffset[id][0] = (fPitch - gfPitch[id])/moves;
gfMoveOffset[id][1] = (fYaw - gfYaw[id])/moves;
giMoves[id] = moves;
}
public fwPreThink(id){
if(!is_user_alive(id)) return;
if(gFast[id]){
set_pev(id, pev_button, pev(id,pev_button) & ~IN_ATTACK)
set_pev(id, pev_button, pev(id,pev_button) & ~IN_ATTACK2)
if(gZmeczenie[id] >= get_pcvar_num(pZmeczenie)*10){
stopMove(id);
}
}
if(giMoves[id] > 0){
giMoves[id]--;
gfPitch[id] += gfMoveOffset[id][0];
gfYaw[id] += gfMoveOffset[id][1];
engfunc(EngFunc_CrosshairAngle, id, gfPitch[id], gfYaw[id]);
}
}
public spawned(id){
if(is_user_alive(id)){
gZmeczenie[id] = 0;
}
}
public addZmeczenie(id){
gZmeczenie[id]++;
}
public odejZmecznie(id){
if(gZmeczenie[id] > 0){
gZmeczenie[id]--;
}
}
public UpdateClientData_Post(id, sendweapons, cd_handle)
{
if(!is_user_alive(id)){
return FMRES_IGNORED
}
if(gFast[id]){
set_cd(cd_handle, CD_ID, 0)
return FMRES_HANDLED
}
return FMRES_IGNORED
}
public CurWeapon(id)
{
if(!is_user_alive(id)){
return PLUGIN_CONTINUE;
}
static iOldWeap[33];
new weapon = read_data(2);
if(gFast[id] && iOldWeap[id] != weapon){
new szName[64];
get_weaponname(iOldWeap[id],szName,charsmax(szName));
engclient_cmd(id,szName);
engfunc(EngFunc_SetClientMaxspeed, id, g_fWeaponsSpeed[get_user_weapon(id)]+get_pcvar_float(pSpeed));
return PLUGIN_CONTINUE;
}
iOldWeap[id] = weapon;
return PLUGIN_CONTINUE;
}
client_cmd(id,"bind shift +fast_run");
Last edited by Don_Collione; 06-01-2013 at 20:55.
Reason: lang
|
|