Raised This Month: $51 Target: $400
 12% 

TF2: SetPlayerWeaponSlot(client,slot) ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Tauphi
SourceMod Donor
Join Date: Sep 2004
Location: Germany
Old 10-04-2008 , 10:43   TF2: SetPlayerWeaponSlot(client,slot) ?
Reply With Quote #1

Hello,

does someone know how I can force a specific client, to switch the weapon to another slot?

There is a GetPlayerWeaponSlot() function, that gives me the current slot, but how do I set it?

Any ideas?

Andi
__________________
Tauphi is offline
Send a message via ICQ to Tauphi Send a message via Skype™ to Tauphi
FeuerSturm
AlliedModders Donor
Join Date: Apr 2004
Old 10-04-2008 , 10:57   Re: TF2: SetPlayerWeaponSlot(client,slot) ?
Reply With Quote #2

Quote:
Originally Posted by Tauphi View Post
Hello,

does someone know how I can force a specific client, to switch the weapon to another slot?

There is a GetPlayerWeaponSlot() function, that gives me the current slot, but how do I set it?

Any ideas?

Andi
You could try to use FakeClientCommand and "slot0", "slot1" etc.
or "invnext", "invprev".

Haven't tried that though, not sure if those commands are fakeable
or clientside only.

And if they exist in TF2 at all
FeuerSturm is offline
Tauphi
SourceMod Donor
Join Date: Sep 2004
Location: Germany
Old 10-04-2008 , 11:14   Re: TF2: SetPlayerWeaponSlot(client,slot) ?
Reply With Quote #3

slot0, slot1 etc are possible to change ...

but they open the weapon change menu only ... i have to set hud_fastswitch to 1 to get it work ... but hud_fastswitch is not fakeable serverside

other ideas ? ;D
__________________
Tauphi is offline
Send a message via ICQ to Tauphi Send a message via Skype™ to Tauphi
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 10-04-2008 , 12:23   Re: TF2: SetPlayerWeaponSlot(client,slot) ?
Reply With Quote #4

Are you able to fake an equip command? Such as equip tf_weapon_rocketlauncher.

If not, take a look at bl4nk's code in this post: http://forums.alliedmods.net/showthr...837#post682837. Look at the OnPluginStart and the end of Command_GiveNamedItem for the WeaponEquip stuff.

Last edited by Fyren; 10-05-2008 at 05:23. Reason: rocketlauncher, not rocket
Fyren is offline
kortul
Member
Join Date: May 2009
Location: Canada
Old 07-07-2009 , 19:51   Re: TF2: SetPlayerWeaponSlot(client,slot) ?
Reply With Quote #5

you can use ClientCommand("slot#") to force a switch. I use this for a plugin I am developing. FakeClientCommand() reports an unknown command. Make sure you use a timer if setting player's weapons when they spawn, as they only are equipped with weapons 1 game frame after spawn. I use 0.1 second timer and it works most of the time. Randomly it does not work. Still trying to determine why.
kortul is offline
retsam
Veteran Member
Join Date: Aug 2008
Location: so-cal
Old 07-07-2009 , 20:49   Re: TF2: SetPlayerWeaponSlot(client,slot) ?
Reply With Quote #6

ClientCommand(client, "slot3");

That would switch their slot to slot3.


The other way to do it is

new weapon = GetPlayerWeaponSlot(client, 2);
SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", weapon);
retsam is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-08-2009 , 04:26   Re: TF2: SetPlayerWeaponSlot(client,slot) ?
Reply With Quote #7

Use the second way that retsam mentioned. The first will have problems if a menu is active, or if they don't have quick switching enabled.
bl4nk is offline
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 05:15.


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