Jump to content

I want to make the command "/rp" like in roleplay servers. Is it possible?


bencskrisz

Recommended Posts

Hey! :) My (not so original) idea is putting this /rp command into the server (local). I want it to work like this -> If you write your IC action next to /rp in chat (for example: /rp fasten the seat belt) then it gonna appear above the player in this form -> *fasten the seat belt. So basically it would repeat the action text above the player who said it (without the "/rp"). Is it possible to script it? If it is, then can someone help me, Im kindda new in scripting. If its not possible then it would be still cool if the repeated action would appear only in the chatbox. But the best and the coolest would be if it would appear above the player.. Thank you in advance!! :) 

Link to comment

You can use a community script to get chat bubbles popping up above players, and (optionally) modify it to stop showing up normal chat messages, and use the exported functions to add bubbles for RP stuff like this /rp command.

The command implementation is easy:

addCommandHandler("rp", 
  function (player, command, ...)
    -- first, concatenate all parameters of the command (/command parameter1 parameter2 etc) into one string seperated by spaces
    local text = table.concat({...}, " ")
    
    -- make sure text was actually provided so we don't display an empty bubble
    if text and #text > 1 then
      --todo: call an export for a chat bubble to show up
      --      e.g. exports:bubblechat:outputMessage(player, "* " .. text .. " *")
      --      the above line should work with https://community.multitheftauto.com/index.php?p=resources&s=details&id=12008
      
      -- optionally, also display the text in chatbox formatted as follows: asterisk, space, player name, space, action text (e.g. "* Player_1 fastens his seatbelts")
      outputChatBox("* " .. getPlayerName(player) .. " " .. text, root, 255, 0, 255)
    end
  end
)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...