Raised This Month: $ Target: $400
 0% 

[CSS] Remove idle weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-20-2009 , 13:23   [CSS] Remove idle weapons
Reply With Quote #1

How to implement this on sourcemod?

ES code
Quote:
es.server.queuecmd('es_xfire %s game_weapon_manager AddOutput "maxpieces 0"' % es.getuserid())
__________________
altex is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-24-2009 , 15:09   Re: [CSS] Remove idle weapons
Reply With Quote #2

Hi
__________________
altex is offline
Kevin_b_er
SourceMod Donor
Join Date: Feb 2009
Old 12-24-2009 , 16:33   Re: [CSS] Remove idle weapons
Reply With Quote #3

Technically the ES thing appears to be a way to unflag cheats on ent_fire, fake a client command of 'ent_fire [userid] game_weapon_manager AddOutput "maxpieces 0"'

There's no builtin for unflagging the cheat, executing the command in the client's context, then reflagging cheat. There's FakeClientCommand for faking a command like ent_fire, but its protected by sv_cheats. So again, you'd have to take off the cheat flag, then put it back.

Alternatively something like this is probably much safer for this case.
game_weapon_manager is an entity that lives on the map, and the ent_fire command you're trying to do is to add an output of "maxpieces 0" to it. So lets do this directly.

PHP Code:
new ent = -1
if ((ent FindEntityByClassname(ent"game_weapon_manager")) > -1)
    {
    
SetVariantString("maxpieces 0");
    
AcceptEntityInput(ent"AddOutput");
    } 
Notes:
* Safer method courtesy of some example code written by BAILOPAN.
* Untested, scripter beware.
Kevin_b_er is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-24-2009 , 22:43   Re: [CSS] Remove idle weapons
Reply With Quote #4

Thank you!

P.S. Ofcourse i want to do it directly, not with cheats and ent_fire clientid
I just do not know how to dial with AddOutput and other entity manipulation commands (
But thanks for the explanation, i was not ever thinking of ent_fire.

P.P.S. I've used search forum before asking and was found various solutions to make AddOutput, but trying only one of them, it did not working, i'm felling unlucky
I was trying DispatchKeyValue(ent, "maxpieces", "0"); and it did not work. And that is why i was trying it - http://forums.alliedmods.net/showpos...98&postcount=4
I was found in forum that DispatchKeyValue and SetVariantString + AcceptEntityInput is the same thing and only trying first one )
But i did not expect (somehow 0_o) that DispatchKeyValue works only on creating or spawning new entities ))
And it realy is - http://forums.alliedmods.net/showpos...83&postcount=4
Thanks again for the help!
__________________

Last edited by altex; 12-24-2009 at 23:09.
altex is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-27-2009 , 06:48   Re: [CSS] Remove idle weapons
Reply With Quote #5

Just do not work

Quote:
new ent = -1;
if ( (ent = FindEntityByClassname(ent, "game_weapon_manager")) == -1 )
{
ent = CreateEntityByName("game_weapon_manager");
DispatchSpawn(ent);
}
SetVariantString("maxpieces 0");
AcceptEntityInput(ent, "AddOutput");
LogError("game_weapon_manager = %i", ent);
every round start it creates new entity, but dropped weapons are not removed
L 12/27/2009 - 14:50:29: [test.smx] game_weapon_manager = 87
L 12/27/2009 - 14:50:41: [test.smx] game_weapon_manager = 149
L 12/27/2009 - 14:51:04: [test.smx] game_weapon_manager = 154
__________________

Last edited by altex; 12-27-2009 at 06:53.
altex is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 12-27-2009 , 08:50   Re: [CSS] Remove idle weapons
Reply With Quote #6

Why are you creating a new entity when you could just use the input on the already existing one? I think you might be confusing the game's logic with more than one entity.
bl4nk is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-27-2009 , 09:00   Re: [CSS] Remove idle weapons
Reply With Quote #7

Quote:
Originally Posted by bl4nk View Post
Why are you creating a new entity when you could just use the input on the already existing one? I think you might be confusing the game's logic with more than one entity.
Actualy FindEntityByClassname(ent, "game_weapon_manager") returns -1; I have If statement, and if this entity exists, then i'm not creating anothe one. Just take a look at the if statement once again )

The first issue is that entity does not exist
The second issue is that after creating such entity i can not change it's property (or it does not take an effect).

__________________
altex is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 12-27-2009 , 09:05   Re: [CSS] Remove idle weapons
Reply With Quote #8

Ah, I read that as != instead of == (still sleepy I suppose). Why is it printing three different game_weapon_managers then?
bl4nk is offline
altex
Veteran Member
Join Date: May 2009
Location: Russia
Old 12-27-2009 , 09:08   Re: [CSS] Remove idle weapons
Reply With Quote #9

Quote:
Originally Posted by bl4nk View Post
Why is it printing three different game_weapon_managers then?
I think the this is because of sourcemod can not find such entity and it just creates another one.

But i can not fugure it out why it can not find this enitity.

Or maybe this entity just drops after round start/end...
__________________
altex is offline
Kevin_b_er
SourceMod Donor
Join Date: Feb 2009
Old 12-27-2009 , 15:44   Re: [CSS] Remove idle weapons
Reply With Quote #10

I will note that the valve developer wiki says that game_weapon_manager should only exist once in a map, and that extra copies of this entity type may cause errors.

http://developer.valvesoftware.com/w...weapon_manager

So if this entity exists more than once, there could be errors involved.
Kevin_b_er 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 20:01.


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