Jump to content

[HELP] Serverside bindkey to open clientside gui


Sande

Recommended Posts

Im trying to make a bindKey in serverside what opening the gui in clientside. But the key is not going to binded at it says bad argument.

Serverside:

  
function openGUI(thePlayer) 
    if getAccountData (thePlayer, "viplevel", 1 ) == true then 
    triggerClientEvent(thePlayer, "openVpanel1", thePlayer ) 
    else 
    outputChatBox("[VIP] You dont have permission to open vip-panel (1)", thePlayer, 255,0,0) 
    end 
    end 
  
function bind() 
bindKey( "F7", "down", openGUI ) 
end 
addEventHandler("onResourceStart", getRootElement(), bind ) 
  

Clientside

  
function openPanel ( ) 
            local state = guiGetVisible ( vipGUI [ "window" ] ) 
            guiSetVisible ( vipGUI [ "window" ], not state ) 
            showCursor ( not state ) 
                end 
                addEvent( "openVpanel1", true ) 
                addEventHandler( "openVpanel1", getLocalPlayer(), openPanel ) 

Link to comment

server-side

function openGUI ( thePlayer ) 
    if ( getAccountData ( thePlayer, "viplevel" ) == "1" ) then 
        triggerClientEvent ( thePlayer, "openVpanel1", thePlayer ) 
    else 
        outputChatBox ( "[VIP] You dont have permission to open vip-panel (1)", thePlayer, 255, 0, 0 ) 
    end 
end 
  
function bind ( ) 
    bindKey ( source, "F7", "down", openGUI ) 
end 
addEventHandler ( "onPlayerJoin", root, bind ) 

Edited by Guest
Link to comment

Can you help me with this:

  
function givePermission (thePlayer, command, target ) 
     local playeraccount = getPlayerAccount ( target ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
    local viplevel = 1 
    setAccountData(playeraccount, "viplevel", viplevel ) 
    outputChatBox("[VIP-Management] VIP annettu pelaajalle "..getPlayerName(target).." onnistuneesti.", thePlayer, 0,255,0) 
    else  
    outputChatBox("[VIP-Management] Error.", thePlayer, 255,0,0) 
    end 
    end 
addCommandHandler("viplevel-1", givePermission ) 

I cant set someplayer account data idk why. it goes to else message.

Link to comment

Try this:

function givePermission ( thePlayer, command, target ) 
    if ( target ) and ( getPlayerFromName ( target ) ) then 
        target = getPlayerFromName ( target ) 
    end 
    local playeraccount = getPlayerAccount ( target ) 
    if ( not isGuestAccount ( playeraccount ) ) then 
        local viplevel = "1" 
        setAccountData ( playeraccount, "viplevel", viplevel ) 
        outputChatBox("[VIP-Management] VIP annettu pelaajalle " .. getPlayerName ( target ) .. " onnistuneesti.", thePlayer, 0, 255, 0) 
    else 
        outputChatBox ( "[VIP-Management] Error.", thePlayer, 255, 0, 0 ) 
    end 
end 
addCommandHandler ( "viplevel-1", givePermission ) 

edit:

Glad to hear that.

(P.S. you can take the above code anytime you want)

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