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

How to switch client weapon?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 05-21-2009 , 10:14   How to switch client weapon?
Reply With Quote #1

How to switch client weapon? Something like sending "use weapon_X" to client...
altex is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 05-21-2009 , 10:54   Re: How to switch client weapon?
Reply With Quote #2

Maybe this will help you:
Quote:
bind "0" "slot10"
bind "1" "slot1"
bind "2" "slot2"
bind "3" "slot3"
bind "4" "slot4"
bind "5" "slot5"
bind "6" "slot6"
bind "7" "slot7"
bind "8" "slot8"
bind "9" "slot9"
Use this with FakeClientCommand.
For example:
PHP Code:
FakeClientCommand(client"slot2"); 
__________________
For admins: My plugins

For developers: Colors library

Last edited by exvel; 05-21-2009 at 11:12.
exvel is offline
Send a message via ICQ to exvel
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 05-21-2009 , 11:55   Re: How to switch client weapon?
Reply With Quote #3

Thanks, i'll try FakeClientCommand.
But the way, what is the difference between FakeClientCommand and ClientCommand?

found https://forums.alliedmods.net/showpo...10&postcount=3
altex is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 05-21-2009 , 12:39   Re: How to switch client weapon?
Reply With Quote #4

Quote:
Originally Posted by altex View Post
Thanks, i'll try FakeClientCommand.
But the way, what is the difference between FakeClientCommand and ClientCommand?

found https://forums.alliedmods.net/showpo...10&postcount=3
  • FakeClientCommand makes server think that client executed a command.
  • ClientCommand will try to execute command on client. Only a few commands can be executed on client.
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 05-21-2009 , 17:10   Re: How to switch client weapon?
Reply With Quote #5

slot2 does not work, unknown command
use weapon_deagle does work
Thanks!
altex is offline
kortul
Member
Join Date: May 2009
Location: Canada
Old 05-22-2009 , 12:56   Re: How to switch client weapon?
Reply With Quote #6

the "slot%d" command is client side. when the client runs that it sends a different command to the server (probably use weapon_%s). I used ClientCommand("slot%d", slotnum) and it worked. But most commands it won't work.

Any client command that has to be sent to the server (networked) should work with FakeClientCommand. I think someone explains it in the api at one of those commands: http://docs.sourcemod.net/api/
kortul is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 05-22-2009 , 16:08   Re: How to switch client weapon?
Reply With Quote #7

Thanks for help everybody!

Quote:
Originally Posted by kortul View Post
I think someone explains it in the api at one of those commands: http://docs.sourcemod.net/api/
Did not found any explanations.. Maybe in wiki.
altex is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 05-22-2009 , 19:53   Re: How to switch client weapon?
Reply With Quote #8

PHP Code:
new weapon GetPlayerWeaponSlot(client2);
SetEntPropEnt(clientProp_Send"m_hActiveWeapon"weapon); 
That should changed to the third (yes, third - the second arg starts at 0) slot, which would be the melee weapon.
bl4nk is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 05-22-2009 , 23:00   Re: How to switch client weapon?
Reply With Quote #9

Quote:
Originally Posted by bl4nk View Post
PHP Code:
new weapon GetPlayerWeaponSlot(client2);
SetEntPropEnt(clientProp_Send"m_hActiveWeapon"weapon); 
That should changed to the third (yes, third - the second arg starts at 0) slot, which would be the melee weapon.
What is Prop_Send in this example?
altex is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 05-23-2009 , 01:54   Re: How to switch client weapon?
Reply With Quote #10

And what is the most correct way to change weapon? fakeclientcmd or setentpropent?
altex 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 18:11.


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