AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   vip speed (https://forums.alliedmods.net/showthread.php?t=314295)

Mikaeel123 02-12-2019 13:57

vip speed
 
Hi all . i want a plugin for vip speed . i want duble W = 3 sec speed for vips
who have this ?

Moody92 02-13-2019 14:59

Re: vip speed
 
Double speed for 3 seconds only? And when does it trigger/start?

Or do you want 3x speed at all times controlled by a cvar?

Mikaeel123 02-14-2019 04:37

Re: vip speed
 
i want speed in use double W for 3 sec

OciXCrom 02-14-2019 07:41

Re: vip speed
 
Translation: he wants to have speed for 3 seconds when he double-taps the W button.

Moody92 02-14-2019 08:01

Re: vip speed
 
Something like this already exists
Sprint - Run Faster

Mikaeel123 02-14-2019 11:52

Re: vip speed
 
what flag ??

Mikaeel123 02-14-2019 12:28

Re: vip speed
 
this is for all players
i test code but no work
PHP Code:

 /* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

#define ADMIN_IMMUNITY
#define PLUGIN "Sprint"
#define VERSION "1.2"
#define AUTHOR "akcaliberg"

#define TASKID 58964

#define MAX_PLAYERS 32

new bool:IsUserSprinting[MAX_PLAYERS+1];
new 
bool:UserCanSprint[MAX_PLAYERS+1];
new 
gMsgScreenFade;

new 
Float:LastSprintUsed[MAX_PLAYERS+1];
new 
Float:LastKeyPressed[MAX_PLAYERS+1];
new 
Float:LastSprintReleased[MAX_PLAYERS+1];
new 
Float:SprintTime[MAX_PLAYERS+1];
new 
Float:gCooldownFloat:gSprinttimeFloat:gSprintspeed,
Float:gKeyPressInterval,gShowUsage,gBreathinggBlockJumpgScreenFade[9];

new const 
EXHAUSTED_BREATH[] = "player/exhausted_breathing.wav";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_cvar("sprint_cooldown","5");
    
register_cvar("sprint_timemax","2.5");
    
register_cvar("sprint_speed","400.0");
    
register_cvar("sprint_keylisten_interval","0.2");
    
register_cvar("sprint_blockjump","0");
    
register_cvar("sprint_breathsound","2");
    
register_cvar("sprint_screenfade_enabled","1");
    
register_cvar("sprint_screenfade_rgba","0 20 200 50");
    
register_cvar("sprint_screenfade_rgba2","255 0 0 50");
    
register_cvar("sprint_showusage","1");
    
    
register_event("HLTV","eNewRound","a","1=0","2=0");
    
register_event("TeamInfo""eTeamInfo""a");
    
    
register_forward(FM_PlayerPreThink"fwd_PlayerPreThink");
    
    
RegisterHam(Ham_Spawn,"player","fwd_PlayerSpawnPost",1);
    
    
gMsgScreenFade get_user_msgid("ScreenFade");
    
    
register_concmd("sprint_reloadcvars""CacheCvars"ADMIN_CVAR);
    
    if(
gShowUsageset_task(300.0,"ShowUsage",TASKID, .flags="b");
    
}
public 
plugin_precache() {
    
precache_sound(EXHAUSTED_BREATH)
}
public 
plugin_cfg() {
    
CacheCvars(0,0,0// function will ignore the level check if the id equals 0
}
public 
eNewRound() {
    
CacheCvars(0,0,0)
}
public 
eTeamInfo() {
    new 
id read_data(1);
    
    new 
szTeam[12];
    
read_data(2szTeamcharsmax(szTeam));
    
    
UserCanSprint[id] = (szTeam[0] == 'S' || szTeam[0] == 'U') ? false true;
}
public 
CacheCvars(idlevelcid) {
    
    if(
id != && !cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
    gCooldown 
get_cvar_float("sprint_cooldown");
    
gSprinttime get_cvar_float("sprint_timemax");
    
gSprintspeed get_cvar_float("sprint_speed");
    
gKeyPressInterval get_cvar_float("sprint_keylisten_interval");
    
gShowUsage get_cvar_num("sprint_showusage");
    
gBreathing get_cvar_num("sprint_breathsound");
    
gBlockJump get_cvar_num("sprint_blockjump");
    
gScreenFade[0] = get_cvar_num("sprint_screenfade_enabled");
    
    new 
szRGBA[16], szR[4], szG[4], szB[4], szA[4];
    
get_cvar_string("sprint_screenfade_rgba",szRGBA,15);
    
parse(szRGBAszR3szG3szB3szA3);
    
    
gScreenFade[1] = str_to_num(szR);
    
gScreenFade[2] = str_to_num(szG);
    
gScreenFade[3] = str_to_num(szB);
    
gScreenFade[4] = str_to_num(szA);
    
    
get_cvar_string("sprint_screenfade_rgba2",szRGBA,15);
    
parse(szRGBAszR3szG3szB3szA3);
    
    
gScreenFade[5] = str_to_num(szR);
    
gScreenFade[6] = str_to_num(szG);
    
gScreenFade[7] = str_to_num(szB);
    
gScreenFade[8] = str_to_num(szA);
    
    return 
PLUGIN_HANDLED
}
public 
client_putinserver(id) {
    if(
gShowUsageset_task(10.0,"ShowUsage",id+TASKID)
}
public 
fwd_PlayerSpawnPost(id) {
    
SprintTime[id] = 0.0;
}
public 
fwd_PlayerPreThink(id) {
    if(!
UserCanSprint[id]) return;
    
    static 
button,oldbuttons,flagsFloat:speed;
    
    
button pev(idpev_button);
    
oldbuttons pev(idpev_oldbuttons); 
    
pev(idpev_maxspeedspeed);
    
flags pev(idpev_flags);
    
    
    if(!(
flags FL_DUCKING) && speed != 1.0) {
        
        
// Pressed
        
if(button IN_FORWARD && !(oldbuttons IN_FORWARD)) {
            if( (
get_gametime() - LastKeyPressed[id]) < gKeyPressInterval ) {
                if( (
get_gametime() - LastSprintReleased[id]) >= gCooldown)  {
                    
LastSprintUsed[id] = get_gametime();
                    
IsUserSprinting[id] = true;
                    
SprintTime[id] = 0.0
                    
if(gScreenFade[0]) SetScreenFadeEffect(id1)
                }
                else if( 
SprintTime[id] > 0.0 && SprintTime[id] < gSprinttime ) {
                    
LastSprintUsed[id] = get_gametime();
                    
IsUserSprinting[id] = true;
                    if(
gScreenFade[0]) SetScreenFadeEffect(id1)
                }
                
            }
            
LastKeyPressed[id] = get_gametime();
        }
        
// Holding
        
else if( oldbuttons IN_FORWARD && button IN_FORWARD ) {
            if(
IsUserSprinting[id]) {
                if(
speed != gSprintspeedset_pev(idpev_maxspeedgSprintspeed );
                if( ( 
SprintTime[id] + get_gametime() - LastSprintUsed[id] ) > gSprinttime) {
                    
IsUserSprinting[id] = false;
                    
ExecuteHamB(Ham_Item_PreFrameid);
                    
LastSprintReleased[id] = get_gametime();
                    
SprintTime[id] = 0.0;
                    if(
gScreenFade[0]) SetScreenFadeEffect(id2)
                    
                    
// Exhausted breath sound
                    
switch(gBreathing) {
                        case 
1client_cmd(id"spk %s",EXHAUSTED_BREATH);
                        case 
2emit_sound(idCHAN_AUTOEXHAUSTED_BREATHVOL_NORMATTN_NORM0PITCH_NORM); 
                    }
                    
                }
            }
        }
        
// Released
        
else if( oldbuttons IN_FORWARD && !(button IN_FORWARD)) {
            if(
IsUserSprinting[id]) {
                
LastSprintReleased[id] = get_gametime();
                
IsUserSprinting[id] = false;
                
SprintTime[id] += ( get_gametime() - LastSprintUsed[id]);
                
ExecuteHamB(Ham_Item_PreFrameid);
                if(
gScreenFade[0]) SetScreenFadeEffect(id0)
            }
        }
        
// Ducking
        
if(IsUserSprinting[id] && button IN_DUCK) {
            
LastSprintReleased[id] = get_gametime();
            
IsUserSprinting[id] = false;
            
SprintTime[id] += ( get_gametime() - LastSprintUsed[id]);
            
ExecuteHamB(Ham_Item_PreFrameid);
            if(
gScreenFade[0]) SetScreenFadeEffect(id0)
        }
        
// Jumping
        
if(gBlockJump && IsUserSprinting[id] && button IN_JUMP) {
            
LastSprintReleased[id] = get_gametime();
            
IsUserSprinting[id] = false;
            
SprintTime[id] += ( get_gametime() - LastSprintUsed[id]);
            
ExecuteHamB(Ham_Item_PreFrameid);
            if(
gScreenFade[0]) SetScreenFadeEffect(id0)
        }
    }
}
public 
SetScreenFadeEffect(idflag) {
    
    switch(
flag) {
        case 
0: {
            
message_begin(MSG_ONE_UNRELIABLEgMsgScreenFade_id)
            
write_short(0)
            
write_short(0)
            
write_short(0)
            
write_byte(0)
            
write_byte(0)
            
write_byte(0)
            
write_byte(0)
            
message_end()
        }
        case 
1: {
            
message_begin(MSG_ONE_UNRELIABLEgMsgScreenFade_id)
            
write_short(0// duration (will be ignored because of the flag)
            
write_short(0// holdtime
            
write_short(0x0004// FFADE_STAYOUT
            
write_byte(gScreenFade[1]) // r
            
write_byte(gScreenFade[2]) // g
            
write_byte(gScreenFade[3]) // b
            
write_byte(gScreenFade[4]) // alpha
            
message_end()
        }
        case 
2: {
            
message_begin(MSG_ONE_UNRELIABLEgMsgScreenFade_id)
            
write_short(4096// duration
            
write_short(2048// holdtime
            
write_short(0x0000// FFADE_IN
            
write_byte(gScreenFade[5]) // r
            
write_byte(gScreenFade[6]) // g
            
write_byte(gScreenFade[7]) // b
            
write_byte(gScreenFade[8]) // alpha
            
message_end()
        }
    }
}
public 
ShowUsage(id) {
    
id -= TASKID
    client_print
(id,print_chat,"[SPRINT] You can sprint in this server by double-tapping forward (W) key. ");



Moody92 02-14-2019 15:32

Re: vip speed
 
1 Attachment(s)
Quote:

Originally Posted by Mikaeel123 (Post 2639615)
this is for all players
i test code but no work

I have no idea what you modified in the plugin, but here.

Mikaeel123 02-15-2019 02:37

Re: vip speed
 
Its for flag b ??

PartialCloning 02-15-2019 02:54

Re: vip speed
 
No, he used the immunity flag. But calling get_user_flags in a prethink forward isn't a good practice. Use this, edit "#define SPRINT_FLAG ADMIN_RESERVATION" to change the flag. ADMIN_RESERVATION is flag b.

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <hamsandwich>

#define SPRINT_FLAG ADMIN_RESERVATION

#define PLUGIN "Sprint"
#define VERSION "1.2"
#define AUTHOR "akcaliberg"

#define TASKID 58964

#define MAX_PLAYERS 32

new bool:IsUserSprinting[MAX_PLAYERS+1];
new 
bool:UserCanSprint[MAX_PLAYERS+1];
new 
gMsgScreenFade;

new 
Float:LastSprintUsed[MAX_PLAYERS+1];
new 
Float:LastKeyPressed[MAX_PLAYERS+1];
new 
Float:LastSprintReleased[MAX_PLAYERS+1];
new 
Float:SprintTime[MAX_PLAYERS+1];
new 
Float:gCooldownFloat:gSprinttimeFloat:gSprintspeed,
Float:gKeyPressInterval,gShowUsage,gBreathinggBlockJumpgScreenFade[9];

new const 
EXHAUSTED_BREATH[] = "player/exhausted_breathing.wav";

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_cvar("sprint_cooldown","5");
    
register_cvar("sprint_timemax","2.5");
    
register_cvar("sprint_speed","400.0");
    
register_cvar("sprint_keylisten_interval","0.2");
    
register_cvar("sprint_blockjump","0");
    
register_cvar("sprint_breathsound","2");
    
register_cvar("sprint_screenfade_enabled","1");
    
register_cvar("sprint_screenfade_rgba","0 20 200 50");
    
register_cvar("sprint_screenfade_rgba2","255 0 0 50");
    
register_cvar("sprint_showusage","1");
    
    
register_event("HLTV","eNewRound","a","1=0","2=0");
    
register_event("TeamInfo""eTeamInfo""a");
    
    
register_forward(FM_PlayerPreThink"fwd_PlayerPreThink");
    
    
RegisterHam(Ham_Spawn,"player","fwd_PlayerSpawnPost",1);
    
    
gMsgScreenFade get_user_msgid("ScreenFade");
    
    
register_concmd("sprint_reloadcvars""CacheCvars"ADMIN_CVAR);
    
    if(
gShowUsageset_task(300.0,"ShowUsage",TASKID, .flags="b");
    
}
public 
plugin_precache() {
    
precache_sound(EXHAUSTED_BREATH)
}
public 
plugin_cfg() {
    
CacheCvars(0,0,0// function will ignore the level check if the id equals 0
}
public 
eNewRound() {
    
CacheCvars(0,0,0)
}
public 
eTeamInfo() {
    new 
id read_data(1);
    
    new 
szTeam[12];
    
read_data(2szTeamcharsmax(szTeam));
    
    
UserCanSprint[id] = (get_user_flags(id) & SPRINT_FLAG && (szTeam[0] == 'C' || szTeam[0] == 'T')) ? true false;
}
public 
CacheCvars(idlevelcid) {
    
    if(
id != && !cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
    gCooldown 
get_cvar_float("sprint_cooldown");
    
gSprinttime get_cvar_float("sprint_timemax");
    
gSprintspeed get_cvar_float("sprint_speed");
    
gKeyPressInterval get_cvar_float("sprint_keylisten_interval");
    
gShowUsage get_cvar_num("sprint_showusage");
    
gBreathing get_cvar_num("sprint_breathsound");
    
gBlockJump get_cvar_num("sprint_blockjump");
    
gScreenFade[0] = get_cvar_num("sprint_screenfade_enabled");
    
    new 
szRGBA[16], szR[4], szG[4], szB[4], szA[4];
    
get_cvar_string("sprint_screenfade_rgba",szRGBA,15);
    
parse(szRGBAszR3szG3szB3szA3);
    
    
gScreenFade[1] = str_to_num(szR);
    
gScreenFade[2] = str_to_num(szG);
    
gScreenFade[3] = str_to_num(szB);
    
gScreenFade[4] = str_to_num(szA);
    
    
get_cvar_string("sprint_screenfade_rgba2",szRGBA,15);
    
parse(szRGBAszR3szG3szB3szA3);
    
    
gScreenFade[5] = str_to_num(szR);
    
gScreenFade[6] = str_to_num(szG);
    
gScreenFade[7] = str_to_num(szB);
    
gScreenFade[8] = str_to_num(szA);
    
    return 
PLUGIN_HANDLED
}
public 
client_putinserver(id) {
    if(
gShowUsageset_task(10.0,"ShowUsage",id+TASKID)
}
public 
fwd_PlayerSpawnPost(id) {
    
SprintTime[id] = 0.0;
}
public 
fwd_PlayerPreThink(id) {
    if(!
UserCanSprint[id]) return;
    
    static 
button,oldbuttons,flagsFloat:speed;
    
    
button pev(idpev_button);
    
oldbuttons pev(idpev_oldbuttons); 
    
pev(idpev_maxspeedspeed);
    
flags pev(idpev_flags);
    
    
    if(!(
flags FL_DUCKING) && speed != 1.0) {
        
        
// Pressed
        
if(button IN_FORWARD && !(oldbuttons IN_FORWARD)) {
            if( (
get_gametime() - LastKeyPressed[id]) < gKeyPressInterval ) {
                if( (
get_gametime() - LastSprintReleased[id]) >= gCooldown)  {
                    
LastSprintUsed[id] = get_gametime();
                    
IsUserSprinting[id] = true;
                    
SprintTime[id] = 0.0
                    
if(gScreenFade[0]) SetScreenFadeEffect(id1)
                }
                else if( 
SprintTime[id] > 0.0 && SprintTime[id] < gSprinttime ) {
                    
LastSprintUsed[id] = get_gametime();
                    
IsUserSprinting[id] = true;
                    if(
gScreenFade[0]) SetScreenFadeEffect(id1)
                }
                
            }
            
LastKeyPressed[id] = get_gametime();
        }
        
// Holding
        
else if( oldbuttons IN_FORWARD && button IN_FORWARD ) {
            if(
IsUserSprinting[id]) {
                if(
speed != gSprintspeedset_pev(idpev_maxspeedgSprintspeed );
                if( ( 
SprintTime[id] + get_gametime() - LastSprintUsed[id] ) > gSprinttime) {
                    
IsUserSprinting[id] = false;
                    
ExecuteHamB(Ham_Item_PreFrameid);
                    
LastSprintReleased[id] = get_gametime();
                    
SprintTime[id] = 0.0;
                    if(
gScreenFade[0]) SetScreenFadeEffect(id2)
                    
                    
// Exhausted breath sound
                    
switch(gBreathing) {
                        case 
1client_cmd(id"spk %s",EXHAUSTED_BREATH);
                        case 
2emit_sound(idCHAN_AUTOEXHAUSTED_BREATHVOL_NORMATTN_NORM0PITCH_NORM); 
                    }
                    
                }
            }
        }
        
// Released
        
else if( oldbuttons IN_FORWARD && !(button IN_FORWARD)) {
            if(
IsUserSprinting[id]) {
                
LastSprintReleased[id] = get_gametime();
                
IsUserSprinting[id] = false;
                
SprintTime[id] += ( get_gametime() - LastSprintUsed[id]);
                
ExecuteHamB(Ham_Item_PreFrameid);
                if(
gScreenFade[0]) SetScreenFadeEffect(id0)
            }
        }
        
// Ducking
        
if(IsUserSprinting[id] && button IN_DUCK) {
            
LastSprintReleased[id] = get_gametime();
            
IsUserSprinting[id] = false;
            
SprintTime[id] += ( get_gametime() - LastSprintUsed[id]);
            
ExecuteHamB(Ham_Item_PreFrameid);
            if(
gScreenFade[0]) SetScreenFadeEffect(id0)
        }
        
// Jumping
        
if(gBlockJump && IsUserSprinting[id] && button IN_JUMP) {
            
LastSprintReleased[id] = get_gametime();
            
IsUserSprinting[id] = false;
            
SprintTime[id] += ( get_gametime() - LastSprintUsed[id]);
            
ExecuteHamB(Ham_Item_PreFrameid);
            if(
gScreenFade[0]) SetScreenFadeEffect(id0)
        }
    }
}
public 
SetScreenFadeEffect(idflag) {
    
    switch(
flag) {
        case 
0: {
            
message_begin(MSG_ONE_UNRELIABLEgMsgScreenFade_id)
            
write_short(0)
            
write_short(0)
            
write_short(0)
            
write_byte(0)
            
write_byte(0)
            
write_byte(0)
            
write_byte(0)
            
message_end()
        }
        case 
1: {
            
message_begin(MSG_ONE_UNRELIABLEgMsgScreenFade_id)
            
write_short(0// duration (will be ignored because of the flag)
            
write_short(0// holdtime
            
write_short(0x0004// FFADE_STAYOUT
            
write_byte(gScreenFade[1]) // r
            
write_byte(gScreenFade[2]) // g
            
write_byte(gScreenFade[3]) // b
            
write_byte(gScreenFade[4]) // alpha
            
message_end()
        }
        case 
2: {
            
message_begin(MSG_ONE_UNRELIABLEgMsgScreenFade_id)
            
write_short(4096// duration
            
write_short(2048// holdtime
            
write_short(0x0000// FFADE_IN
            
write_byte(gScreenFade[5]) // r
            
write_byte(gScreenFade[6]) // g
            
write_byte(gScreenFade[7]) // b
            
write_byte(gScreenFade[8]) // alpha
            
message_end()
        }
    }
}
public 
ShowUsage()
{
    
client_print(0print_chat"[SPRINT] You can sprint in this server by double-tapping forward (W) key.");




All times are GMT -4. The time now is 07:23.

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