This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

problem of color print


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dark Hacker
Junior Member
Join Date: Jun 2024
Old Today , 04:33   problem of color print
Reply With Quote #1

yes. stock codes changed to :

PHP Code:
new const teams[][] = {"""TERRORIST""CT""SPECTATOR"}

// Stock: ZP Colored Print
stock zp_colored_print(index, const text[], any:...)
{
    new 
msg[128], main_teamteam[32]
    
vformat(msgcharsmax(msg), text3)
    
    if (
containi(msg"!t") != -1)
        
team "CT"
    
else if (containi(msg"!y") != -1)
        
team "TERRORIST"
    
else if (containi(msg"!d") != -1)
        
team "SPECTATOR"
    
else
        
team "DEFAULT"
    
    
replace_all(msgcharsmax(msg), "!g""^x04")
    
replace_all(msgcharsmax(msg), "!n""^x01")
    
replace_all(msgcharsmax(msg), "!t""^x03")
    
replace_all(msgcharsmax(msg), "!y""^x03")
    
replace_all(msgcharsmax(msg), "!d""^x03")
    
    if (
index == 0)
    {
        new 
players[32], numid
            get_players
(playersnum)

            for (new 
0numi++)
            {
                
id players[i]
            
            if (
is_user_connected(id))
            {
                
main_team get_user_team(id)
                
color_selection(idMSG_ONEteam)
                
show_color_message(idMSG_ONEmsg)
                
team_info(idMSG_ONEteams[main_team])
            }
        }
    }
    else
    {
        if (
index || index get_maxplayers())
            return
        
        if (
is_user_connected(index))
        {
            
main_team get_user_team(index)
            
color_selection(indexMSG_ONEteam)
            
show_color_message(indexMSG_ONEmsg)
            
team_info(indexMSG_ONEteams[main_team])
        }
    }
}

// Stock: Color Selection
stock color_selection(indexmsg_typecolor_type[])
{
    if (
containi(color_type"CT") != -1)
        return 
team_info(indexmsg_typeteams[2])
    else if (
containi(color_type"TERRORIST") != -1)
        return 
team_info(indexmsg_typeteams[1])
    else if (
containi(color_type"SPECTATOR") != -1)
        return 
team_info(indexmsg_typeteams[3])
    
    return 
0
}

// Stock: Show Color Message
stock show_color_message(idtypemessage[])
{
    new 
bool:saytext_usedget_user_msgid_saytext
    
    
if (!saytext_used)
    {
        
get_user_msgid_saytext get_user_msgid("SayText")
        
saytext_used true
    
}
    
    
message_begin(typeget_user_msgid_saytext_id)
    
write_byte(id)
    
write_string(message)
    
message_end()
}

// Stock: Team Info
stock team_info(idtypeteam[])
{
    new 
bool:teaminfo_usedget_user_msgid_teaminfo
    
    
if (!teaminfo_used)
    {
        
get_user_msgid_teaminfo get_user_msgid("TeamInfo")
        
teaminfo_used true
    
}
    
    
message_begin(typeget_user_msgid_teaminfo_id)
    
write_byte(id)
    
write_string(team)
    
message_end()
    
    return 
1




But out of index error mostly occurs here:
PHP Code:
else
{
    if (
index || index get_maxplayers())
        return
        
    if (
is_user_connected(index))
    {
        
main_team get_user_team(index)
        
color_selection(indexMSG_ONEteam)
        
show_color_message(indexMSG_ONEmsg)
        
team_info(indexMSG_ONEteams[main_team])
    }


Specially here:

PHP Code:
if (index || index get_maxplayers())
    return
        
if (
is_user_connected(index))
{
    
main_team get_user_team(index
Dark Hacker is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old Today , 08:22   Re: problem of color print
Reply With Quote #2

Try using get_players() instead of get_maxplayers().
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Dark Hacker
Junior Member
Join Date: Jun 2024
Old Today , 08:30   Re: problem of color print
Reply With Quote #3

Quote:
Originally Posted by Napoleon_be View Post
Try using get_players() instead of get_maxplayers().
Where?

PHP Code:
// this message will be printed for all players
if (index == 0)
    {
        new 
players[32], numid
        get_players
(playersnum)
        
        for (new 
0numi++)
        {
            
id players[i]
            
            if (
is_user_connected(id))
            {
                
main_team get_user_team(id)
                
color_selection(idMSG_ONEteam)
                
show_color_message(idMSG_ONEmsg)
                
team_info(idMSG_ONEteams[main_team])
            }
        }
    }

    
// This place is special indexed player (message willn't be printed to all)
    
else
    {
        if (
index || index get_maxplayers())
            return
        
        if (
is_user_connected(index))
        {
            
main_team get_user_team(index)
            
color_selection(indexMSG_ONEteam)
            
show_color_message(indexMSG_ONEmsg)
            
team_info(indexMSG_ONEteams[main_team])
        }
    } 
Dark Hacker is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old Today , 12:52   Re: problem of color print
Reply With Quote #4

I'm surprised that this stock came from a zp
__________________
mlibre is offline
Dark Hacker
Junior Member
Join Date: Jun 2024
Old Today , 14:15   Re: problem of color print
Reply With Quote #5

Quote:
Originally Posted by mlibre View Post
I'm surprised that this stock came from a zp
this doesn't come from ZP. Only i added it to ZP mode (i made this stock for public mode)

u have no any idea? for fixing this error? .d
Dark Hacker is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old Today , 15:49   Re: problem of color print
Reply With Quote #6

The error should tell you exactly which line on which the error occurs, please tell us what line that is.

P.S. When using get_players(), all returned players are connected so you don't need to check that again.
__________________
fysiks is online now
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 16:05.


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