Jump to content

[HELP] Gui does not open


Sande

Recommended Posts

I started to code vip-panel gui for my server. But i have problem, the check are the player vip works but when it execute a clientTriggerEvent command the panel does not open.

Serverside:

function openVIPPanel(thePlayer) 
if getAccountData(getPlayerAccount(thePlayer), "vip" ) == 1 then 
    triggerClientEvent (thePlayer, "vipPanelOpen", thePlayer) 
exports["ac-message"]:outputTopBar("VIP: Panel opened!", thePlayer,0,255,0) 
 else 
exports["ac-message"]:outputTopBar("VIP: You are not vip!", thePlayer,255,0,0) 
end 
 end 
addCommandHandler("vip", openVIPPanel ) 

Clientside:

function gui() 
        vipPanel.window[1] = guiCreateWindow(498, 140, 365, 632, "Suomisu - VIP Panel", false) 
        guiWindowSetSizable(vipPanel.window[1], false) 
        vipPanel.label[1] = guiCreateLabel(10, 24, 100, 52, "Player functions", false, vipPanel.window[1]) 
        guiSetFont(vipPanel.label[1], "default-bold-small") 
        vipPanel.label[2] = guiCreateLabel(10, 322, 102, 49, "Vehicle functions", false, vipPanel.window[1]) 
        guiSetFont(vipPanel.label[2], "default-bold-small") 
        vipPanel.button[1] = guiCreateButton(9, 76, 165, 47, "Godmode", false, vipPanel.window[1]) 
        vipPanel.button[2] = guiCreateButton(9, 133, 165, 47, "Health", false, vipPanel.window[1]) 
        vipPanel.button[3] = guiCreateButton(10, 190, 165, 47, "Random vehicle", false, vipPanel.window[1]) 
        vipPanel.button[4] = guiCreateButton(10, 255, 345, 47, "Random dailyreward", false, vipPanel.window[1]) 
        vipPanel.button[5] = guiCreateButton(191, 76, 165, 47, "Ghostmode", false, vipPanel.window[1]) 
        vipPanel.button[6] = guiCreateButton(191, 133, 165, 47, "Armor", false, vipPanel.window[1]) 
        vipPanel.button[7] = guiCreateButton(191, 190, 165, 47, "Random skin", false, vipPanel.window[1]) 
        vipPanel.button[8] = guiCreateButton(10, 377, 165, 47, "Fix", false, vipPanel.window[1]) 
        vipPanel.button[9] = guiCreateButton(190, 377, 165, 47, "Refill", false, vipPanel.window[1]) 
        vipPanel.button[10] = guiCreateButton(10, 439, 165, 47, "Destroy", false, vipPanel.window[1]) 
        vipPanel.button[11] = guiCreateButton(190, 439, 165, 47, "Random color", false, vipPanel.window[1]) 
        vipPanel.button[12] = guiCreateButton(10, 502, 165, 47, "Water cheat", false, vipPanel.window[1]) 
        vipPanel.button[13] = guiCreateButton(191, 502, 164, 47, "Fly cheat", false, vipPanel.window[1]) 
        vipPanel.button[14] = guiCreateButton(10, 566, 165, 47, "Ghostcar", false, vipPanel.window[1]) 
        vipPanel.button[15] = guiCreateButton(191, 566, 165, 47, "Spawn infernus", false, vipPanel.window[1]) 
        guiSetVisible ( vipPanel.window[1], false ) 
    end 
 addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), gui ) 
  
function show () 
    vipPanel = guiGetVisible  (vipPanel.Window[1]) 
    if (vipPanel == true) then 
        guiSetVisible  (vipPanel.Window[1], false) 
        showCursor  (false) 
    end 
    if (vipPanel == false) then 
        guiSetVisible  (vipPanel.Window[1], true) 
        showCursor  (true) 
    end 
end 
addEvent ("vipPanelOpen",true) 
addEventHandler ("vipPanelOpen",root,show) 

Link to comment

triggerClientEvent should be like this ..

triggerClientEvent ("vipPanelOpen", thePlayer) 

Replace the function show, with this

function show () 
    if ( guiGetVisible(vipPanel.Window[1]) == true ) then 
        guiSetVisible  (vipPanel.Window[1], false) 
        showCursor  (false) 
else 
        guiSetVisible  (vipPanel.Window[1], true) 
        showCursor  (true) 
    end 
end 
addEvent ("vipPanelOpen",true) 
addEventHandler ("vipPanelOpen",root,show) 

