Jump to content

Adding /showchat command When you click Button


Recommended Posts

Posted

Hello, I need help with adding "showchat" which disables/enables chat. I have no idea on how to do that, i tried everything .. And I also need help with adding Speed + Big Jump if anyone knows how .... :fadein:

Skype - destroyermarc354

Ingame: [Victory]#1ERuPTiON / [xXx]#1ERuPTiON / 'kkingg'

Posted

You can't execute a MTA hardcoded command, so you have to use the function:

showCursor 

And, if you mean the bunny jump cheat from single player, then you must use the function:

setWorldSpecialPropertyEnabled 

Posted

Don't call your button showChat it could make some troubles.

  
addEventHandler("onClientGUIClick",btn_showChat, 
    function() 
        showChat(false) 
    end 
) 

Posted

That could cause problem, since you forgot to set to false the "getPropagated" argument from addEventHandler, everytime you click a GUI element, the chat will hide.

Posted
That could cause problem, since you forgot to set to false the "getPropagated" argument from addEventHandler, everytime you click a GUI element, the chat will hide.

I get bad Argument @ Showchat

Posted
Don't call your button showChat it could make some troubles.
  
addEventHandler("onClientGUIClick",btn_showChat, 
    function() 
        showChat(false) 
    end 
) 

+ I want to Trigger it Server Side

Posted
Post your complete script.

My complete script is a Shop I'm making.. But here is the showChat..

-- Client --

showChat = guiCreateButton(385, 100, 144, 25, "Show/Hide Chat", false, tab)

guiSetProperty(showChat, "CaptionColour", "FFFE0000")

guiSetProperty(showChat, "PushedTextColour", "FFFE0000")

guiSetProperty(showChat, "HoverTextColour", "FFFE0000")

guiSetProperty(showChat, "NormalTextColour", "FFFE0000")

guiSetFont(showChat, "default-bold-small")

addEventHandler("onClientGUIClick",root,function()

if ( source == showChat ) then

triggerServerEvent("showChat",localPlayer)

end

end)

-- Server --

addEvent("showChat",true)

addEventHandler("showChat",root,

function()

showChat(false)

end)

Posted

Why are you triggering to the server when you can make it client-sided?

and i said you should call your button different. This could cause some problems.

Posted

Try changing the button variable to showChatButton since it might be causing a conflict with the function showChat.

For example you can try something like this(Client Side);

function showChatOnButtonClick_Handler() 
    local chatHidden = false; 
    if(source == showChatButton and chatHidden == false) then 
        showChat(false); 
        chatHidden = true; 
    elseif(source == showChatButton and chatHidden == true) then 
        showChat(true); 
        chatHidden = false; 
    end 
end 
addEventHandler("onClientGUIClick", getRootElement(), showChatOnButtonClick_Handler) 

Posted
Try changing the button variable to showChatButton since it might be causing a conflict with the function showChat.

For example you can try something like this(Client Side);

function showChatOnButtonClick_Handler() 
    local chatHidden = false; 
    if(source == showChatButton and chatHidden == false) then 
        showChat(false); 
        chatHidden = true; 
    elseif(source == showChatButton and chatHidden == true) then 
        showChat(true); 
        chatHidden = false; 
    end 
end 
  
Thanks, But now when I click it, yes it hides the chat, but I wanted it when you click it again it will show again .. the c 
addEventHandler("onClientGUIClick", getRootElement(), showChatOnButtonClick_Handler) 

Thanks, But now when I click it, yes it hides the chat, but I wanted it when you click it again it will show again .. Doesn't work with that .

Posted

Try this instead, I messed up the logic a bit...

  
local chatHidden = false; 
  
function showChatOnButtonClick_Handler() 
    if(source == showChatButton) then 
        if(chatHidden == false) then 
            showChat(false); 
            chatHidden = true; 
        else 
            showChat(true); 
            chatHidden = false; 
        end 
    end 
end 

Posted
Try this instead, I messed up the logic a bit...
  
local chatHidden = false; 
  
function showChatOnButtonClick_Handler() 
    if(source == showChatButton) then 
        if(chatHidden == false) then 
            showChat(false); 
            chatHidden = true; 
        else 
            showChat(true); 
            chatHidden = false; 
        end 
    end 
end 

Still doesn't work :| and you forgot to add "addEventHandler("onClientGUIClick", getRootElement(), showChatOnButtonClick_Handler)" in the second one ..

Anyways, i don't know maybe I have to make separate tabs for showchat and hidechat ? because this doesn't work :|

Posted

Anyone, Help me with this, basically I want a button to click "showchat" and when you click it once, it will hide chat, click again show chat. I don't know how to do this please help :D

- skype : destroyermarc354

Posted

He told you to change your button variable name as it may conflict with the function showChat.

if ( source == showChat ) then 

if(source == showChatButton) then 

Posted
He told you to change your button variable name as it may conflict with the function showChat.
if ( source == showChat ) then 

if(source == showChatButton) then 

I know that, I said I wanted it all in one button, When you click button once it shows chat, then again hides chat

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...