Jump to content

Premium Panel


SnoopCat

Recommended Posts

hello i have a Gui that i want to make it open only for a specific Group in acl How i can do this??? there is the Gui code and also i tried to make it open whit M button but it doesnt work :S

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
  
GUIEditor_Window[1] = guiCreateWindow(244,192,289,309,"Panel Miembros Que Pagan",false) 
GUIEditor_Button[1] = guiCreateButton(73,31,124,39,"Repair",false,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(72,83,129,38,"Flip",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(71,140,124,39,"Get Nitro",false,GUIEditor_Window[1]) 
GUIEditor_Button[4] = guiCreateButton(19,275,237,25,"Close [M]",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(11,199,266,17,"Todo En este panel No tiene Costo Para Ti.",false,GUIEditor_Window[1]) 
GUIEditor_Label[2] = guiCreateLabel(64,220,166,43,"premium!",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,0,0,0) 
guiSetFont(GUIEditor_Label[2],"sa-gothic") 
  
bindKey("m", "down", function () guiSetVisible ( GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) showCursor(not isCursorShowing()) end) 
  
addEventHandler("onClientGUIClick",getRootElement(), 
function () 
if (source == GUIEditor_Button[4]) then 
guiSetVisible ( GUIEditor_Window[1], false ) 
showCursor(false) 
   end 
end 

Link to comment

Try this

  
function showTheGUI (key,keySate)  
if isObjectInACLGroup (source,aclGetGroup("Admin")) then 
if guiGetVisible (GUIEditor_Window[1]) == false then 
      guiSetVisible ( GUIEditor_Window[1],true)  
      showCursor (true)  
else 
      guiSetVisible ( GUIEditor_Window[1],false)  
      showCursor (false)  
end 
      else outputChatBox ("You Are not admin") 
      end 
end 
bindKey ("m","down",showTheGUI) 
  

Im not sure if it works :/

Link to comment

Did you replace this:

  
bindKey("m", "down", function () guiSetVisible ( GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) showCursor(not isCursorShowing()) end) 
  

for this

  
function showTheGUI (key,keySate) 
if isObjectInACLGroup (source,aclGetGroup("Admin")) then 
if guiGetVisible (GUIEditor_Window[1]) == false then 
      guiSetVisible ( GUIEditor_Window[1],true) 
      showCursor (true) 
else 
      guiSetVisible ( GUIEditor_Window[1],false) 
      showCursor (false) 
end 
      else outputChatBox ("You Are not admin") 
      end 
end 
bindKey ("m","down",showTheGUI) 
  

Link to comment
  
function showTheGUI (key,keySate) 
if isObjectInACLGroup (source,aclGetGroup("Admin")) then -- isObjectInACLGroup -> Only server side function. 
if guiGetVisible (GUIEditor_Window[1]) == false then 
      guiSetVisible ( GUIEditor_Window[1],true) 
      showCursor (true) 
else 
      guiSetVisible ( GUIEditor_Window[1],false) 
      showCursor (false) 
end 
      else outputChatBox ("You Are not admin") 
      end 
end 
bindKey ("m","down",showTheGUI) 
  

So, we have to do some check's in server side, and then trigger client side event to open gui.

-- Server side

function onPlayerLogin () 
    if isObjectInACLGroup (source,aclGetGroup("Admin")) then 
    bindKey ( source, "m, "down", showWindow ) 
    end 
end 
addEventHandler ( "onPlayerLogin", getRootElement(), onPlayerLogin ) 
  
function showWindow () 
  triggerClientEvent ( thePlayer, "showWindowClientSide", thePlayer ) 
end 
  
 

-- Client Side

function showWindowClientSide() 
  if guiGetVisible (GUIEditor_Window[1]) == false then 
      guiSetVisible ( GUIEditor_Window[1],true) 
      showCursor (true) 
else 
      guiSetVisible ( GUIEditor_Window[1],false) 
      showCursor (false) 
  end 
end 
addEvent ( "showWindowClientSide", true ) 
addEventHandler ( "showWindowClientSide", getRootElement(), showWindowClientSide )  

Next time use /debugscript 3 <-- That was should output error isObjectInACLGroup ( a nil value ).

Hope it works ;)

Link to comment

cow im having same problem as first try i see gui but i cant close it and it apears when i join the server :S and also i get an error saying :

[09:55:45] SCRIPT ERROR: Ppanel\GuiS.lua:3: ')' expected near 'down' 
[09:55:45] WARNING: Loading script failed: Ppanel\GuiS.lua:3: ')' expected near 
'down' 

Link to comment

Ok, i missed one "

-- Server side

function onPlayerLogin () 
    if isObjectInACLGroup (source,aclGetGroup("Admin")) then 
    bindKey ( source, "m", "down", showWindow ) 
    end 
end 
addEventHandler ( "onPlayerLogin", getRootElement(), onPlayerLogin ) 
  
function showWindow () 
  triggerClientEvent ( thePlayer, "showWindowClientSide", thePlayer ) 
end 
  
  

-- Client Side

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
  
GUIEditor_Window[1] = guiCreateWindow(244,192,289,309,"Panel Miembros Que Pagan",false) 
GUIEditor_Button[1] = guiCreateButton(73,31,124,39,"Repair",false,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(72,83,129,38,"Flip",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(71,140,124,39,"Get Nitro",false,GUIEditor_Window[1]) 
GUIEditor_Button[4] = guiCreateButton(19,275,237,25,"Close [M]",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(11,199,266,17,"Todo En este panel No tiene Costo Para Ti.",false,GUIEditor_Window[1]) 
GUIEditor_Label[2] = guiCreateLabel(64,220,166,43,"premium!",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,0,0,0) 
guiSetFont(GUIEditor_Label[2],"sa-gothic") 
 guiSetVisible ( GUIEditor_Window[1], false ) -- You have to add that, if you dont, u will see gui everytime when script starts.. 
  
  
addEventHandler("onClientGUIClick",getRootElement(), 
function () 
if (source == GUIEditor_Button[4]) then 
guiSetVisible ( GUIEditor_Window[1], false ) 
showCursor(false) 
   end 
end 
  
function showWindowClientSide() 
  if guiGetVisible (GUIEditor_Window[1]) == false then 
      guiSetVisible ( GUIEditor_Window[1],true) 
      showCursor (true) 
else 
      guiSetVisible ( GUIEditor_Window[1],false) 
      showCursor (false) 
  end 
end 
addEvent ( "showWindowClientSide", true ) 
addEventHandler ( "showWindowClientSide", getRootElement(), showWindowClientSide )  

now should work.

Link to comment

--Client side

GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
  
GUIEditor_Window[1] = guiCreateWindow(244,192,289,309,"Panel Miembros Que Pagan",false) 
guiSetVisible ( GUIEditor_Window[1], false ) 
GUIEditor_Button[1] = guiCreateButton(73,31,124,39,"Repair",false,GUIEditor_Window[1]) 
GUIEditor_Button[2] = guiCreateButton(72,83,129,38,"Flip",false,GUIEditor_Window[1]) 
GUIEditor_Button[3] = guiCreateButton(71,140,124,39,"Get Nitro",false,GUIEditor_Window[1]) 
GUIEditor_Button[4] = guiCreateButton(19,275,237,25,"Close [M]",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(11,199,266,17,"Todo En este panel No tiene Costo Para Ti.",false,GUIEditor_Window[1]) 
GUIEditor_Label[2] = guiCreateLabel(64,220,166,43,"premium!",false,GUIEditor_Window[1]) 
guiLabelSetColor(GUIEditor_Label[2],255,0,0,0) 
guiSetFont(GUIEditor_Label[2],"sa-gothic") 
   
addEventHandler("onClientGUIClick",getRootElement(), 
function () 
if (source == GUIEditor_Button[4]) then 
guiSetVisible ( GUIEditor_Window[1], false ) 
showCursor(false) 
   end 
end) 
  
addEvent("openPremiumPanel",true) 
addEventHandler("openPremiumPanel",getRootElement(), 
function () 
guiSetVisible (GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) 
showCursor(not isCursorShowing()) 
end) 

--Server side

function showPremiumPanel(thePlayer) 
local account = getPlayerAccount(thePlayer) 
if account then 
local accountname = getAccountName(account) 
if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Sr.Admin" )) then 
    triggerClientEvent (thePlayer, "openPremiumPanel", getRootElement()) 
    else 
    outputChatBox ("Premium: Access denied", thePlayer, 255, 0, 0) 
        end 
    end 
end 
  
addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
function () 
    for index, player in ipairs ( getElementsByType ( "player" ) ) do 
    bindKey ( player, "M", "down", showPremiumPanel ) 
    end 
end) 
  
addEventHandler ( "onPlayerJoin", getRootElement(), 
function () 
    bindKey ( source, "M", "down", showPremiumPanel ) 
end) 
  
addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource() ), 
function () 
    for index, player in ipairs ( getElementsByType ( "player" ) ) do 
    unbindKey ( player, "M", "down", showPremiumPanel ) 
    end 
end) 

Works (tested).

Link to comment

it doest works solid :S it is giving me this error:

  
[20:01:02] SCRIPT ERROR: Ppanel\GuiS.lua:17: 'end' expected (to close 'function' 
 at line 14) near '<eof>' 
[20:01:02] WARNING: Loading script failed: Ppanel\GuiS.lua:17: 'end' expected (t 
o close 'function' at line 14) near '<eof>' 

Link to comment

well now i have to add functions to the gui like fixing car and droping barrel and get nitro For Free.

there is the client part i tried to made but idk how to make the server side part :S

Client side:

    GUIEditor_Window = {} 
    GUIEditor_Button = {} 
    GUIEditor_Label = {} 
      
    GUIEditor_Window[1] = guiCreateWindow(244,192,289,309,"Panel Miembros Que Pagan",false) 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    GUIEditor_Button[1] = guiCreateButton(73,31,124,39,"Repair",false,GUIEditor_Window[1]) 
    GUIEditor_Button[2] = guiCreateButton(72,83,129,38,"mine",false,GUIEditor_Window[1]) 
    GUIEditor_Button[3] = guiCreateButton(71,140,124,39,"Get Nitro",false,GUIEditor_Window[1]) 
    GUIEditor_Button[4] = guiCreateButton(19,275,237,25,"Close [M]",false,GUIEditor_Window[1]) 
    GUIEditor_Label[1] = guiCreateLabel(11,199,266,17,"Todo En este panel No tiene Costo Para Ti.",false,GUIEditor_Window[1]) 
    GUIEditor_Label[2] = guiCreateLabel(64,220,166,43,"premium!",false,GUIEditor_Window[1]) 
    guiLabelSetColor(GUIEditor_Label[2],255,0,0,0) 
    guiSetFont(GUIEditor_Label[2],"sa-gothic") 
      
    addEventHandler("onClientGUIClick",getRootElement(), 
    function () 
    if (source == GUIEditor_Button[4]) then 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    showCursor(false) 
       end 
    end) 
      
    addEvent("openPremiumPanel",true) 
    addEventHandler("openPremiumPanel",getRootElement(), 
    function () 
    guiSetVisible (GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) 
    showCursor(not isCursorShowing()) 
    end) 
  
function onGuiClick (button, state, absoluteX, absoluteY) 
if (source == GUIEditor_Button[1]) then 
    triggerServerEvent ("buyfix", getLocalPlayer()) 
elseif (source == GUIEditor_Button[3]) then 
    triggerServerEvent ("buynitro", getLocalPlayer()) 
elseif (source == GUIEditor_Button[2]) then 
    triggerServerEvent ("buymine", getLocalPlayer()) 

Server side:

    function showPremiumPanel(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if account then 
    local accountname = getAccountName(account) 
    if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "premium" )) then 
        triggerClientEvent (thePlayer, "openPremiumPanel", getRootElement()) 
        else 
        outputChatBox ("Premium: Access denied", thePlayer, 255, 0, 0) 
            end 
        end 
    end 
      
    addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
    function () 
        for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        bindKey ( player, "M", "down", showPremiumPanel ) 
        end 
    end) 
      
    addEventHandler ( "onPlayerJoin", getRootElement(), 
    function () 
        bindKey ( source, "M", "down", showPremiumPanel ) 
    end) 
      
    addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource() ), 
    function () 
        for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        unbindKey ( player, "M", "down", showPremiumPanel ) 
        end 
    end) 
  

Link to comment
GUIEditor_Window = {} 
    GUIEditor_Button = {} 
    GUIEditor_Label = {} 
      
    GUIEditor_Window[1] = guiCreateWindow(244,192,289,309,"Panel Miembros Que Pagan",false) 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    GUIEditor_Button[1] = guiCreateButton(73,31,124,39,"Repair",false,GUIEditor_Window[1]) 
    GUIEditor_Button[2] = guiCreateButton(72,83,129,38,"mine",false,GUIEditor_Window[1]) 
    GUIEditor_Button[3] = guiCreateButton(71,140,124,39,"Get Nitro",false,GUIEditor_Window[1]) 
    GUIEditor_Button[4] = guiCreateButton(19,275,237,25,"Close [M]",false,GUIEditor_Window[1]) 
    GUIEditor_Label[1] = guiCreateLabel(11,199,266,17,"Todo En este panel No tiene Costo Para Ti.",false,GUIEditor_Window[1]) 
    GUIEditor_Label[2] = guiCreateLabel(64,220,166,43,"premium!",false,GUIEditor_Window[1]) 
    guiLabelSetColor(GUIEditor_Label[2],255,0,0,0) 
    guiSetFont(GUIEditor_Label[2],"sa-gothic") 
      
    addEventHandler("onClientGUIClick",getRootElement(), 
    function () 
    if (source == GUIEditor_Button[4]) then 
    guiSetVisible ( GUIEditor_Window[1], false ) 
    showCursor(false) 
    elseif (source == GUIEditor_Button[1]) then 
    triggerServerEvent ("buyfix", getLocalPlayer()) 
    elseif (source == GUIEditor_Button[3]) then 
    triggerServerEvent ("buynitro", getLocalPlayer()) 
    elseif (source == GUIEditor_Button[2]) then 
    triggerServerEvent ("buymine", getLocalPlayer()) 
       end 
    end) 
      
    addEvent("openPremiumPanel",true) 
    addEventHandler("openPremiumPanel",getRootElement(), 
    function () 
    guiSetVisible (GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) 
    showCursor(not isCursorShowing()) 
    end) 

Link to comment

hey i tried this can any one say me why is not working and where is error?

Client:

    GUIEditor_Window = {} 
        GUIEditor_Button = {} 
        GUIEditor_Label = {} 
          
        GUIEditor_Window[1] = guiCreateWindow(244,192,289,309,"Panel Miembros Que Pagan",false) 
        guiSetVisible ( GUIEditor_Window[1], false ) 
        GUIEditor_Button[1] = guiCreateButton(73,31,124,39,"Reparar Vehiculo",false,GUIEditor_Window[1]) 
        GUIEditor_Button[2] = guiCreateButton(72,83,129,38,"Poner Bomba",false,GUIEditor_Window[1]) 
        GUIEditor_Button[3] = guiCreateButton(71,140,124,39,"Obtener nitro",false,GUIEditor_Window[1]) 
        GUIEditor_Button[4] = guiCreateButton(19,275,237,25,"cerrar [M]",false,GUIEditor_Window[1]) 
        GUIEditor_Label[1] = guiCreateLabel(11,199,266,17,"Todo En este panel No tiene Costo Para Ti.",false,GUIEditor_Window[1]) 
        GUIEditor_Label[2] = guiCreateLabel(64,220,166,43,"premium!",false,GUIEditor_Window[1]) 
        guiLabelSetColor(GUIEditor_Label[2],255,0,0,0) 
        guiSetFont(GUIEditor_Label[2],"sa-gothic") 
          
        addEventHandler("onClientGUIClick",getRootElement(), 
        function () 
        if (source == GUIEditor_Button[4]) then 
        guiSetVisible ( GUIEditor_Window[1], false ) 
        showCursor(false) 
        elseif (source == GUIEditor_Button[1]) then 
        triggerServerEvent ("buyfix", getLocalPlayer()) 
        elseif (source == GUIEditor_Button[3]) then 
        triggerServerEvent ("buynitro", getLocalPlayer()) 
        elseif (source == GUIEditor_Button[2]) then 
        triggerServerEvent ("buybomb", getLocalPlayer()) 
           end 
        end) 
          
        addEvent("openPremiumPanel",true) 
        addEventHandler("openPremiumPanel",getRootElement(), 
        function () 
        guiSetVisible (GUIEditor_Window[1], not guiGetVisible(GUIEditor_Window[1])) 
        showCursor(not isCursorShowing()) 
        end) 

Server:

    function showPremiumPanel(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if account then 
    local accountname = getAccountName(account) 
    if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "premium" )) then 
        triggerClientEvent (thePlayer, "openPremiumPanel", getRootElement()) 
        else 
        outputChatBox ("Premium: Access denied", thePlayer, 255, 0, 0) 
            end 
        end 
    end 
      
    addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
    function () 
        for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        bindKey ( player, "M", "down", showPremiumPanel ) 
        end 
    end) 
      
    addEventHandler ( "onPlayerJoin", getRootElement(), 
    function () 
        bindKey ( source, "M", "down", showPremiumPanel ) 
    end) 
      
    addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource() ), 
    function () 
        for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        unbindKey ( player, "M", "down", showPremiumPanel ) 
        end 
    end) 
     
    addEvent("buybomb", true) 
