AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   2 lil questions :) (https://forums.alliedmods.net/showthread.php?t=107296)

Amonel 10-25-2009 02:22

2 lil questions :)
 
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 :|

Sylwester 10-25-2009 03:20

Re: 2 lil questions :)
 
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).

Amonel 10-25-2009 04:34

Re: 2 lil questions :)
 
thanks for advice, it was very helpfull.. now i fixed 4 scripts :D

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"

Sylwester 10-25-2009 06:06

Re: 2 lil questions :)
 
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 !")



ConnorMcLeod 10-25-2009 06:16

Re: 2 lil questions :)
 
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



Sylwester 10-25-2009 06:52

Re: 2 lil questions :)
 
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 :P

Amonel 10-25-2009 13:39

Re: 2 lil questions :)
 
thanks sylwester :), didnt noticed :)

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






All times are GMT -4. The time now is 17:44.

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