Jump to content

guiSetText problem


Hero192

Recommended Posts

Posted

Hey guys, I want to set a text to a button while the player is frozen it should setText Unfreeze if not set Freeze.

I tried that , but it doesn't works like I want, I want like when you Frozen a player in Admin Panel it shows, "Freeze" / "UnFreeze".

Can anyone give me a hand?

  if (isElementFrozen(player)) then  
        guiSetText (myButton, "Unfreeze") 
    else 
        guiSetText (myButton, "Freeze") 
    end 

Thanks in advance.

Posted
Where is myButton this kinda important and show the function this code is in.

Its just a part of code

Yes I understand this is part of your code but I need to see rest of it. Where mybutton is declared and where this part of your code is compaired to your declaration.

Posted
local myButton = guiCreateButton(574, 55, 95, 20, "Freeze", false, window) 
  
addEventHandler("onClientGUIClick",guiRoot, 
function () 
    if (source == myButton) then  
        local player = getPlayerFromName(guiGridListGetItemText(grid, guiGridListGetSelectedItem(grid), 1))  
        if not player then return end  
        triggerServerEvent("freezeplayer",localPlayer) 
        if (isElementFrozen(player)) then  
            guiSetText(myButton, "Unfreeze") 
        else 
            guiSetText(myButton, "Freeze") 
        end 
    end 
end) 

Posted
local myButton = guiCreateButton (574, 55, 95, 20, "Freeze", false, window) 
  
addEventHandler("onClientGUIClick", myButton, 
function () 
        local player = getPlayerFromName(guiGridListGetItemText(grid, guiGridListGetSelectedItem(grid), 1)) 
        outputServerLog("Player name (from grid): "..guiGridListGetItemText(grid, guiGridListGetSelectedItem(grid), 1)) 
        outputServerLog("Player name: "..getPlayerName(player)) 
        if not player then return end 
        triggerServerEvent("freezeplayer",localPlayer) 
        if (isElementFrozen(player)) then 
            guiSetText(myButton, "Unfreeze") 
        else 
            guiSetText(myButton, "Freeze") 
        end 
end) 

Try this and see what I says

Posted

the grid works fine, the problem is I want do like admin panel of Lil Today, if you see the button "Freeze" if you frozen someone the button text change to freeze if the player selected is unfrozen and show unfreeze if the player who's selected is frozen.

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