keymetaphore Posted June 12, 2017 Posted June 12, 2017 (edited) Hey. Today I was creating a CEGUI based resource system, that would allow easier start/stop of resources. I wanted to make more features, but I won't speak about that. So, in serverside, I created a function that stores getResources() in a variable, and triggers it to client. When I loop thru the table in clientside with ipairs(), nothing happens. I tried it with outputChatBox, and nah. No errors in debugscript. -- server side addEvent("getResourcesGUI", true) function resourceGUI () resursi = getResources() triggerClientEvent(client, "openGUI", resourceRoot, resursi) end addEventHandler("getResourcesGUI", resourceRoot, resourceGUI) -- client side addEvent("openGUI", true) function init (resursi) for k, v in ipairs (resursi) do outputChatBox("hi, i spammer 100 resources") end end addEventHandler("openGUI", resourceRoot, init) Oh, and ipairs() work serverside. So, it doesn't work after passing to client. When I tried to outputChatBox the table ( know its dumb, just to check if it passed ), it shows that it tried to output table, so that's correct. And all events get passed, the serverside gets called by another function, but that's not revelant. Edited June 12, 2017 by Gourmet.
MTA Team botder Posted June 12, 2017 MTA Team Posted June 12, 2017 A resource-pointer doesn't exist on clientside - you can't send "resources" to clientside. You can send resource root elements to clientside, but these will only work if the corresponding resource is running.
Tails Posted June 13, 2017 Posted June 13, 2017 (edited) @Gourmet. When I just started scripting I wrote this. You can't send the resources but you can send the data then display that in your gui. function getResourceData() local resources = {} local res = getResources() for k, resource in ipairs(res) do if getResourceInfo(resource, "type") ~= "map" then table.insert(resources, {name=getResourceName(resource), state=getResourceState(resource)}) end end triggerClientEvent("ResourcesTable", root, resources) end addEvent("ResourceList",true) addEventHandler("ResourceList",root,getResourceData) I'm assuming that's what you want. Edited June 13, 2017 by Tails 1
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