Edited by Guest
Link to comment

Server:

  
function openVIPPanel(source) 
if getAccountData(getPlayerAccount(source), "vip" ) == 1 then 
  triggerClientEvent ("vipPanelOpen", source) 
exports["ac-message"]:outputTopBar("VIP: Panel opened!", source,0,255,0) 
 else 
exports["ac-message"]:outputTopBar("VIP: You are not vip!", source,255,0,0) 
end 
 end 
addCommandHandler("vip", openVIPPanel ) 
  

Client

  
function gui() 
        vipPanel.window[1] = guiCreateWindow(498, 140, 365, 632, "Suomisu - VIP Panel", false) 
        guiWindowSetSizable(vipPanel.window[1], false) 
        vipPanel.label[1] = guiCreateLabel(10, 24, 100, 52, "Player functions", false, vipPanel.window[1]) 
        guiSetFont(vipPanel.label[1], "default-bold-small") 
        vipPanel.label[2] = guiCreateLabel(10, 322, 102, 49, "Vehicle functions", false, vipPanel.window[1]) 
        guiSetFont(vipPanel.label[2], "default-bold-small") 
        vipPanel.button[1] = guiCreateButton(9, 76, 165, 47, "Godmode", false, vipPanel.window[1]) 
        vipPanel.button[2] = guiCreateButton(9, 133, 165, 47, "Health", false, vipPanel.window[1]) 
        vipPanel.button[3] = guiCreateButton(10, 190, 165, 47, "Random vehicle", false, vipPanel.window[1]) 
        vipPanel.button[4] = guiCreateButton(10, 255, 345, 47, "Random dailyreward", false, vipPanel.window[1]) 
        vipPanel.button[5] = guiCreateButton(191, 76, 165, 47, "Ghostmode", false, vipPanel.window[1]) 
        vipPanel.button[6] = guiCreateButton(191, 133, 165, 47, "Armor", false, vipPanel.window[1]) 
        vipPanel.button[7] = guiCreateButton(191, 190, 165, 47, "Random skin", false, vipPanel.window[1]) 
        vipPanel.button[8] = guiCreateButton(10, 377, 165, 47, "Fix", false, vipPanel.window[1]) 
        vipPanel.button[9] = guiCreateButton(190, 377, 165, 47, "Refill", false, vipPanel.window[1]) 
        vipPanel.button[10] = guiCreateButton(10, 439, 165, 47, "Destroy", false, vipPanel.window[1]) 
        vipPanel.button[11] = guiCreateButton(190, 439, 165, 47, "Random color", false, vipPanel.window[1]) 
        vipPanel.button[12] = guiCreateButton(10, 502, 165, 47, "Water cheat", false, vipPanel.window[1]) 
        vipPanel.button[13] = guiCreateButton(191, 502, 164, 47, "Fly cheat", false, vipPanel.window[1]) 
        vipPanel.button[14] = guiCreateButton(10, 566, 165, 47, "Ghostcar", false, vipPanel.window[1]) 
        vipPanel.button[15] = guiCreateButton(191, 566, 165, 47, "Spawn infernus", false, vipPanel.window[1]) 
        guiSetVisible ( vipPanel.window[1], false ) 
    end 
 addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), gui ) 
  
function show () 
if guiGetVisible(vipPanel.Window[1],true) then 
guiSetVisible (vipPanel.Window[1], false) 
showCursor (false) 
else 
guiSetVisible (vipPanel.Window[1], true) 
showCursor (true) 
end 
end 
addEvent ("vipPanelOpen",true) 
addEventHandler ("vipPanelOpen",root,show) 
  

Link to comment

Put this for server ..

function openVIPPanel() 
if getAccountData(getPlayerAccount(source), "vip" ) == 1 then 
  triggerClientEvent ("vipPanelOpen", getRootElement()) 
exports["ac-message"]:outputTopBar("VIP: Panel opened!", source,0,255,0) 
 else 
exports["ac-message"]:outputTopBar("VIP: You are not vip!", source,255,0,0) 
end 
 end 
addCommandHandler("vip", openVIPPanel ) 

and for client..the function show should be like this

function show () 
    if ( guiGetVisible(vipPanel.Window[1]) == true ) then 
        guiSetVisible  (vipPanel.Window[1], false) 
        showCursor  (false) 
else 
        guiSetVisible  (vipPanel.Window[1], true) 
        showCursor  (true) 
    end 
end 
addEvent ("vipPanelOpen",true) 
addEventHandler ("vipPanelOpen",root,show) 

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