Jump to content

Little Help


[MTA]Weed

Recommended Posts

function toggleHatGUI()
    local accName = getAccountName(getPlayerAccount(player))
    if isObjectInACLGroup ( "user." ..accName, aclGetGroup ( "VIP") ) then
    if vip==false then vip="No" end
    if guiGetVisible(VipHats) then
        guiSetVisible(VipHats, false)
        showCursor(false)
    elseif vip=="Yes" then
        guiSetVisible(VipHats, true)
        showCursor(true)
    end

what is wrong here, anyone?

Link to comment

Where end

You need 3 end in your code

function toggleHatGUI()
    local accName = getAccountName(getPlayerAccount(player))
    if isObjectInACLGroup ( "user." ..accName, aclGetGroup ( "VIP") ) then
    if vip==false then vip="No" end
    if guiGetVisible(VipHats) then
        guiSetVisible(VipHats, false)
        showCursor(false)
    elseif vip=="Yes" then
        guiSetVisible(VipHats, true)
        showCursor(true)
    end
    end
    end

 

  • Haha 1
Link to comment
  • Moderators

As I said before, you can't use the same code on the same application! Like my words are just trash, seriously...

 


So split it in two:

 

Clientside

if not guiGetVisible(VipHats) then
	triggerServerEvent("requestOpenVIPWindow", resourceRoot)
else
  -- close the vip window...
end

 

Serverside

addEvent("requestOpenVIPWindow", true)
addEventHandler("requestOpenVIPWindow", resourceRoot,
function ()
    if isElement(client) then
      	local account = getPlayerAccount(client)
      	if account and not isGuestAccount(account) then
            local accName = getAccountName(account)
        	if isObjectInACLGroup ( "user." ..accName, aclGetGroup ( "VIP") ) then
				triggerClientEvent(client, "openVIPWindow", resourceRoot)
            end
        end
    end
end)

 

Clientside

addEvent("openVIPWindow", true)
addEventHandler("openVIPWindow", resourceRoot,
function ()
    -- open the vip window...
end)

 

Edited by IIYAMA
  • Like 1
Link to comment

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