Skocz do zawartości

Nowy szablon forum

mygo.pl

Stworzyliśmy dla Was nowy wygląd forum. Z pewnością znajdziesz rzeczy, które wg Ciebie mogą zostać zmienione - wspomnij o tym w specjalnym wątku.

Czytaj więcej

Jak założyć własną sieć

serwerów CS

Zastanawiasz się nad prowadzeniem własnej sieci serwerów? Przeczytaj podstawowe informacje, na które należy zwrócić uwagę, przy takim projekcie.

Czytaj więcej

Tworzymy spis sieci

dodaj swoją

Dodaj sieć do której należysz, pozwoli to na promocję i budowę ogólnopolskiej bazy sieci CS.

Czytaj więcej

RSSproblem of color print


MYGO.pl
 Udostępnij

Rekomendowane odpowiedzi

  • RSSy
Hello everyone. I made a stock which it can show colored messages to clients. Example of Using:

Code:

zp_colored_print(0, "!y This is red text")
zp_colored_print(0, "!t This is blue text")
zp_colored_print(0, "!d This is spectator color text")
zp_colored_print(0, "!g And this is green text")


But it gives error. "Index out of bounding"
Can anyone help me please?


Code:

new const teams[][] = {"", "TERRORIST", "CT", "SPECTATOR"}

// Stock: Colored Print
stock colored_print(index, const text[], any:...)
{
        new msg[128], main_team, team[32]
        vformat(msg, charsmax(msg), text, 3)
       
        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(msg, charsmax(msg), "!g", "^x04")
        replace_all(msg, charsmax(msg), "!n", "^x01")
        replace_all(msg, charsmax(msg), "!t", "^x03")
        replace_all(msg, charsmax(msg), "!y", "^x03")
        replace_all(msg, charsmax(msg), "!d", "^x03")
       
        if (index == 0)
        {
                for (new id = -1; id <= get_maxplayers(); id++)
                {
                        if (is_user_connected(id))
                        {
                                main_team = get_user_team(id)
                                color_selection(id, MSG_ONE, team)
                                show_color_message(id, MSG_ONE, msg)
                                team_info(id, MSG_ONE, teams[main_team])
                        }
                }
        }
        else
        {
                if (index < 0 || index > get_maxplayers())
                        return
               
                if (is_user_connected(index))
                {
                        main_team = get_user_team(index)
                        color_selection(index, MSG_ONE, team)
                        show_color_message(index, MSG_ONE, msg)
                        team_info(index, MSG_ONE, teams[main_team])
                }
        }
}

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

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

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

Przeczytaj cały wpis

Odnośnik do komentarza
Udostępnij na innych stronach

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
 Udostępnij

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...