Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-7

How can I add a CONSOLE in my game?

Asked by 10 years ago

I was wondering how I can add a console that announces a player has entered or left a game, along with it announcing when someone gets a point. I would also like it to stop a player from spamming and announce ONLY to the player that is spamming.

I would like it to say this:

When someone gets a point: [CONSOLE: (User without parenthesis) has gained (number of points)]

When someone enters: [CONSOLE: (User without parenthesis) has entered the server]

When someone leaves: [CONSOLE: (User without parenthesis) has left the server]

When someone spams (This will only appear on the spammers screen): You are submitting messages too quickly!

But the spamming message will not submit anymore messages until at least 15 seconds and will continue to repeat the spam message above every time the player sends a message and they will not be able to send another message for 15 more seconds every time they spam when punished.

PM me on R?BLOX if you need more information.

3 answers

Log in to vote
0
Answered by
Diitto 230 Moderation Voter
10 years ago

Since I am such a kind person( sarcasm intended ), I'll help you out, even though I am thoroughly annoyed by your constant capitalizing of "CONSOLE."

In my examples, ChatInterface is a table of functions for controlling the chat, and System is basically the player interaction class.

For joining and leaving,


game:service'Players'.playerAdded:connect( function(Player)--// Whenever a player joins Player:waitForChild'PlayerGui';--// Wait for their PlayerGui. System.Connect(Player);--// This function will give them a chat GUI once they have loaded into the game, and alert other processes. ChatInterface.GlobalAnnounce( '[ CONSOLE ]', '%s has joined the server.', 'Really blue', Player.Name); --// Above function alerts all players a message, which in this case would be the player leaving the game. end); game:service'Players'.playerRemoving:connect( function(Player)--// Whenever a player leaves System.Disconnect(Player,'Disconnected');--// This function removes them from the system and forcefully removes their client from the game, incase that they remove()'d their character.( anti-exploit ) If the reason was Exploit, it would ban them. end);

For earning points,

System.AwardPoints=function(Player,Points)

    local Client=System.Clients[Player.Name] 
    or System.Connect(Player);--// Gets their data in the system.

    Client:SetStats(
    'Points',
    Client:getStats('Points')+Points);--// Changes their Points stat.

    ChatInterface.GlobalAnnounce(
    '[ CONSOLE ]',
    '%s has earned %d points!',
    'New Yeller',
    {Exception=Client.Name},
    Client.Name,
    Points);--// Alerts all but the player that he/she has earned some points.

    ChatInterface.SendMessage(
    '[ CONSOLE ]',
    Client,
    'You have earned %d points!',
    'New Yeller',
    Points);--// Alerts the player that he/she earned some points.

end;

For spamming,

System.OnChatted=function(Player,Message)

    local Client=System.Clients[Player.Name] or System.Connect(Player);
    local Time,Spam=tick();--// Gets the time the message was chatted.
    if(Client.LastSpoke-Time>3)then
        Client.MessagesSpammed=Client.MessagesSpammed+1;
    else
        Client.MessagesSpammed=0;
    end;

    if(Client.MessagesSpammed>=5 and Client.MessagesSpammed<15)then--// They spammed.
            ChatInterface.SendMessage(
            '[ CONSOLE ]',
            Client,
            'Please stop spamming.'..(
                Client.MessagesSpammed<10 and''or 
                ' You have '..15-Client.MessagesSpammed..' chances left.'),
            'Really red');
            Spam=true;
    elseif(Client.MessagesSpammed>=15)then
        System.Disconnect(Client,'Spam');--// alerts all of disconnection by spam.
    end;    
    Client.LastSpoke=Time;
    if(not Spam)then--// Keeps chat free.
        ChatInterface.GlobalChat(
            string.format(
                (Client.IsAdmin and '~%s~'or''),
                Client.Name
            ),
            ChatInterface.FilterString(Message,System:playersUnder13()),--// cuss please, blocks out bad words if under13 accounts ingame.
            ChatInterface.ChatColor(Client.Name)
        );
    end;

end;

You better credit me.

0
It doesn't seem to work. hunkilicous12 2 — 10y
Ad
Log in to vote
0
Answered by 8 years ago

You can always use SetCore (http://wiki.roblox.com/index.php?title=API:Class/StarterGui/SetCore) to create a new chat message with your own custom text and style.

EXAMPLE

game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", { Text = "[CONSOLE: wravager has left the server]"; })

The code will only run n the client so you may have to make a remote event to call the function in every client.

Log in to vote
-3
Answered by 10 years ago

You clearly didn't read the rules... you are just asking for someone to do the work.It says to give snippets of code you tried..And here without any code you are asking for someone to do the work for you...But anyway if this helps can i get credit in your game?.

Maybe for When someone enters: [CONSOLE: (User without parenthesis) has entered the server] you could try the playeradded feature

local player = game.Players.LocalPlayer

game.Players.PlayerAdded:connect(function(Welcome)

function Welcome
game.Workspace.Welcome Gui:clone().Parent = player.StarterGui


for other things figure it out yourself instead of asking people to do all the work for you

Answer this question