• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Chat Log - Array?

Status
Not open for further replies.
Level 7
Joined
Oct 20, 2010
Messages
182
Hello everyone again. Today I am attempting to create a logging system that lets you call upon call messages recently sent.

First, for some background, I have a custom chat system that prevents messages from showing up both in the bottom left and in the typical log.

I am trying to make a command that when typed will show the last 15 sent messages. I also hope to be able to add a number after the command to see previous pages (like chatlog, chatlog 1, etc). I've started my attempt at coding it by saving sent messages into an array but it's all quickly to much for me to handle and I don't know where to start with this. Any help is appreciated, thank you!

If this is confusing, please ask follow up questions. I may not be the best at explaining :)
 
Level 39
Joined
Feb 27, 2007
Messages
4,989
  • -------- in chat string "" event --------
  • Set ChatCount = ChatCount + 1
  • Set ChatString[ChatCount] = (Entered chat string)
  • -------- to print last 15 messages --------
  • For each (Integer A) from 0 to 14 do (Actions)
    • Loop - Actions
      • Game - Display to (All Players) the message ChatCount[(ChatCount - (Integer A))]
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
Might want to use a circular buffer for this. That way there is no concern for overflow and one can have access to the last N messages where N is the circular buffer size. A size of 1,000-10,000 should be fine and have no performance implications. For the last X messages one can iterate back from the head.
 
Status
Not open for further replies.
Top