AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   When I execute this script it crashes my server (https://forums.alliedmods.net/showthread.php?t=293619)

Lawnmoverman 02-05-2017 08:47

When I execute this script it crashes my server
 
When I execute noz_warmup on server it crashes!
Any help would be appreciated!

PHP Code:

#include <amxmodx>
#include <amxmisc>

new iCount =        0

public plugin_init() 
{
    
register_plugin("Knifes Warmup","1.0","Lawnmoverman")
    
register_concmd("noz_warmup","noz_warmup",ADMIN_IMMUNITY,"noz_warmup - starts knifes only warmup")
}

// Colour Chat
client_printc(index, const text[], any:...)
{
    new 
szMsg[128];
    
vformat(szMsgsizeof(szMsg) - 1text3);
    
    
replace_all(szMsgsizeof(szMsg) - 1"!g""^x04");
    
replace_all(szMsgsizeof(szMsg) - 1"!n""^x01");
    
replace_all(szMsgsizeof(szMsg) - 1"!t""^x03");
    
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _index);
    
write_byte(index);
    
write_string(szMsg);
    
message_end();
}

public 
noz_warmup(id
{

    new const 
Float:fTime[] = { 1.015.045.060.071.075.078.084.0 }
    for ( new 
i++ )
    
set_task(fTime[i], "WarmUP"id)

    return 
PLUGIN_HANDLED
}

public 
WarmUP(id
{    
    switch(
iCount)
    {
        case 
0
        {
        
client_printc(0"!t[Warmup] !gKnifes only!")
        
server_cmd("amx_csay yellow ^"[WarmupKnifes only!^"")
        
server_cmd("amx_knifesonly 1")
        
client_cmd(0"spk ^"Hello, and have the nice day^"")
        }
        case 
1
        {
        
client_printc(0"!t[Warmup] !g60 seconds remaining!")
        } 
        case 
2:
        {
        
client_printc(0"!t[Warmup] !g30 seconds remaining!")
        }
        case 
3:
        {
        
client_printc(0"!t[Warmup] !g15 seconds remaining!")
        }
        case 
4:
        {
        
client_printc(0"!t[Warmup] !gLive after 3 restarts!")
        }
        case 
5:
        {
        
server_cmd("amx_rr ^"3^" ^"1^"")
        }
        case 
6:
        {
        
server_cmd("amx_knifesonly 0")
        }
        case 
7:
        {
        
client_printc(0"!t[Warmup] !gLive! GL & HF!")
        
server_cmd("amx_csay yellow ^"[WarmupLiveGL HF!^"")
        
client_cmd(0"spk ^"Going lifekill and eliminate all ass^"")
        }
    }
    
iCount++



Black Rose 02-05-2017 09:29

Re: When I execute this script it crashes my server
 
It's because you can't send SayText to ONE_UNRELIABLE while not supplying an index. Index 0 is the server and it can't receive that message.
If index = 0 and the server is dedicated, you should use MSG_BROADCAST.

Lawnmoverman 02-05-2017 12:24

Re: When I execute this script it crashes my server
 
I thought that index 0 is all clients. I will try to change MSG_ONE_UNRELIABLE to MSG_BROADCAST

HamletEagle 02-05-2017 12:38

Re: When I execute this script it crashes my server
 
That's only for client_print native, because this is how it's designed. If 0 is passed it loops all players, it does not send a message with player index = 0.
https://github.com/alliedmodders/amx...xmodx.cpp#L243

Lawnmoverman 02-07-2017 16:05

Re: When I execute this script it crashes my server
 
If I change MSG_ONE_UNRELIABLE to MSG_BROADCAST, script works fine, but I dont get colors and in messages instead of !g !t and !n there are placed spaces, so in game I get very spaced messages without colors.

Like
HTML Code:

  [Warmup]  some text
And not
[Warmup] some text

Is there any way to fix this or to use something other instead of msg_broadcast, or to put some index in client_printc ?.

Black Rose 02-08-2017 13:25

Re: When I execute this script it crashes my server
 
I don't know if broadcast would cause that but try looping players instead like HamletEagle said.

Lawnmoverman 02-08-2017 14:03

Re: When I execute this script it crashes my server
 
I will try to do that with iCount

Natsheh 02-09-2017 11:37

Re: When I execute this script it crashes my server
 
PHP Code:

//Colour Chat 
client_printc(index, const text[], any:...) 

    new 
szMsg[192]; 
    
vformat(szMsg[1], charsmax(szMsg), text3); 
    
szMsg[0] =  '^1'
    
szMsg[191] = '^0'
     
    
replace_all(szMsgsizeof(szMsg) - 1"!g""^x04"); 
    
replace_all(szMsgsizeof(szMsg) - 1"!n""^x01"); 
    
replace_all(szMsgsizeof(szMsg) - 1"!t""^x03"); 
     
    if( 
index == 0)
    {
           new 
players[32], pnum;
           
get_players(playerspnum"ch")
           for(new 
iget_maxplayers(); i++)
           {
                     
index players[i];
                     
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _index); 
                     
write_byte(index); 
                     
write_string(szMsg); 
                     
message_end();
           }
           return;
    }
    
    
message_begin(MSG_ONEget_user_msgid("SayText"), _index); 
    
write_byte(index); 
    
write_string(szMsg); 
    
message_end(); 



Lawnmoverman 02-10-2017 12:32

Re: When I execute this script it crashes my server
 
Quote:

Originally Posted by Natsheh (Post 2494124)
PHP Code:

//Colour Chat 
client_printc(index, const text[], any:...) 

    new 
szMsg[192]; 
    
vformat(szMsg[1], charsmax(szMsg), text3); 
    
szMsg[0] =  '^1'
    
szMsg[191] = '^0'
     
    
replace_all(szMsgsizeof(szMsg) - 1"!g""^x04"); 
    
replace_all(szMsgsizeof(szMsg) - 1"!n""^x01"); 
    
replace_all(szMsgsizeof(szMsg) - 1"!t""^x03"); 
     
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _index); 
    
write_byte(index); 
    
write_string(szMsg); 
    
message_end(); 



This is not working at all !

Lawnmoverman 02-10-2017 15:44

Re: When I execute this script it crashes my server
 
I solved this by including chatcolor.inc

Chatcolor loops players when 0 is specified.

Heres the code:

PHP Code:

#include <amxmodx> 
#include <amxmisc>
#include <chatcolor> 

new iCount =        

public plugin_init()  

    
register_plugin("Knifes Warmup","1.0","Lawnmoverman"
    
register_concmd("noz_warmup","noz_warmup",ADMIN_IMMUNITY,"noz_warmup - starts knifes only warmup"


public 
noz_warmup(id)  


    new const 
Float:fTime[] = { 1.015.045.060.071.075.078.084.0 
    for ( new 
i++ ) 
    
set_task(fTime[i], "WarmUP"id

    return 
PLUGIN_HANDLED 


public 
WarmUP(id)  
{     
    switch(
iCount
    { 
        case 
0:  
        { 
        
client_print_color(00"^3[Warmup] ^4Knifes only!"
        
server_cmd("amx_csay yellow [Warmup] Knifes only!"
        
server_cmd("amx_knifesonly 1"
        
client_cmd(0"spk ^"Hello, and have the nice day^""
        } 
        case 
1:  
        { 
        
client_print_color(00"^3[Warmup]^4 60 seconds remaining!"
        }  
        case 
2
        { 
        
client_print_color(00"^3[Warmup]^4 30 seconds remaining!"
        } 
        case 
3
        { 
        
client_print_color(00"^3[Warmup]^4 15 seconds remaining!"
        } 
        case 
4
        { 
        
client_print_color(00"^3[Warmup]^4 Live after 3 restarts!"
        } 
        case 
5
        { 
        
server_cmd("amx_rr ^"3^" ^"1^""
        } 
        case 
6
        { 
        
server_cmd("amx_knifesonly 0"
        } 
        case 
7
        { 
        
client_print_color(00"^3[Warmup]^4 Live! GL & HF!"
        
server_cmd("amx_csay yellow [Warmup] Live! GL & HF!"
        
client_cmd(0"spk ^"Going lifegoing lifekill and eliminate all ass^""
        } 
    } 
    
iCount++ 


You can close this thread!


All times are GMT -4. The time now is 20:45.

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