Jump to content

Server side command open a client side window


..:D&G:..

Recommended Posts

Hey, I just made a window and I need to open it when I trigger a command in server side.

function menuShow () 
    visableornot = guiGetVisible (DXgui.fereastra[1]) 
    if (visableornot == true) then 
        guiSetVisible (DXgui.fereastra[1], false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (DXgui.fereastra[1], true) 
        showCursor (true) 
    end 
end 

I know I need to use triggerClientEvent but I don't know how to make the line...

Link to comment

try

  
function menuShow () 
    visableornot = guiGetVisible (DXgui.fereastra[1]) 
    if (visableornot == true) then 
        guiSetVisible (DXgui.fereastra[1], false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (DXgui.fereastra[1], true) 
        showCursor (true) 
    end 
end 
addEvent("SeeGui",true) 
addEventHandler("SeeGui",root,menuShow) 
  
-- server 
  
function open(P) 
triggerClientEvent(P,"SeeGui"P) 
end 
addCommandHandler("gui",open) 

Link to comment

Thanks!

There is a problem, when the resource starts the gui appears.

Also when I write the command /stats the gui appears but only the gui, the closing button, the copyright and the logo appears, but he writing (stats) doesn't not appear. Also when I press the closing button, the gui closes but the button doesn't not disappear.

DXgui = { 
    fereastra = {}, 
    copyright = {}, 
    linie = {}, 
    nume = {}, 
    status = {}, 
    buton = {}, 
    skin = {}, 
    logowg = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        DXgui.buton[1] = guiCreateButton(907, 109, 29, 25, "X", false, DXgui.fereastra[1]) 
        guiSetFont(DXgui.buton[1], "default-bold-small") 
  
  
        DXgui.fereastra[1] = guiCreateStaticImage(323, 139, 614, 338, "imagini/fereastra.png", false) 
        guiSetAlpha(DXgui.fereastra[1], 0.80) 
  
        DXgui.linie[1] = guiCreateStaticImage(0, 53, 613, 3, "imagini/linie.png", false, DXgui.fereastra[1]) 
        guiSetAlpha(DXgui.linie[1], 0.80) 
        DXgui.logowg[1] = guiCreateStaticImage(572, 301, 42, 36, "imagini/wg.png", false, DXgui.fereastra[1]) 
        guiSetAlpha(DXgui.logowg[1], 0.79) 
        DXgui.copyright[1] = guiCreateLabel(391, 323, 181, 15, "Copyright © România World Gaming - D&G", false, DXgui.fereastra[1]) 
        guiSetFont(DXgui.copyright[1], "default-small") 
        guiLabelSetHorizontalAlign(DXgui.copyright[1], "right", false) 
        guiLabelSetVerticalAlign(DXgui.copyright[1], "center") 
        DXgui.status[1] = guiCreateLabel(4, 85, 606, 145, "Numar Telefon: " .. getElementData(thePlayer, "cellnumber") .. "\nPermis de Conducere: " .. carlicense .. "\nPort Arma: " .. gunlicense .. "\nVehicule (" .. numcars .. "): " .. string.sub(carids, 1, string.len(carids)-2).. "\nProprietati (" .. numproperties .. "): " .. string.sub(properties, 1, string.len(properties)-2) .. "\nOre jucate pe caracter: " .. hoursplayed .. " ora/e\nLimbi Vorbite: " .. table.concat(languages, ", ") .. "\nNumar de Securitate: ".. finalstring .."", false, DXgui.fereastra[1]) 
        local font_0 = guiCreateFont("font/ariblk.ttf") 
        guiSetFont(DXgui.status[1], font_0) 
        DXgui.nume[1] = guiCreateLabel(0, 1, 613, 52, "~-~ ~-~", false, DXgui.fereastra[1]) 
        guiSetFont(DXgui.nume[1], "sa-header") 
        guiLabelSetHorizontalAlign(DXgui.nume[1], "center", false) 
        DXgui.skin[1] = guiCreateStaticImage(143, 241, 92, 87, ":account-system/img/000.png", false, DXgui.fereastra[1])   
    end 
) 
  
function menuShow () 
    visableornot = guiGetVisible (DXgui.fereastra[1]) 
    if (visableornot == true) then 
        guiSetVisible (DXgui.fereastra[1], false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (DXgui.fereastra[1], true) 
        showCursor (true) 
    end 
end 
addEvent("showPlayerStats",true) 
addEventHandler("showPlayerStats",root,menuShow) 
  
addEventHandler("onClientGUIClick", root, 
    function() 
        if ( source == DXgui.buton[1] ) then 
        guiSetVisible(DXgui.fereastra[1], false) 
        showCursor(false) 
    end 
end 
) 

Also when I start the resource I get this erros: ERROR: chat\c_stats.lua:28 bad argument #1 to 'len' (string expected, got nil)

Link to comment
  
-- server 
  
function open(P) 
triggerClientEvent(P,"SeeGui"P) 
end 
addCommandHandler("gui",open) 

Should Be

  
-- server 
  
function open(P) 
triggerClientEvent(P,"SeeGui",P) 
end 
addCommandHandler("gui",open) 

And the reason why you are getting that error is because

string.len(properties) 

should be

string.len("properties") 

since it's a string

Link to comment

Same error...

DXgui = { 
    fereastra = {}, 
    copyright = {}, 
    linie = {}, 
    nume = {}, 
    status = {}, 
    buton = {}, 
    skin = {}, 
    logowg = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        DXgui.buton[1] = guiCreateButton(907, 109, 29, 25, "X", false, DXgui.fereastra[1]) 
        guiSetFont(DXgui.buton[1], "default-bold-small") 
  
  
        DXgui.fereastra[1] = guiCreateStaticImage(323, 139, 614, 338, "imagini/fereastra.png", false) 
        guiSetAlpha(DXgui.fereastra[1], 0.80) 
  
        DXgui.linie[1] = guiCreateStaticImage(0, 53, 613, 3, "imagini/linie.png", false, DXgui.fereastra[1]) 
        guiSetAlpha(DXgui.linie[1], 0.80) 
        DXgui.logowg[1] = guiCreateStaticImage(572, 301, 42, 36, "imagini/wg.png", false, DXgui.fereastra[1]) 
        guiSetAlpha(DXgui.logowg[1], 0.79) 
        DXgui.copyright[1] = guiCreateLabel(391, 323, 181, 15, "Copyright © România World Gaming - D&G", false, DXgui.fereastra[1]) 
        guiSetFont(DXgui.copyright[1], "default-small") 
        guiLabelSetHorizontalAlign(DXgui.copyright[1], "right", false) 
        guiLabelSetVerticalAlign(DXgui.copyright[1], "center") 
        DXgui.status[1] = guiCreateLabel(4, 85, 606, 145, "Numar Telefon: " .. getElementData(thePlayer, "cellnumber") .. "\nPermis de Conducere: " .. carlicense .. "\nPort Arma: " .. gunlicense .. "\nVehicule (" .. numcars .. "): " .. string.sub(carids, 1, string.len(carids)-2).. "\nProprietati (" .. numproperties .. "): " .. string.sub(properties, 1, string.len("properties")-2) .. "\nOre jucate pe caracter: " .. hoursplayed .. " ora/e\nLimbi Vorbite: " .. table.concat(languages, ", ") .. "\nNumar de Securitate: ".. finalstring .."", false, DXgui.fereastra[1]) 
        local font_0 = guiCreateFont("font/ariblk.ttf") 
        guiSetFont(DXgui.status[1], font_0) 
        DXgui.nume[1] = guiCreateLabel(0, 1, 613, 52, "~-~ ~-~", false, DXgui.fereastra[1]) 
        guiSetFont(DXgui.nume[1], "sa-header") 
        guiLabelSetHorizontalAlign(DXgui.nume[1], "center", false) 
        DXgui.skin[1] = guiCreateStaticImage(143, 241, 92, 87, ":account-system/img/000.png", false, DXgui.fereastra[1])   
    end 
) 
  
function menuShow () 
    visableornot = guiGetVisible (DXgui.fereastra[1]) 
    if (visableornot == true) then 
        guiSetVisible (DXgui.fereastra[1], false) 
        showCursor (false) 
    end 
    if (visableornot == false) then 
        guiSetVisible (DXgui.fereastra[1], true) 
        showCursor (true) 
    end 
end 
addEvent("showPlayerStats",true) 
addEventHandler("showPlayerStats",root,menuShow) 
  
addEventHandler("onClientGUIClick", root, 
    function() 
        if ( source == DXgui.buton[1] ) then 
        guiSetVisible(DXgui.fereastra[1], false) 
        showCursor(false) 
    end 
end 
) 
  
  

This part was in a server side file saying the info in the chat box.

  DXgui.status[1] = guiCreateLabel(4, 85, 606, 145, "Numar Telefon: " .. getElementData(thePlayer, "cellnumber") .. "\nPermis de Conducere: " .. carlicense .. "\nPort Arma: " .. gunlicense .. "\nVehicule (" .. numcars .. "): " .. string.sub(carids, 1, string.len(carids)-2).. "\nProprietati (" .. numproperties .. "): " .. string.sub(properties, 1, string.len("properties")-2) .. "\nOre jucate pe caracter: " .. hoursplayed .. " ora/e\nLimbi Vorbite: " .. table.concat(languages, ", ") .. "\nNumar de Securitate: ".. finalstring .."", false, DXgui.fereastra[1]) 

Link to comment

[quote name=..:D&G:..]Same error...

  DXgui.status[1] = guiCreateLabel(4, 85, 606, 145, "Numar Telefon: " .. getElementData(thePlayer, "cellnumber") .. "\nPermis de Conducere: " .. carlicense .. "\nPort Arma: " .. gunlicense .. "\nVehicule (" .. numcars .. "): " .. string.sub(carids, 1, string.len(carids)-2).. "\nProprietati (" .. numproperties .. "): " .. string.sub(properties, 1, string.len("properties")-2) .. "\nOre jucate pe caracter: " .. hoursplayed .. " ora/e\nLimbi Vorbite: " .. table.concat(languages, ", ") .. "\nNumar de Securitate: ".. finalstring .."", false, DXgui.fereastra[1]) 

Should be

DXgui.status[1] = guiCreateLabel(4, 85, 606, 145, "Numar Telefon: " .. getElementData(thePlayer, "cellnumber") .. "\nPermis de Conducere: " .. carlicense .. "\nPort Arma: " .. gunlicense .. "\nVehicule (" .. numcars .. "): " .. string.sub("carids", 1, string.len("carids")-2).. "\nProprietati (" .. numproperties .. "): " .. string.sub("properties", 1, string.len("properties")-2) .. "\nOre jucate pe caracter: " .. hoursplayed .. " ora/e\nLimbi Vorbite: " .. table.concat(languages, ", ") .. "\nNumar de Securitate: ".. finalstring .."", false, DXgui.fereastra[1]) 

Anywhere you're writing a string it has to be inside quotes (" ")

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