koragg

[HELP] Trouble removing all hardcoded messages

Recommended Posts

A few pages back I saw a way to remove MTA's hardcoded messages like "login: ", "logout: " etc. when the player logs in/out, But the only one which gets removed is the one when the player logs in, the others still show up somehow although I've included them to be removed:

function removeLoginText(text)
    if text == "login: You successfully logged in" or text == "login: You are already logged in" or text == "logout: You logged out" then
        cancelEvent()
    end
end
addEventHandler("onClientChatMessage", root, removeLoginText)

Just the "login: You successfully logged in" one gets disabled but the other two still show up. Why? Any way to remove them as well?

I tried making different functions for each of them but still the same.

Edited by koragg
  • Like 1

Share this post


Link to post
function removeLoginText(text)
    if text:lower():find('login:') or text:lower():find('logout:') then
      cancelEvent()
    end
end
addEventHandler("onClientChatMessage", root, removeLoginText)

Try that, there might be a space or something in the text, so they are not actually the same.

  • Like 1

Share this post


Link to post

Worked, thanks. Also any way to check if the account to which I'm trying to login is already used by me? I mean, now the "login: You are already logged in" message doesn't show up and I wanna make a custom one when I am logged in but still try to login with the same credentials without logging out first. I tried this but didn't work (no errors as well):

function onPlayerAlreadyLoggedIn(previousAccount, newAccount)
	if previousAccount == newAccount then
		outputChatBox("#0000FF* #FFFFFFYou've already logged in to #00FFFF"..getAccountName(previousAccount).."#FFFFFF's account!", source, 255, 255, 255, true)
	end
end
addEventHandler("onPlayerLogin", root, onPlayerAlreadyLoggedIn)

 

Share this post


Link to post
function removeLoginText(text)
  if text:lower():find('login:') or text:lower():find('logout:') then
    cancelEvent()
  else
    return
  end
  if text:lower():find("already logged in") then
    outputChatBox() -- your own message
  elseif text:lower():find("something else") then
    somethingElse()
  end
end
addEventHandler("onClientChatMessage", root, removeLoginText)

I think this would be the simplest way around it.

  • Like 1

Share this post


Link to post

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.