addEventHandler("buybomb", getRootElement(), 
function() 
      if 
        local x,y,z = getElementPosition( source ) 
        setTimer(function()createObject ( 1225, x, y, z, 90, 0, 0 )end,3000,1) 
        outputChatBox("*Poniendo Mina en 3 Segundos",source,0,255,0)         
        outputChatBox("*Premium: "..getPlayerName(source).." a Tirado una Mina",getRootElement(),0,255,0) 
        account = getPlayerAccount(source) 
  
    end 
) 
  
addEvent("buyfix", true) 
 addEventHandler("buyfix", getRootElement(), 
   function() 
     if isPedInVehicle(source) then 
         fixVehicle( getPedOccupiedVehicle(source) ) 
         outputChatBox("*Premium: "..getPlayerName(source).." Se ha Reparado",getRootElement(),0,255,0) 
         account = getPlayerAccount(source)  
       end 
     end 
) 
  
addEvent("buynitro", true) 
addEventHandler("buynitro", getRootElement(), 
  function() 
    if isPedInVehicle(source) then 
        addVehicleUpgrade(getPedOccupiedVehicle(source),1010) 
        outputChatBox("*Premium: "..getPlayerName(source).." Se Puso Nitro",getRootElement(),0,255,0) 
        account = getPlayerAccount(source) 
        end 
  end 
) 
  

