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

[L4D2]Add a switch


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 06-30-2019 , 11:02   [L4D2]Add a switch
Reply With Quote #1

Add a switch to allow players with only ADMFLAG_KICK to fly?

Unauthorized players cannot use helicopters.

At present, someone on the server maliciously made a lot of. helicopters.
All players a helicopter.
Causing server latency is too high.
Want to make a limit.
Attached Files
File Type: sp Get Plugin or Get Source (helicopter_l4d2.sp - 153 views - 43.3 KB)
__________________
I like this BBS sharing of spirit

I come from China, my English is poor
phoenix0001 is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-30-2019 , 12:32   Re: [L4D2]Add a switch
Reply With Quote #2

PHP Code:
RegConsoleCmd("sm_h"sm_h);
to
RegAdminCmd
("sm_h"sm_hADMFLAG_KICK); 
__________________

Last edited by Silvers; 06-30-2019 at 12:32. Reason: typo
Silvers is offline
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 07-01-2019 , 01:04   Re: [L4D2]Add a switch
Reply With Quote #3

After the helicopter is dropped[CTRL+E], there is no ADMFLAG_KICK player and you cannot use the helicopter.
__________________
I like this BBS sharing of spirit

I come from China, my English is poor

Last edited by phoenix0001; 07-01-2019 at 01:05.
phoenix0001 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-02-2019 , 12:52   Re: [L4D2]Add a switch
Reply With Quote #4

When the helicopter is dropped, a button (invisible) is spawned.
You need do that check also when the button is pressed.

Button created here: CreateEntityByName("func_button")
Or maybe to Fly command, but need to do more tests.
__________________
Marttt is offline
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 07-04-2019 , 01:29   Re: [L4D2]Add a switch
Reply With Quote #5

Quote:
Originally Posted by Marttt View Post
When the helicopter is dropped, a button (invisible) is spawned.
You need do that check also when the button is pressed.

Button created here: CreateEntityByName("func_button")
Or maybe to Fly command, but need to do more tests.
I won't create it. Can you help me create it?
__________________
I like this BBS sharing of spirit

I come from China, my English is poor
phoenix0001 is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-04-2019 , 07:01   Re: [L4D2]Add a switch
Reply With Quote #6

Yes, I'm a little busy now but till the end of the week I will try to fix it for you.
__________________
Marttt is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 07-04-2019 , 18:09   Re: [L4D2]Add a switch
Reply With Quote #7

Quote:
Originally Posted by Marttt View Post
I removed all compile warnings
https://forums.alliedmods.net/showpo...0&postcount=41

Quote:
1.7 (21-Jul-2018)
- New Syntax and some Methodmaps
- Removed useless and unused code
- Cleaned some code and whitespace
- Fixed all compiler warnings
- No more crashes
- No more spectator stuck bugs
- Bomb now credits kill (but doesn't hurt survivors as much)
- Changed bomb model to Maverick Missile (toggle lines and recompile to revert)
- Compatible with updated Flare Gun plugin
__________________

Last edited by Silvers; 07-04-2019 at 18:09.
Silvers is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-04-2019 , 21:24   Re: [L4D2]Add a switch
Reply With Quote #8

Added a check on the "OnPressed" event, try it now.

PHP Code:
public void OnPressed(const char[] outputint callerint activatorfloat delay)
{
    if (!
CheckCommandAccess(activator"sm_h"ADMFLAG_KICK))
        
PrintToChat(activator"Only admins can use helicopters");

    ... 
Note:
This is not the best way to do it, but may work, players will still take "5" seconds for the chat message (since "type" var is always false).
And if you use a "admin_override.cfg" to change the command flag, it may not work properly.

Thank you Silvers, I was about to post the wrong sp plugin file.
Attached Files
File Type: sp Get Plugin or Get Source (helicopter_l4d2.sp - 119 views - 43.5 KB)
__________________

Last edited by Marttt; 07-04-2019 at 21:26.
Marttt is offline
phoenix0001
Senior Member
Join Date: Apr 2010
Location: China
Old 07-07-2019 , 00:20   Re: [L4D2]Add a switch
Reply With Quote #9

Quote:
Originally Posted by Marttt View Post
Added a check on the "OnPressed" event, try it now.

PHP Code:
public void OnPressed(const char[] outputint callerint activatorfloat delay)
{
    if (!
CheckCommandAccess(activator"sm_h"ADMFLAG_KICK))
        
PrintToChat(activator"Only admins can use helicopters");

    ... 
Note:
This is not the best way to do it, but may work, players will still take "5" seconds for the chat message (since "type" var is always false).
And if you use a "admin_override.cfg" to change the command flag, it may not work properly.

Thank you Silvers, I was about to post the wrong sp plugin file.
If a helicopter is not used for many seconds, it will disappear.
Is this going to be simpler?
__________________
I like this BBS sharing of spirit

I come from China, my English is poor
phoenix0001 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 09:48.


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