..:D&G:.. Posted November 17, 2013 Share Posted November 17, 2013 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
manawydan Posted November 17, 2013 Share Posted November 17, 2013 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
..:D&G:.. Posted November 17, 2013 Author Share Posted November 17, 2013 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
Chronic Posted November 17, 2013 Share Posted November 17, 2013 -- 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
..:D&G:.. Posted November 18, 2013 Author Share Posted November 18, 2013 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
Chronic Posted November 18, 2013 Share Posted November 18, 2013 [quote name=..&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
..:D&G:.. Posted November 18, 2013 Author Share Posted November 18, 2013 Limbi Vorbite: " .. table.concat(languages, ", ") .. " Table expected, but got nil, when I add the "" to languages, it says that table expected, but got string Link to comment
Chronic Posted November 18, 2013 Share Posted November 18, 2013 Quotes are used only for strings. For this table you are trying to add, you never defined it, so put this at the top of your script. languages = {} Link to comment
..:D&G:.. Posted November 18, 2013 Author Share Posted November 18, 2013 (edited) Oh... I am going retarded, how could I forget?! Thanks! Edited November 20, 2013 by Guest Link to comment
..:D&G:.. Posted November 19, 2013 Author Share Posted November 19, 2013 Now I get another error... 30: attempt to concatenate global 'finalstring' (a nil value) All the events and functions are in a server side file. Link to comment
Chronic Posted November 19, 2013 Share Posted November 19, 2013 'finalstring' was never defined Link to comment
..:D&G:.. Posted November 19, 2013 Author Share Posted November 19, 2013 It is, but in server side.. Do I have to trigger something? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now