Link to comment
   function showPremiumPanel(thePlayer) 
    local account = getPlayerAccount(thePlayer) 
    if account then 
    local accountname = getAccountName(account) 
    if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "premium" )) then 
        triggerClientEvent (thePlayer, "openPremiumPanel", getRootElement()) 
        else 
        outputChatBox ("Premium: Access denied", thePlayer, 255, 0, 0) 
            end 
        end 
    end 
      
    addEventHandler ( "onResourceStart", getResourceRootElement ( getThisResource() ), 
    function () 
        for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        bindKey ( player, "M", "down", showPremiumPanel ) 
        end 
    end) 
      
    addEventHandler ( "onPlayerJoin", getRootElement(), 
    function () 
        bindKey ( source, "M", "down", showPremiumPanel ) 
    end) 
      
    addEventHandler ( "onResourceStop", getResourceRootElement ( getThisResource() ), 
    function () 
        for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        unbindKey ( player, "M", "down", showPremiumPanel ) 
        end 
    end) 
    
addEvent("buybomb", true) 
addEventHandler("buybomb", getRootElement(), 
function() 
     if isPedInVehicle(source) then 
        local x,y,z = getElementPosition( source ) 
        setTimer(function()createObject ( 1225, x, y, z, 90, 0, 0 )end,3000,1) 
        outputChatBox("*Poniendo Mina en 3 Segundos",source,0,255,0)        
        outputChatBox("*Premium: "..getPlayerName(source).." a Tirado una Mina",getRootElement(),0,255,0) 
         end 
    end 
) 
  
addEvent("buyfix", true) 
addEventHandler("buyfix", getRootElement(), 
   function() 
     if isPedInVehicle(source) then 
         fixVehicle( getPedOccupiedVehicle(source) ) 
         outputChatBox("*Premium: "..getPlayerName(source).." Se ha Reparado",getRootElement(),0,255,0) 
       end 
     end 
) 
  
addEvent("buynitro", true) 
addEventHandler("buynitro", getRootElement(), 
  function() 
    if isPedInVehicle(source) then 
        addVehicleUpgrade(getPedOccupiedVehicle(source),1010) 
        outputChatBox("*Premium: "..getPlayerName(source).." Se Puso Nitro",getRootElement(),0,255,0) 
        end 
  end 
) 

Link to comment
  • 1 month later...

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