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

[TF2] Stripping certain weapons after spawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Quimbo
Member
Join Date: May 2008
Old 05-15-2008 , 17:35   [TF2] Stripping certain weapons after spawn
Reply With Quote #1

Hi!

I currently learn scripting.

I'm trying to remove some weapons from the player after spawn. My method works great when called from e.g. a menu handler but when called in the player_spawn event hook the player still has all weapons.

PHP Code:
ForceSelectedWeapon(client)
{
    for (new 
0<= 5i++)
    {
        if (
== g_SelectedWeapon)
            continue;

        
TF2_RemoveWeaponSlot(clienti);
    }

    
ClientCommand(clientslotNames[g_SelectedWeapon]);

What am I doing wrong? Are the weapons added to the player after the player_spawn event? How could I remove them after spawn?

The other problem I'm having is to notice when a player touches a refill cabinet because that gives the previously removed weapons back.
Thank you

Last edited by Quimbo; 05-15-2008 at 18:07.
Quimbo is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 05-15-2008 , 18:24   Re: [TF2] Stripping certain weapons after spawn
Reply With Quote #2

You are not the first person having that problem.

Look at the melle plugin http://forums.alliedmods.net/showthread.php?p=561481
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 05-15-2008 , 21:54   Re: [TF2] Stripping certain weapons after spawn
Reply With Quote #3

@Nican: That version of the plugin isn't supported any longer. In my version, it works.

@Quimbo: Once a player spawns, their weapons aren't equipped until the next frame. This means that you have to use a timer (0.1 seconds works great) when they spawn and then remove the items.
bl4nk is offline
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 05-16-2008 , 06:22   Re: [TF2] Stripping certain weapons after spawn
Reply With Quote #4

Regarding your other problem, as far as I know there is no way to detect when a player is touching a locker so you can strip their weapons again. All you can do is disable them altogether like so:

Code:
new iRegenerate = -1; while ((iRegenerate = FindEntityByClassname(iRegenerate, "func_regenerate")) != -1) {     AcceptEntityInput(iRegenerate, "Disable"); }
They will then be disabled until the next round starts. To enable them at any time use Enable instead of Disable.
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 05-16-2008 , 12:53   Re: [TF2] Stripping certain weapons after spawn
Reply With Quote #5

I'm pretty sure you can just set up an entity I/O to detect when a player uses the locker.
bl4nk is offline
Quimbo
Member
Join Date: May 2008
Old 05-16-2008 , 20:27   Re: [TF2] Stripping certain weapons after spawn
Reply With Quote #6

Hi again!

Thanks guys for the nice responses! I really appreciate it.
Usually you get barked at when asking noob questions

I did that with the timer before I read your answer. I already imagined that the weapons aren't equipped yet.

Regarding disabling the locker: That doesn't seem to work always. Sometimes the lockers are still enabled (disabling is triggered by a menu callback).

Entity I/0? I'll try to read what that is

Thank you all.
Quimbo is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 05-16-2008 , 21:30   Re: [TF2] Stripping certain weapons after spawn
Reply With Quote #7

Entity Input/Output

Basically things that usually mappers can activate by a trigger, you can activate it with SourceMod
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
DJ Tsunami
DJ Post Spammer
Join Date: Feb 2008
Location: The Netherlands
Old 05-17-2008 , 08:21   Re: [TF2] Stripping certain weapons after spawn
Reply With Quote #8

Disabling them that way always works for me, they are only enabled when a new round starts.

The only outputs func_regenerate has is OnUser1-4, I'm not sure how you can hook those with SM. An example would be nice
__________________
Advertisements | REST in Pawn - HTTP client for JSON REST APIs
Please do not PM me with questions. Post in the plugin thread.
DJ Tsunami is offline
Quimbo
Member
Join Date: May 2008
Old 05-17-2008 , 12:31   Re: [TF2] Stripping certain weapons after spawn
Reply With Quote #9

Quote:
Originally Posted by DJ Tsunami View Post
Disabling them that way always works for me, they are only enabled when a new round starts.

The only outputs func_regenerate has is OnUser1-4, I'm not sure how you can hook those with SM. An example would be nice
Yeah, when I'm alone on my LAN dedicated it always works but on my gameserver with actual players it sometimes doesn't.
Dunno why.
Quimbo 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:40.


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