Raised This Month: $ Target: $400
 0% 

When I execute this script it crashes my server


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lawnmoverman
Member
Join Date: Jan 2017
Old 02-05-2017 , 08:47   When I execute this script it crashes my server
Reply With Quote #1

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++

Lawnmoverman is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-05-2017 , 09:29   Re: When I execute this script it crashes my server
Reply With Quote #2

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.
__________________
Black Rose is offline
Lawnmoverman
Member
Join Date: Jan 2017
Old 02-05-2017 , 12:24   Re: When I execute this script it crashes my server
Reply With Quote #3

I thought that index 0 is all clients. I will try to change MSG_ONE_UNRELIABLE to MSG_BROADCAST

Last edited by Lawnmoverman; 02-05-2017 at 12:36.
Lawnmoverman is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 02-05-2017 , 12:38   Re: When I execute this script it crashes my server
Reply With Quote #4

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
__________________

Last edited by HamletEagle; 02-05-2017 at 12:38.
HamletEagle is offline
Lawnmoverman
Member
Join Date: Jan 2017
Old 02-07-2017 , 16:05   Re: When I execute this script it crashes my server
Reply With Quote #5

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 ?.

Last edited by Lawnmoverman; 02-07-2017 at 17:03.
Lawnmoverman is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-08-2017 , 13:25   Re: When I execute this script it crashes my server
Reply With Quote #6

I don't know if broadcast would cause that but try looping players instead like HamletEagle said.
__________________
Black Rose is offline
Lawnmoverman
Member
Join Date: Jan 2017
Old 02-08-2017 , 14:03   Re: When I execute this script it crashes my server
Reply With Quote #7

I will try to do that with iCount
Lawnmoverman is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 02-09-2017 , 11:37   Re: When I execute this script it crashes my server
Reply With Quote #8

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(); 


Last edited by Natsheh; 02-12-2017 at 02:29.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Lawnmoverman
Member
Join Date: Jan 2017
Old 02-10-2017 , 12:32   Re: When I execute this script it crashes my server
Reply With Quote #9

Quote:
Originally Posted by Natsheh View Post
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 is offline
Lawnmoverman
Member
Join Date: Jan 2017
Old 02-10-2017 , 15:44   Re: When I execute this script it crashes my server
Reply With Quote #10

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!

Last edited by Lawnmoverman; 02-11-2017 at 00:11.
Lawnmoverman 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 20:45.


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