Save messages

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

aescraft

Well-Known Member
Mar 1, 2017
295
13
0
I want to save the last 200 messages on the chat to be available for quoting.
Any ideas on how to do it?
I dont need you to do the skript, just show me how I do to create a list from a message (on chat event).

Thanks!
 
Do you wan't maybe full log or just only "200" message? If "200" message. if would harder. maybe try this code. (NOT TESTED!)

code_language.skript:
on chat:
    add message to {Logs::*}
    set {_s} to size of {Logs::*}
    if {_s} is more than or equal to 200:
        delete {Logs::1}
        loop {Logs::*}:
            add loop-value to {Logs::*}
       
command /log:
    trigger:
        loop {Logs::*}:
            log "%loop-value%" to "Chat/%now%.log"
        send "Sucessfully created a log"
        delete {Logs::*}

(I hope this won't make lagg >_<)


else

code_language.skript:
on chat:
    log "[%now%] %player% > %message%" to "Chat/%player%.log"#Player Logs (You can see... only what HE write (player)
    log "[%now%] %player% > %message%" to "Chat/Global.log"#Global Logs (You can see what all write at this time.



#Edit:
I have try... I downloaded Labymod (Because Spam bot) and tested it... bruh... sorry. but after 200 its lagging... I have no any more ideas.


nevermind. i got a ideas! :O Let's me code! :emoji_grinning:


#Double-Edit:
This works fine for me. i got no problem. but you get maybe one file with 30 lines. because one ist backup. but you can use the backup (I have tested with 10 line)

code_language.skript:
on chat:
    if {Bla} is not set:
        set {Bla} to 0
    add message to {Logs.%{Bla}%::*}
    add 1 to {Counter}
    if {Counter} is more than or equal to 10:#here can you increase
        if {Bla} is 0:
            add 1 to {Bla}
            delete {Logs.1::*}
        else:
            set {Bla} to 0
            delete {Logs.0::*}
        set {Counter} to 0
        
command /log [<text>]:
    trigger:
        if arg-1 is not set:
            loop {Logs.%{Bla}%::*}:
                log "%loop-value%" to "Chat/Somethingsyourname.log"
            send "Sucessfully created a log"
        else:
            if {Bla} is 0:
                set {_a} to 1
            else:
                set {_a} to 0
            loop {Logs.%{_a}%::*}:
                log "%loop-value%" to "Chat/Somethingsyournamebackup.log"
            send "Scuessfully create a BACKUP log"





upload_2017-3-25_4-26-32.png
 
Last edited by a moderator:
I'll show you what I am doing exactly:

This is my chat now:

code_language.skript:
on chat:
  add 1 to {message.counter}
  set message to "§7>>%{message.counter}%&r %message%"

The message, in game, is displayed like this:

<playername> : >>1234 MESSAGE

Every message add 1 to the message counter, and the counter is showed at the message itself.

I want the others players to be able to quote players within the 200 last messages by using this:

code_language.skript:
on chat:
  if message starts with ">>":
    replace ">>" with "/quote "

command /quote <integer> <text>
  trigger:
    if arg 1 is integer:
      make player say "%{Logs::%arg 1%}% %arg 2%"

on chat:
    add message to {Logs::*}
    set {_s} to size of {Logs::*}
    if {_s} is more than or equal to 200:
        delete {Logs::1}
        loop {Logs::*}:
            add loop-value to {Logs::*}

So, when a player says ">>1234 what you said was stupid", the skript would replace the ">>" with "/quote ", and it would execute the "/quote 1234" command instead of the message.

The /quote command would then say again the message number 1234 and add the "what you said was stupid" at the end.

If the message 1234 was "Hillary will win", then by saying ">>1234 what you said was stupid" in chat, the result would be the player quoting and repeating the "Hillary will win" and adding the message said itself "what you said was stupid"

The final result would be "<Player>: Hillary will win what you said was stupid"

Gotta test it now.
[doublepost=1490412119,1490411643][/doublepost]I think this will work:

code_language.skript:
on chat:
  if message starts with ">>":
    replace ">>" with "/quote "

command /quote <integer> <text>
  trigger:
    if arg 1 is integer:
      make player say "%{Logs::%arg 1%}% %arg 2%"

on chat:
  add 1 to {message.counter}
  set message to "§7>>%{message.counter}%&r %message%"
  add message to {Logs::%{message.counter}%}
  set {_s} to size of {Logs::*}
  if {_s} is more than or equal to 200:
    delete {Logs::%{message.counter} - 200%}
 
i don't understand really. Your code will be ifinity loop. because you are sending a Chat message. then you would check at start the ">>" if exist. then he would say this chat again. and check again if ">>" exist.... so ifinite loop like i did.


upload_2017-3-25_4-44-1.png
 
i don't understand really. Your code will be ifinity loop. because you are sending a Chat message. then you would check at start the ">>" if exist. then he would say this chat again. and check again if ">>" exist.... so ifinite loop like i did.


View attachment 512
I can change from

set message to "§7>>%{message.counter}%&r %message%

To

set message to "§7no.%{message.counter}%&r %message%

So instead of:

<player> : >>1234 MESSAGE

would be:

<player>: no.1234 MESSAGE

That should stop the loop infinity.
[doublepost=1490416537,1490416277][/doublepost]Also, dont make the variables player based. I want to save the last 200 messages in the server, not the 200 last messages from each player.
[doublepost=1490416638][/doublepost]You say 200 is lag, can we use YAML writing to be available at yaml instead of list?
 
Status
Not open for further replies.