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'

n-560x95_FF6464_FFFFFF_000000_000000.png
Posted

For showchat, use the event onClientGUIClick to detect when the button is clicked. Then use executeCommandHandler.

For speed and jump you can use;

getElementVelocity 
setElementVelocity 

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
You can't execute a MTA hardcoded command

Knowledge is power ;)

Then you could just use the function showChat... :lol:

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

n-560x95_FF6464_FFFFFF_000000_000000.png
Posted

Post your complete script.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

n-560x95_FF6464_FFFFFF_000000_000000.png
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)

n-560x95_FF6464_FFFFFF_000000_000000.png
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

The error is because showChat in the server side has a player argument, and you didn't specify one.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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) 

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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 .

n-560x95_FF6464_FFFFFF_000000_000000.png
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 

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

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

n-560x95_FF6464_FFFFFF_000000_000000.png
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

n-560x95_FF6464_FFFFFF_000000_000000.png
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 

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

n-560x95_FF6464_FFFFFF_000000_000000.png

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