Raised This Month: $ Target: $400
 0% 

Someone knows how to...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 05-26-2010 , 14:28   Someone knows how to...
Reply With Quote #1

...hook say and make a command called /rr !rr or .rr (NUM) and the server will make a restart depending of the NUM ?

I have tried with strbreak and changing the str to num,but doesn't works.
#8 SickneSS is offline
Send a message via MSN to #8 SickneSS Send a message via Skype™ to #8 SickneSS
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 05-26-2010 , 14:53   Re: Someone knows how to...
Reply With Quote #2

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]
    
read_args(args31)
    
remove_quotes(args)
    
parse(argscmd15tmp15)
    if(
equali("rr"cmd[cmd[0] == '!' || cmd[0] == '/' || cmd[0] == '.'])){
        
server_cmd("sv_restartround %d"str_to_num(tmp))
    }

__________________
Impossible is Nothing
Sylwester is offline
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 05-26-2010 , 14:56   Re: Someone knows how to...
Reply With Quote #3

I will test it later,thanks
#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-26-2010 , 18:28   Re: Someone knows how to...
Reply With Quote #4

What in the world is this???

Code:
equali("rr", cmd[cmd[0] == '!' || cmd[0] == '/' || cmd[0] == '.'])
EDIT:
I figured it out. This bool/int conversion assumption is annoying sometimes. It will also return true if you say "rr".

You should probably change it to:

Code:
equali("rr", cmd[!!(cmd[0] == '!' || cmd[0] == '/' || cmd[0] == '.')])
__________________

Last edited by fysiks; 05-26-2010 at 18:33.
fysiks is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 05-27-2010 , 01:46   Re: Someone knows how to...
Reply With Quote #5

Why double negation? It doesn't change anything here and in the end it's still auto conversion to int.
Did you mean:
Code:
equali("rr", cmd[_:(cmd[0] == '!' || cmd[0] == '/' || cmd[0] == '.')])
?
__________________
Impossible is Nothing
Sylwester is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-27-2010 , 02:56   Re: Someone knows how to...
Reply With Quote #6

Quote:
Originally Posted by Sylwester View Post
Why double negation? It doesn't change anything here and in the end it's still auto conversion to int.
Did you mean:
Code:
equali("rr", cmd[_:(cmd[0] == '!' || cmd[0] == '/' || cmd[0] == '.')])
?
Nope. Essentially this. There is more discussion about it in the thread.

But, now that I think of it, it should be something like:

Code:
equali("rr", cmd[(cmd[0] == '!' || cmd[0] == '/' || cmd[0] == '.') ? 1 : 0])
But because Pawn is typeless it may work your way without fail. Basically the result of (cmd[0] == '!' || cmd[0] == '/' || cmd[0] == '.') cannot be -1 or 3 (i.e. anything not 1 or 0; all of which evaluate as true) or it will case a index out of bounds.
__________________

Last edited by fysiks; 05-27-2010 at 02:59.
fysiks is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 05-27-2010 , 04:59   Re: Someone knows how to...
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
Nope. Essentially this. There is more discussion about it in the thread.
They used !! in that thread only for conversion int -> bool, but you tried to use it in this thread for conversion bool -> int (it does nothing in this case).
__________________
Impossible is Nothing
Sylwester is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-27-2010 , 12:06   Re: Someone knows how to...
Reply With Quote #8

Quote:
Originally Posted by Sylwester View Post
They used !! in that thread only for conversion int -> bool, but you tried to use it in this thread for conversion bool -> int (it does nothing in this case).
Yeah, but the result of (var == 3) will not necessarily be 1 or 0. If it's true it could be 34. This is the way I understand it but maybe I am wrong.
__________________

Last edited by fysiks; 05-27-2010 at 12:16.
fysiks is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 05-27-2010 , 12:26   Re: Someone knows how to...
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
Yeah, but the result of (var == 3) will not necessarily be 1 or 0. If it's true it could be 34. This is the way I understand it but maybe I am wrong.
Can you provide an example proving your theory? Because as far as I know the result of (x == y) will always be true or false (converted to int it will always be 1 or 0). The same goes for other logical operators.
__________________
Impossible is Nothing
Sylwester is offline
#8 SickneSS
BANNED
Join Date: Sep 2008
Location: Here
Old 05-27-2010 , 12:16   Re: Someone knows how to...
Reply With Quote #10

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "#8 SickneSS"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say","hook")
}

public 
hook(id) {
    
    new 
said[192]
    
read_args(said,191)
    
remove_quotes(said)
    
    new 
Restart[11]
    new 
Value[11]
    
    
strbreak(said,Restart,10,Value,10)

    if(
equali(Restart,"/rr"))
    {
        if(
equal(Value,""))
        {
            
server_cmd("sv_restart 1")
            
client_print(id,print_chat,"Restart por 1")
        }
        else
        {
            
server_cmd("sv_restart %d",str_to_num(Value))
            
client_print(id,print_chat,"Restart por %d",str_to_num(Value))
        }
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_CONTINUE

I Made this,but I can't take if is str num or is more than 60,because if I put that,doesn't do nothing when I put only /rr

btw : i will made a const to type !rr /rr .rr or /r !r .r or !restart /restart .restart

Last edited by #8 SickneSS; 05-27-2010 at 12:21.
#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 05:23.


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