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

Override command with parameters


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kamis
Member
Join Date: May 2011
Old 11-21-2011 , 21:34   Override command with parameters
Reply With Quote #1

I'm wondering if there is a way to override a command that needs parameters. For example
Code:
"sm_giveto @me 2" "s"
Thanks in advance for any help you can give!
Kamis is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-22-2011 , 04:28   Re: Override command with parameters
Reply With Quote #2

What ?
__________________
Do not Private Message @me
Bacardi is offline
Kamis
Member
Join Date: May 2011
Old 11-22-2011 , 10:11   Re: Override command with parameters
Reply With Quote #3

In my admin overrides file, I'm trying to give people access to a command that has parameters associated with it. I need to restrict it to only that exact command.
The sm_giveto is the command, @me is parameter 1, and 2 is parameter two. And people with the s flag should be able to access it. But this doesn't seem to work, when doing that people with the s flag do not have access.
Code:
"sm_giveto @me 2" "s"
Kamis is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 11-22-2011 , 13:46   Re: Override command with parameters
Reply With Quote #4

You can't give access based on parameters. You can only give access based on command. So, "sm_giveto" "s" is as close as you're gonna get.
__________________
McFlurry is offline
Send a message via Skype™ to McFlurry
Kamis
Member
Join Date: May 2011
Old 11-22-2011 , 18:25   Re: Override command with parameters
Reply With Quote #5

Thanks for your reply.
That's too bad, is there another way to do that, short of recompiling the plugin with the command of course?
Kamis is offline
Steell
SourceMod Donor
Join Date: Mar 2009
Old 11-22-2011 , 23:58   Re: Override command with parameters
Reply With Quote #6

Best bet is to write a new plugin that creates a new command. Let's call it sm_giveme2. When this command is called, the plugin calls the sm_giveto command and supplies the client id as the first parameter and 2 as the second.
__________________
Steell is offline
McFlurry
Veteran Member
Join Date: Mar 2010
Location: RemoveEdict(0);
Old 11-23-2011 , 05:07   Re: Override command with parameters
Reply With Quote #7

ProcessTargetString doesn't use client ids. It uses user ids.
Sample of what you could merge into the original plugin.
PHP Code:
public OnPluginStart()
{
     
RegAdminCmd("sm_giveme2"Command_Giveme2ADMFLAG_CUSTOM5);
}

public 
Action:Command_Giveme2(clientargs)
{
     if(
args 0) return Plugin_Handled;
     new 
userid GetClientOfUserId(client);
     if(
userid != 0)
     {
          
ServerCommand("sm_giveme #%d 2"userid);
     }
     return 
Plugin_Handled;

__________________

Last edited by McFlurry; 11-23-2011 at 05:10.
McFlurry is offline
Send a message via Skype™ to McFlurry
Kamis
Member
Join Date: May 2011
Old 11-23-2011 , 11:13   Re: Override command with parameters
Reply With Quote #8

Great I'll give these a try, thank you!
Kamis is offline
Kamis
Member
Join Date: May 2011
Old 11-25-2011 , 19:29   Re: Override command with parameters
Reply With Quote #9

McFlurry,
I tried adding the code you put below, and added some print to chat for debugging, but it doesn't seem to work. It would not get into the If statement, And if I comment that out, The command still does not do what it is supposed to. Any suggestions? Thanks!
Kamis is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 11-26-2011 , 07:21   Re: Override command with parameters
Reply With Quote #10

Change GetClientOfUserId to GetClientUserId.
__________________
asherkin 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 08:18.


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