Welcome to Open Carnage

A resource for modders and technology enthusiasts; have a wander to see why we're worth the time! EST. 2012

Sign in to follow this  
Followers 0
Weyland

Toggle rprint message on and off

Hi,

 

I have a basic script below I'm using to create player commands that rprint custom messages with info/content to the console i.e Discord link, YouTube channel link

 

Would anyone be able to help embellish it so the message stays on screen until the command is executed again?

So the command essentially toggles the message on and off.

I've seen it done on a few servers, so I'm hoping one of you legends has something sitting around.

Best,
Weyland

Share this post


Link to post
Share on other sites

Members of Open Carnage never see off-site ads.

Here: 

-- Don't touch these.
api_version = "1.10.0.0"
display = {}
lines = {} 

-- Command to trigger text.
cmd = "!info"

-- line[number] = "text" .. get_var(1, "$global event variable")
-- or
-- line[number] = "text"
lines[1] = "This is line 1"
lines[2] = "This is line 2"
-- Add more lines as needed

function OnScriptLoad()
	register_callback(cb['EVENT_COMMAND'], "OnEventCommand")
	register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
	register_callback(cb['EVENT_TICK'], "OnEventTick")
end

function OnEventCommand(PlayerIndex, Command, Enviroment, Password)
	-- Lets get quotation marks out of our commands.
	local Command = string.lower(string.gsub(Command, '"', ""))
	if Command == cmd then
		-- If they are already set to true then set to false.
		if display[tonumber(PlayerIndex)] then 
			display[tonumber(PlayerIndex)] = false
		else -- If they are not true then set to true
			display[tonumber(PlayerIndex)] = true
		end
		return false
	end
end

function OnPlayerJoin(PlayerIndex)
	-- Make sure the default is for this to be truned off.
	-- Also makes it so the last player in this slot's setting does not carry over.
	display[tonumber(PlayerIndex)] = false
end

function OnEventTick()
	for i = 1,16 do
		-- Check if the player is in the server.
		if player_present(i) then
			-- If they want the display then.
			if display[i] then
				-- Spam 26 blank lines (to clear console for ENG and ESP clients.)
				for j = 0,25 do rprint(i, " ") end 
				-- Print info from all the lines (in order) to the player.
				for x = 1,#lines do
					rprint(i, lines[x])
				end
			end
		end
	end
end

function OnScriptUnload()	end	

 

Edited by Devieth
api_version = "1.10.0.0"

Share this post


Link to post
Share on other sites

Thanks!

 

Unfortunately I'm not able to get this working.

 

The script itself isn't loading.

Any ideas or suggestions would be much appreciated.

Share this post


Link to post
Share on other sites
18 hours ago, Weyland said:

Thanks @Devieth

 

Unfortunately I'm not able to get this working.

 

The script itself isn't loading.

Any ideas or suggestions would be much appreciated.

Try it now (updated to api_version = "1.10.0.0")

Share this post


Link to post
Share on other sites
On 12/8/2018 at 1:39 AM, Weyland said:

Thanks for replying - added that change but it's still not initialising or loading unfortunately.

Try again, changed something, you cant use "get_var()" the way i did.

Share this post


Link to post
Share on other sites
On 12/13/2018 at 4:55 AM, Devieth said:

Try again, changed something, you cant use "get_var()" the way i did.

 

Hi,

 

Sorry, still not happening.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0
  • Recently Browsing   0 members

    No registered users viewing this page.