Raised This Month: $ Target: $400
 0% 

Someone knows how to...


Post New Thread Reply   
 
Thread Tools Display Modes
unnyquee
Senior Member
Join Date: Jun 2009
Location: Constanta, Romania
Old 05-27-2010 , 12:37   Re: Someone knows how to...
Reply With Quote #11

PHP Code:
#include <amxmodx>

#pragma semicolon 1

new const g_szCommands[][] =
{
      
"/rr",
      
"!rr",
      
".rr"
};


public 
plugin_init()
{
      
register_plugin("O""M""G");
      
      
register_concmd("say""ConsoleCommand_Say");
}

public 
ConsoleCommand_Say(iClient)
{
      new 
szSaid[192], szCommand[3], szValue[3], iValue;
      
      
read_args(szSaidcharsmax(szSaid));
      
      for(new 
0sizeof(g_szCommands); i++)
      {
           if(
equali(szSaidg_szCommands[i], 3))
           {
                 
strbreak(szSaidszCommandcharsmax(szCommand), szValuecharsmax(szValue));
            
                 
iValue str_to_num(szValue);
            
                 if(
iValue)
                       
server_cmd("sv_restart %d"iValue);
            
                 else
                       
server_cmd("sv_restart 1");
           }
      }

      return 
PLUGIN_CONTINUE;

Not tested, though.
__________________

Last edited by unnyquee; 05-27-2010 at 12:46. Reason: edited a lil' bit
unnyquee is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 05-27-2010 , 12:47   Re: Someone knows how to...
Reply With Quote #12

tested, without any const, you can type just part of "restart" and it will work
PHP Code:
#include <amxmodx>
public plugin_init(){
    
register_clcmd("say""handle_say")
    
register_clcmd("say_team""handle_say")
}

public 
handle_say(id){
    static 
args[32], cmd[16], tmp[16], pos
    read_args
(args31)
    
remove_quotes(args)
    
parse(argscmd15tmp15)
    
pos = (cmd[0] == '!' || cmd[0] == '/' || cmd[0] == '.')
    if(
equali("rr"cmd[pos]) || containi("restart"cmd[pos]) == 0){
        new 
num str_to_num(tmp)
        if(
num<=0)
            
num 1
        
else if(num>60)
            
num 60
        client_print
(idprint_chat"Restart por %d"num)
        
server_cmd("sv_restart %d"num)
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE

__________________
Impossible is Nothing

Last edited by Sylwester; 05-27-2010 at 12:50.
Sylwester is offline
unnyquee
Senior Member
Join Date: Jun 2009
Location: Constanta, Romania
Old 05-27-2010 , 12:55   Re: Someone knows how to...
Reply With Quote #13

I have put that const there to easily modify the commands .
__________________
unnyquee is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 05-27-2010 , 13:07   Re: Someone knows how to...
Reply With Quote #14

But you also made a mistake and it will not work properly with longer commands.
__________________
Impossible is Nothing
Sylwester is offline
Old 05-27-2010, 13:18
#8 SickneSS
This message has been deleted by #8 SickneSS. Reason: A
unnyquee
Senior Member
Join Date: Jun 2009
Location: Constanta, Romania
Old 05-27-2010 , 14:03   Re: Someone knows how to...
Reply With Quote #15

Quote:
Originally Posted by Sylwester View Post
But you also made a mistake and it will not work properly with longer commands.
I understand what you're saying. Didn't though about longer commands.
__________________
unnyquee is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 05-28-2010 , 13:10   Re: Someone knows how to...
Reply With Quote #16

Wont be better something more easy?

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define MAX_RESTART_VALUE 10

public plugin_init() 
{
    
register_clcmd("say /rr""cmd_manual_restart")
    
register_clcmd("say !rr""cmd_manual_restart")
    
register_clcmd("say .rr""cmd_manual_restart")
}

public 
cmd_manual_restart(id)
{
    new 
szArgs[5]
    
read_argv(1szArgscharsmax(szArgs))
    
    new 
iResult clamp(str_to_num(szArgs), 110)
    
    
server_cmd("sv_restart ^"%d^""iResult)
    
client_print(idprint_chat"[INFO] Restart Request Succesfully. The round will restart on %d seconds"iResult)
    
    return 
PLUGIN_HANDLED

__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-28-2010 , 13:43   Re: Someone knows how to...
Reply With Quote #17

@meTaLiCroSS
Won't work.

"say /rr" is different from "say /rr ANYNUMBER", so commands won't be registered.



For other method, use Tries rather than succesive equal(), or use Sylwester method.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 05-28-2010 , 15:13   Re: Someone knows how to...
Reply With Quote #18

Tested and done.(This is my method,and now it works). If someone have a suggestion or want to optimise the code I'll appreciate.
PHP Code:
public cmdSayRestart(id,level,cid) {
    
    if(!
cmd_access(id,level,cid,1))
        return 
PLUGIN_HANDLED
    
    
new said[192]
    
read_args(said,191)
    
remove_quotes(said)
    
    new 
name[32]
    
get_user_name(id,name,31)
    
    new 
Restart[11]
    new 
Tmp[11]
    
strbreak(said,Restart,10,Tmp,10)
    
    new 
Value str_to_num(Tmp)

    new const 
Restrts[] = { "/restart","!restart",".restart","/rr","!rr",".rr","/r","!r",".r" }
    
    for(new 
0;<= sizeof (Restrts);i++)
        if(
equali(Restart,Restrts[i]))
        {
            if(!
is_str_num(Tmp) || Value 60)
                
Value 1
                    
            
if(equal(Tmp,""))
                
server_cmd("sv_restart 1")
            else
                
server_cmd("sv_restart %d",Value)
    
            
ChatColor(0,"%s !yADMIN %s : Restarteo la ronda",szPrefix,name)
            return 
PLUGIN_HANDLED
        
}

    return 
PLUGIN_CONTINUE


Last edited by #8 SickneSS; 05-28-2010 at 15:17.
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-28-2010 , 18:12   Re: Someone knows how to...
Reply With Quote #19

Quote:
Originally Posted by #8 SickneSS View Post
If someone have a suggestion or want to optimise the code I'll appreciate.[
Quote:
Originally Posted by ConnorMcLeod View Post
For other method, use Tries rather than succesive equal(), or use Sylwester method.
__________________
fysiks is offline
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 05-28-2010 , 20:24   Re: Someone knows how to...
Reply With Quote #20

Oh,sorry I dont see that .. (I deleted my other code and upload this)

Sorry,Im not to good in this,can someone tell me what means Connor

Last edited by #8 SickneSS; 05-28-2010 at 20:28.
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
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 22:47.


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