Raised This Month: $ Target: $400
 0% 

[TF2] Output for a player reloading?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sirot
Member
Join Date: Sep 2008
Old 09-28-2008 , 02:59   [TF2] Output for a player reloading?
Reply With Quote #1

I want to do certain actions when a player hits the reload key. What I have currently is extremely unreliable as there are more players in the server...

Or even better yet, how can I get a client id out of the following code since it does seem to give one.

Code:
RegConsoleCmd("+reload", command_Reload);

public Action: command_Reload (client, args)
{
STUFF
}
Found a work-around.

EDIT: bah, didn't work.

Last edited by Sirot; 09-28-2008 at 14:00.
Sirot is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 09-28-2008 , 12:53   Re: [SOLVED] [TF2] Output for a player reloading?
Reply With Quote #2

if(GetClientButtons(client) & IN_RELOAD)
{
// stuff
}
or hook 'weapon_reload' event

Last edited by SAMURAI16; 09-28-2008 at 13:22.
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
Sirot
Member
Join Date: Sep 2008
Old 09-28-2008 , 13:56   Re: [SOLVED] [TF2] Output for a player reloading?
Reply With Quote #3

Quote:
Originally Posted by SAMURAI16 View Post
if(GetClientButtons(client) & IN_RELOAD)
{
// stuff
}
or hook 'weapon_reload' event
'weapon_reload' does not exist in TF2 and the issue is that no client is given to find the buttons from.
Sirot is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 09-28-2008 , 14:08   Re: [TF2] Output for a player reloading?
Reply With Quote #4

yea, you have right
Try using Hacks ext : http://forums.alliedmods.net/showthread.php?t=56323
Hook PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper)
and check if 'buttons' param is IN_RELOAD
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
Sirot
Member
Join Date: Sep 2008
Old 09-28-2008 , 23:38   Re: [TF2] Output for a player reloading?
Reply With Quote #5

Quote:
Originally Posted by SAMURAI16 View Post
yea, you have right
Try using Hacks ext : http://forums.alliedmods.net/showthread.php?t=56323
Hook PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper)
and check if 'buttons' param is IN_RELOAD
I looked at extension and damn, none of his examples make a lick of sense.
Sirot is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 09-29-2008 , 08:11   Re: [TF2] Output for a player reloading?
Reply With Quote #6

hmm
from player.cpp
Code:
void CBasePlayer::PlayerRunCommand(CUserCmd *ucmd, IMoveHelper *moveHelper)
{
 m_touchedPhysObject = false;
 if ( pl.fixangle == FIXANGLE_NONE)
 {
  VectorCopy ( ucmd->viewangles, pl.v_angle );
 }
 // Handle FL_FROZEN.
 // Prevent player moving for some seconds after New Game, so that they pick up everything
 if( GetFlags() & FL_FROZEN || 
  (developer.GetInt() == 0 && gpGlobals->eLoadType == MapLoad_NewGame && gpGlobals->curtime < 3.0 ) )
 {
  ucmd->forwardmove = 0;
  ucmd->sidemove = 0;
  ucmd->upmove = 0;
  ucmd->buttons = 0;
  ucmd->impulse = 0;
  VectorCopy ( pl.v_angle, ucmd->viewangles );
 }
 PlayerMove()->RunCommand(this, ucmd, moveHelper);
}
I couldn't figure yet arguments, but try this:
Code:
#include <hacks> new g_iHooks[MAXPLAYERS + 1] = { -1, ... };   public OnClientPutInServer(client) {     g_iHooks[client] = Hacks_Hook(client, HACKS_HTYPE_PLAYERRUNCOMMAND, HookClientCommand, false);     }     public OnClientDisconnect(client) {     Hacks_Unhook(g_iHooks[client]); }     public HookClientCommand(client, buttons, weapon, forwardmove, sidemove, upmove) {     if(buttons & IN_RELOAD)     {         // stuff     }       return Hacks_Continue; }
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
Sirot
Member
Join Date: Sep 2008
Old 09-29-2008 , 14:28   Re: [TF2] Output for a player reloading?
Reply With Quote #7

Kept getting an error in the console when the server first starts that says "hacks.ext was not loaded". The code does noing : /

Found this: http://forums.alliedmods.net/showthread.php?t=71498
All's good.

Last edited by Sirot; 09-29-2008 at 14:38.
Sirot is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 09-29-2008 , 14:46   Re: [TF2] Output for a player reloading?
Reply With Quote #8

probably you didn't installed hack extension correctly
btw, hooker extension can hook RELOAD ?
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
Reply



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 18:24.


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