Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 07-03-2012, 05:10 PM   #1
Codexofwisdom
 
Join Date: Nov 2011
Reputation: 0
Posts: 11
Console Commands via Weapon

I've spent the last hour Googling this, but can't find anything anywhere.
How would I go about telling a weapon to execute a console command instead of firing a bullet? Specifically, I want to create a camera, like Garry's Mod has, that will take a screenshot when you click.
Does this need to be edited in the weapon's .cpp, or the script? Or will I need to create a whole new weapon type?
Codexofwisdom is offline  
Reply With Quote
Old 07-03-2012, 07:00 PM   #2
Alters
 
 
 
Join Date: Jun 2008
Reputation: 13
Posts: 132
It should be pretty easy. In a weapon's PrimaryAttack function (in the cpp file) simply remove everything weapon related and instead put:

Code:
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if ( pPlayer )
{
engine->ClientCommand( pPlayer->edict(), "WhateverTheScreenshotCmdIs\n" );
}

Last edited by Alters: 07-03-2012 at 09:31 PM.
Alters is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


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



All times are GMT -7. The time now is 01:17 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2014, All Rights Reserved.