VenomOG Posted August 27, 2019 Share Posted August 27, 2019 Hello so heres the codes SERVER local TitlesTable = { } function getTitlesTable() return TitlesTable end CLIENT THAT IS CALLING EXPORT for i, k in ipairs(exports.HIDDEN:getTitlesTable()) do dxDrawRelativeRectangle(598, 219+i*30, 296, 30, isMouseInPosition((598/resolutionX )*sWidth,((219+i*30)/resolutionY )*sHeight, (219/resolutionX )*sWidth, (32/resolutionY )*sHeight) and tocolor(255, 255, 255, 158) or tocolor(0, 0, 0, 158)) dxDrawRelativeText(k[1], 701, 200+i*30, 785+40, 239+(i+1)*30, tocolor(255, 255, 255, 255), 0.40, dxfont5_bebas_font, "left", "center") end META <meta> <info author="Hidden" name="Titles" type="script" version="1.1.0" description="Hidden Titles" /> <script src="client.Lua" type="client"/> <script src="server.Lua" type="server"/> <file src="fonts/font.ttf"/> <export function="createTitle" type="server" /> <export function="equipCT" type="client" /> <export function="getTitlesTable" type="server" /> </meta> So it gives me an error Quote failed to call 'HIDDEN:getTitlesTable' [string "?"] Any suggestions? Link to comment
nxFairlywell Posted August 27, 2019 Share Posted August 27, 2019 (edited) first of all make sure getTitlesTable() is a client side function because you exported it as "server" side in meta.xml file.. server side functions unusable for client side after that make sure you have started HIDDEN resource.. if that didn't help you , delete this from loop : exports.HIDDEN:getTitlesTable() and add this : exports['HIDDEN']:getTitlesTable() sometimes first way not works.. Edited August 27, 2019 by NX_CI Link to comment
Simple0x47 Posted August 27, 2019 Share Posted August 27, 2019 40 minutes ago, Network said: Hello so heres the codes SERVER local TitlesTable = { } function getTitlesTable() return TitlesTable end CLIENT THAT IS CALLING EXPORT for i, k in ipairs(exports.HIDDEN:getTitlesTable()) do dxDrawRelativeRectangle(598, 219+i*30, 296, 30, isMouseInPosition((598/resolutionX )*sWidth,((219+i*30)/resolutionY )*sHeight, (219/resolutionX )*sWidth, (32/resolutionY )*sHeight) and tocolor(255, 255, 255, 158) or tocolor(0, 0, 0, 158)) dxDrawRelativeText(k[1], 701, 200+i*30, 785+40, 239+(i+1)*30, tocolor(255, 255, 255, 255), 0.40, dxfont5_bebas_font, "left", "center") end META <meta> <info author="Hidden" name="Titles" type="script" version="1.1.0" description="Hidden Titles" /> <script src="client.Lua" type="client"/> <script src="server.Lua" type="server"/> <file src="fonts/font.ttf"/> <export function="createTitle" type="server" /> <export function="equipCT" type="client" /> <export function="getTitlesTable" type="server" /> </meta> So it gives me an error Any suggestions? You should make use of events, because you are unable to define the export for client-side when your function is being defined on server-side. If you want to stick with functions just create a function on client-side to retrieve the table from the server and then return the value. Link to comment
VenomOG Posted August 27, 2019 Author Share Posted August 27, 2019 Um example please. Just now, Simple0x47 said: You should make use of events, because you are unable to define the export for client-side when your function is being defined on server-side. If you want to stick with functions just create a function on client-side to retrieve the table from the server and then return the value. Link to comment
#\_oskar_/# Posted August 27, 2019 Share Posted August 27, 2019 TitlesTable = {} function getTitlesTable(text) table.insert(TitlesTable, {text=text or ''}) end addEvent("get:TitlesTable",true) addEventHandler("get:TitlesTable",root,getTitlesTable) addEventHandler("onClientRender",root,function () for i, k in ipairs(TitlesTable) do dxDrawRelativeRectangle(598, 219+i*30, 296, 30, isMouseInPosition((598/resolutionX )*sWidth,((219+i*30)/resolutionY )*sHeight, (219/resolutionX )*sWidth, (32/resolutionY )*sHeight) and tocolor(255, 255, 255, 158) or tocolor(0, 0, 0, 158)) dxDrawRelativeText(k.text, 701, 200+i*30, 785+40, 239+(i+1)*30, tocolor(255, 255, 255, 255), 0.40, dxfont5_bebas_font, "left", "center") end end) function getTitlesTable(text,to) return triggerClientEvent (to,'get:TitlesTable',root,text) end Meta.xml <export function="getTitlesTable" type="client" /> <export function="getTitlesTable" type="server" /> example Link to comment
Moderators IIYAMA Posted August 27, 2019 Moderators Share Posted August 27, 2019 (edited) 37 minutes ago, Network said: Um example please. Serverside is running on the server. Application (in case of a local server): Program Files (x86)\MTA San Andreas 1.5\server Clientside is running on clients/players. Application: Program Files (x86)\MTA San Andreas 1.5\Multi Theft Auto.exe Those are two very different applications. And between those two applications there is something called ping, = connection delay. Even a local server has a little bit of ping, even though it is displayed as 0. Your code does not wait for ping, it just runs until it finished all the instructions you gave it. If you want to let those two sides communicate with each other you need to use triggerEvent. See examples on these pages: From clientside to serverside: (examples included) https://wiki.multitheftauto.com/wiki/TriggerServerEvent From serverside to clientside: (examples included) https://wiki.multitheftauto.com/wiki/TriggerClientEvent Enchantment You can also use an enchantment, which I created for people that have trouble with communication between serverside and clientside. Installation Clientside addEventHandler("onClientResourceStart", resourceRoot, function () callServer( "getTitlesTable", function (TitlesTable_) -- < This is the callback function TitlesTable = TitlesTable_ end ) end) Clientside if TitlesTable then for i, k in ipairs(TitlesTable) do dxDrawRelativeRectangle(598, 219+i*30, 296, 30, isMouseInPosition((598/resolutionX )*sWidth,((219+i*30)/resolutionY )*sHeight, (219/resolutionX )*sWidth, (32/resolutionY )*sHeight) and tocolor(255, 255, 255, 158) or tocolor(0, 0, 0, 158)) dxDrawRelativeText(k[1], 701, 200+i*30, 785+40, 239+(i+1)*30, tocolor(255, 255, 255, 255), 0.40, dxfont5_bebas_font, "left", "center") end end Serverside - no changes - Documentation can be found here. Edited August 27, 2019 by IIYAMA Link to comment
VenomOG Posted August 27, 2019 Author Share Posted August 27, 2019 im calling the function from another script aka UCP script Link to comment
nxFairlywell Posted August 27, 2019 Share Posted August 27, 2019 (edited) 23 minutes ago, Network said: im calling the function from another script aka UCP script create a client side variable in AKA UCP script and get the table using triggerServerEvent then receive the table using triggerClientEvent then make the variable you've created equals received table -- client local variable; triggerServerEvent("onPlayerCallTable",localPlayer); addEvent("onClientReceivedTable",true); addEventHandler("onClientReceivedTable",root, function(TitlesTable) variable = TitlesTable; end ) function getTable() return variable; end -- server TitlesTable = {}; function getTitlesTable() return TitlesTable end addEvent("onPlayerCallTable",true) addEventHandler("onPlayerCallTable",root, function() triggerClientEvent(source,"onClientReceivedTable",source,getTitlesTable()); end ) Edited August 27, 2019 by NX_CI 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