Raised This Month: $ Target: $400
 0% 

help to fix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Storas1337
Senior Member
Join Date: Apr 2009
Location: Lithuania
Old 12-28-2013 , 09:34   help to fix
Reply With Quote #1

Hey everbody, im trying to add
Tired sound after player finishes sprint , no result
and removing fade screen anybody can help?
btw dont know method how to hide weapon model until player uses sprint

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Sprint"
#define VERSION "1.0"
#define AUTHOR "DarkGL"

#define FFADE_STAYOUT 10<<12

new g_msgSayText
new g_maxplayers

new const g_SpeedLowSound[64] = "misc/sprint.wav"
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 gTime[33];

new pSpeed,pTime;
new gMsgScreenFade;

public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	pSpeed = register_cvar("sprint_speed","60.0")
	pTime = register_cvar("sprint_time","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")
	register_clcmd("say /sprint","sprint_menu")
	register_clcmd("say_team /sprint","sprint_menu")
	
	g_msgSayText = get_user_msgid("SayText")
	g_maxplayers = get_maxplayers()
	g_fCvarLowSpeed = register_cvar("sprint_low", "150.0")
	gMsgScreenFade = get_user_msgid("ScreenFade")
	
	public plugin_precache()
	precache_sound(g_SpeedLowSound)
}

public sprint_menu(id){
	new menu = menu_create("b[Sprint Menu] Bind Shift button for Sprint?", "sprint_menu_handler")
	
	menu_additem(menu, "Yes (Bind Sprint)", "1", 0);
	menu_additem(menu, "No (Don't Bind Sprint)", "2", 0);
	menu_additem(menu, "More Information", "3", 0);
	menu_additem(menu, "Reset Shift Button (Default key will be set!)", "4", 0);
		
	menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER);
	menu_display(id, menu, 0);
}

public sprint_menu_handler(id, menu, item){
	if( item == MENU_EXIT )
	{
		menu_destroy(menu);
		
		return PLUGIN_HANDLED;
	}
	
	new data[6], szName[64];
	new access, callback;
	menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
	
	new key = str_to_num(data);
	
	switch(key)
	{
		case 1:
		{
			client_cmd(id,"bind shift +fast_run")
			colored_print(id, "Sprint is Successfully binded on Shift Button!")
		}
		case 2:
		{
			colored_print(id, "Sprint is not binded!")
		}
		case 3:
		{
			colored_print(id, "Sprint gives you ability to run faster")
		}
		case 4:
		{
			client_cmd(id,"bind shift +speed")
			colored_print(id, "Sprint is Successfully unbinded to default!")
		}
	}
	menu_destroy(menu);
	return PLUGIN_HANDLED;
}

public event_Sprint(id){
	if (!(get_user_flags(id)&ADMIN_KICK)) {
		return PLUGIN_CONTINUE
	}
	if(!is_user_alive(id) || is_user_bot(id)) 
		return PLUGIN_CONTINUE;
	
	else if(is_user_alive(id)){
		message_begin(MSG_ONE_UNRELIABLE, gMsgScreenFade, {0,0,0}, id);
		write_short( 1<<10 );
		write_short( 1<<10 );
		write_short( 1<<12 );
		write_byte( 225 );
		write_byte( 255 );
		write_byte( 255 );
		write_byte( 35 );
		message_end();
	}
	return PLUGIN_CONTINUE;
}

public stop_Sprint(id){
	message_begin(MSG_ONE_UNRELIABLE, gMsgScreenFade, {0,0,0}, id);
	write_short( 1<<10 );
	write_short( 1<<10 );
	write_short( 1<<12 );
	write_byte( 225 );
	write_byte( 255 );
	write_byte( 255 );
	write_byte( 35 );
	message_end();
}

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;
		stop_Sprint(id)
		engfunc(EngFunc_SetClientMaxspeed, id, g_fWeaponsSpeed[get_user_weapon(id)]);
		remove_task(id)
		set_task(0.2,"odejZmecznie",id,_,_,"b")
		emit_sound(Client, CHAN_VOICE, g_SpeedLowSound, 1.0, ATTN_NORM, 0, PITCH_NORM)
	}
	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]){
		event_Sprint(id)
		set_pev(id, pev_button, pev(id,pev_button) & ~IN_ATTACK) 
		set_pev(id, pev_button, pev(id,pev_button) & ~IN_ATTACK2) 
		if(gTime[id] >= get_pcvar_num(pTime)*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)){
		colored_print(id, "Want to run faster? Type '/sprint' in chat")
		gTime[id] = 0;
	}
}

public addTime(id){
	gTime[id]++;
}

public odejZmecznie(id){
	if(gTime[id] > 0){
		gTime[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;
}

colored_print(target, const message[], any:...)
{
	static buffer[512], i, argscount
	argscount = numargs()
	
	if (!target)
	{
		static player
		for (player = 1; player <= g_maxplayers; player++)
		{
			if (!is_user_connected(player))
				continue;
			
			static changed[5], changedcount
			changedcount = 0
			
			for (i = 2; i < argscount; i++)
			{
				if (getarg(i) == LANG_PLAYER)
				{
					setarg(i, 0, player)
					changed[changedcount] = i
					changedcount++
				}
			}
			
			vformat(buffer, charsmax(buffer), message, 3)
			
			message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
			write_byte(player)
			write_string(buffer)
			message_end()
			
			for (i = 0; i < changedcount; i++)
				setarg(changed[i], 0, LANG_PLAYER)
		}
	}
	else
	{
		vformat(buffer, charsmax(buffer), message, 3)
		
		message_begin(MSG_ONE, g_msgSayText, _, target)
		write_byte(target)
		write_string(buffer)
		message_end()
	}
}
Storas1337 is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 12-28-2013 , 09:51   Re: help to fix
Reply With Quote #2

Hide v_ model? You can do this:
PHP Code:
set_pev(idpev_viewmodel0
Tired sound, you can use task ;)
__________________
What are you looking for here?
DavidJr is offline
Storas1337
Senior Member
Join Date: Apr 2009
Location: Lithuania
Old 12-28-2013 , 10:34   Re: help to fix
Reply With Quote #3

Ok, how to remove fade screen?
Storas1337 is offline
Reply


Thread Tools
Display Modes

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 10:07.


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