Skocz do zawartości
  • 0

Liczenie wiadomości i Top


Gość kultek

Pytanie

5 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0
on load:
    set {symbol} to ": "

function createTop(t: string, i: integer) :: strings:
    set {_offlinePlayers::*} to all offline players
    loop {_offlinePlayers::*}:
        if {%{_t}%::%loop-value%} is set:
            add {%{_t}%::%loop-value%} to {_top::*}
            add loop-value to {_players::*}
    loop {_i} times:
        set {_max} to max({_top::*})
        loop {_top::*}:
            if loop-value-2 = {_max}:
                set {_index} to loop-index
                delete {_top::%{_index}%}
        add "%{_players::%{_index}%}%%{symbol}%%{_max}%" to {_return::*}
        delete {_players::%{_index}%}
    return {_return::*}

function getTop(t: string, list: strings) :: strings:
    loop {_list::*}:
        set {_split::*} to loop-value split at {symbol}
        add {_split::1} to {_players::*}
        add {_split::2} to {_top::*}
    if {_t} = "players":
        return {_players::*}
    else:
        return {_top::*}


on chat:
	if {chatCount::%player%} is not set:
		set {chatCount::%player%} to 0
	if event is not cancelled:
		add 1 to {chatCount::%player%}

command /top [<text>]:
	trigger:
		set {_lista::*} to createTop("chatCount", 10)
		loop {_lista::*}:
			send "%loop-index%. %loop-value%"

Wymaga pluginu Skript w wersji przynajmniej 2.2 dev 36

Odnośnik do komentarza
https://skript.pl/temat/34546-liczenie-wiadomo%C5%9Bci-i-top/#findComment-222174
Udostępnij na innych stronach

  • 0
on join:
	if {Messages::%player%} is not set:
		set {Messages::%player%} to 0
on chat:
	if event is not cancelled:
		add 1 to {Messages::%player%}
command /msgs:
	trigger:
		send "&7Wysłałeś &c%{Messages::%player%}% &7wiadomosci na czacie."
command /topmsgs:
	trigger:
		send "&7Top 10 osób z największą liczbą wysłanych wiadomości na czacie:"
		loop {Messages::*}:
			if loop-value is not 0:
				add loop-index to {_players::*}
		loop 10 times:
			loop {_players::*}:
				if {_top::%loop-number%} is not set:
					set {_top::%loop-number%} to loop-value-2
				else if {Messages::%loop-value-2%} is more than {Messages::%{_top::%loop-number%}%}:
					set {_top::%loop-number%} to loop-value-2
			remove {_top::%loop-number%} from {_players::*}
			if {_top::%loop-number%} is set:
				send "&c%loop-number%&7. &c%{_top::%loop-number%}% &7- &c%{Messages::%{_top::%loop-number%}%}%"
			else:
				send "&c%loop-number%&7. &cBrak danych."

 

Odnośnik do komentarza
https://skript.pl/temat/34546-liczenie-wiadomo%C5%9Bci-i-top/#findComment-222178
Udostępnij na innych stronach

  • 0
33 minuty temu, LuckyPotato napisał:

on load:
    set {symbol} to ": "

function createTop(t: string, i: integer) :: strings:
    set {_offlinePlayers::*} to all offline players
    loop {_offlinePlayers::*}:
        if {%{_t}%::%loop-value%} is set:
            add {%{_t}%::%loop-value%} to {_top::*}
            add loop-value to {_players::*}
    loop {_i} times:
        set {_max} to max({_top::*})
        loop {_top::*}:
            if loop-value-2 = {_max}:
                set {_index} to loop-index
                delete {_top::%{_index}%}
        add "%{_players::%{_index}%}%%{symbol}%%{_max}%" to {_return::*}
        delete {_players::%{_index}%}
    return {_return::*}

function getTop(t: string, list: strings) :: strings:
    loop {_list::*}:
        set {_split::*} to loop-value split at {symbol}
        add {_split::1} to {_players::*}
        add {_split::2} to {_top::*}
    if {_t} = "players":
        return {_players::*}
    else:
        return {_top::*}


on chat:
	if {chatCount::%player%} is not set:
		set {chatCount::%player%} to 0
	if event is not cancelled:
		add 1 to {chatCount::%player%}

command /top [<text>]:
	trigger:
		set {_lista::*} to createTop("chatCount", 10)
		loop {_lista::*}:
			send "%loop-index%. %loop-value%"

Wymaga pluginu Skript w wersji przynajmniej 2.2 dev 36

Mam wersję 2.2-dev36 i nie działa ;c a błędów nie ma 

Edytowane przez kultek
Odnośnik do komentarza
https://skript.pl/temat/34546-liczenie-wiadomo%C5%9Bci-i-top/#findComment-222179
Udostępnij na innych stronach

  • 0
2 minuty temu, Shooterowy napisał:

on join:
	if {Messages::%player%} is not set:
		set {Messages::%player%} to 0
on chat:
	if event is not cancelled:
		add 1 to {Messages::%player%}
command /msgs:
	trigger:
		send "&7Wysłałeś &c%{Messages::%player%}% &7wiadomosci na czacie."
command /topmsgs:
	trigger:
		send "&7Top 10 osób z największą liczbą wysłanych wiadomości na czacie:"
		loop {Messages::*}:
			if loop-value is not 0:
				add loop-index to {_players::*}
		loop 10 times:
			loop {_players::*}:
				if {_top::%loop-number%} is not set:
					set {_top::%loop-number%} to loop-value-2
				else if {Messages::%loop-value-2%} is more than {Messages::%{_top::%loop-number%}%}:
					set {_top::%loop-number%} to loop-value-2
			remove {_top::%loop-number%} from {_players::*}
			if {_top::%loop-number%} is set:
				send "&c%loop-number%&7. &c%{_top::%loop-number%}% &7- &c%{Messages::%{_top::%loop-number%}%}%"
			else:
				send "&c%loop-number%&7. &cBrak danych."

 

Działa, i /msgs i /topmsgs, dzięki za pomoc

Odnośnik do komentarza
https://skript.pl/temat/34546-liczenie-wiadomo%C5%9Bci-i-top/#findComment-222180
Udostępnij na innych stronach

Nieaktywny
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

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