Raised This Month: $ Target: $400
 0% 

2 lil questions :)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Amonel
Senior Member
Join Date: May 2009
Old 10-25-2009 , 02:22   2 lil questions :)
Reply With Quote #1

1.What is the event line for "game will restart in x seconds" ?
- can it be changed to "The game is LIVE" (i don't need how) -

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


public plugin_init()
{
register_plugin("Say /cmds""1.0""AmoneL")
register_clcmd("say /cmds""test")}

public 
test(id)
{
            static 
name[32];
            
get_user_name(idname31);
client_print(0print_chat"%s said /cmds"name);

OK, when i will type in chat /cmds, i will get in chat 2 lines
1st line will be: AmoneL: /cmds
2nd line will be: AmoneL said /cmds

How can i get rid off the 1st line?
i need something like.. remove_say or .. don't know
Amonel is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-25-2009 , 03:20   Re: 2 lil questions :)
Reply With Quote #2

1. If you want to catch "the game will restart in x seconds" then use this:

PHP Code:
public plugin_init(){
    
register_event("TextMsg""event_game_restart""a""2=#Game_will_restart_in")
}

public 
event_game_restart(){


You can use it to send some messages to player like "The game is LIVE" or whatever...

2. To block chat message you need to add "return PLUGIN_HANDLED" at the end of function:
PHP Code:
public plugin_init()
{
    
register_plugin("Say /cmds""1.0""AmoneL");
    
register_clcmd("say /cmds""test");
}

public 
test(id)
{
    static 
name[32];
    
get_user_name(idname31);
    
client_print(0print_chat"%s said /cmds"name);
    return 
PLUGIN_HANDLED;

You should also fix your indentation and use of semi-colons (use them everywhere or don't use them at all).
__________________
Impossible is Nothing

Last edited by Sylwester; 10-25-2009 at 03:25.
Sylwester is offline
Amonel
Senior Member
Join Date: May 2009
Old 10-25-2009 , 04:34   Re: 2 lil questions :)
Reply With Quote #3

thanks for advice, it was very helpfull.. now i fixed 4 scripts

erm.. i tryed what u said

PHP Code:
public plugin_init(){
    
register_event("TextMsg""event_game_restart""a""2=#Game_will_restart_in")
}

public 
event_game_restart()
{
            
client_print(0print_center"L i v e !");

and this one too
PHP Code:
public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_message(get_user_msgid("TextMsg"), "eTextMsg")
}

public 
eTextMsg(msg_idmsg_destmsg_entity)
{
    static 
szMessage[64]
    
get_msg_arg_string(2szMessage63)
    if(
equali(szMessage"2=#Game_will_restart_in")) 
        
set_msg_arg_string(2"L i v e !")

but no one works if i use "amx_cvar sv_restart 1"
Amonel is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-25-2009 , 06:06   Re: 2 lil questions :)
Reply With Quote #4

The first one does not work because message "Live" is displayed before "game will restart in ..." and it's overwritten. You would have to use task to make it work.

The 2nd one is better solution, but you made little mistake. Try:
PHP Code:
public plugin_init()
{
    
register_message(get_user_msgid("TextMsg"), "eTextMsg")
}

public 
eTextMsg(msg_idmsg_destmsg_entity)
{
    static 
szMessage[64]
    
get_msg_arg_string(2szMessage63)
    if(
equali(szMessage"#Game_will_restart_in"))
        
set_msg_arg_string(2"L i v e !")

__________________
Impossible is Nothing

Last edited by Sylwester; 10-25-2009 at 06:09.
Sylwester is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-25-2009 , 06:16   Re: 2 lil questions :)
Reply With Quote #5

First one should work since it's an event, aka message has already been sent.
Try instead : register_event("TextMsg", "event_game_restart", "a", "2&#Game_w")

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

#define VERSION "0.0.1"

new gmsgTextMsg
new g_iFhWriteString

public plugin_init()
{
    
register_plugin("Game Restart"VERSION"ConnorMcLeod")

    
register_forward(FM_MessageBegin"MessageBegin"1)

    
gmsgTextMsg get_user_msgid("TextMsg")
}

public 
MessageBegin(MSG_DESTiMsgId)
{
    if( 
iMsgId == gmsgTextMsg )
    {
        
g_iFhWriteString register_forward(FM_WriteString"WriteString")
    }
}

public 
WriteString( const szString[] )
{
    static const 
Game_will_restart_in[] = "#Game_will_restart_in"
    
static const Live[] = "L i v e !!"

    
unregister_forward(FM_WriteStringg_iFhWriteString)

    if( 
equal(szStringGame_will_restart_in) )
    {
        
write_string(Live)
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-25-2009 , 06:52   Re: 2 lil questions :)
Reply With Quote #6

First one does not work even with "2&#Game_w" - I checked it in game (works if used with task).

The method you used in your code is not very different from second one.

btw congrats, you managed to change 15 lines of easy to understand code into 40 lines of code that is hard to understand
__________________
Impossible is Nothing
Sylwester is offline
Amonel
Senior Member
Join Date: May 2009
Old 10-25-2009 , 13:39   Re: 2 lil questions :)
Reply With Quote #7

thanks sylwester , didnt noticed

btw conor, your code crushed my server X( "iFhWriteString" :-j





Last edited by Amonel; 10-25-2009 at 13:42.
Amonel is offline
Reply


Thread Tools
Display Modes

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 17:44.


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