audi868 Posted September 4, 2011 Posted September 4, 2011 I want to get the name of the map for my client sided script, but it is returning nil on client Server: root = getRootElement() mapmanager = getResourceFromName("mapmanager") addEvent("getCurrentMap",true) function getCurrentMap() local name = call(mapmanager,"getRunningGamemodeMap") return name end addEventHandler("getCurrentMap",root,getCurrentMap) Client: glp = getLocalPlayer() bindKey("F3","down",function() window = {} sx,sy = guiGetScreenSize() window['main'] = guiCreateWindow((sx/2)-320,(sy/2)-240,640,480,"My window",false) window['map'] = guiCreateLabel(0.4043,0.8478,0.589,0.1425,"",true,window['main']) local currentMap = getResourceName(triggerServerEvent("getCurrentMap",glp)) guiSetText(window['map'],currentMap) end )
Castillo Posted September 4, 2011 Posted September 4, 2011 That's a mess, that'll never work that way. Server side: function getCurrentMap() local mapmanager = getResourceFromName("mapmanager") local name = call(mapmanager,"getRunningGamemodeMap") triggerClientEvent(source,"returnCurrentMap",source,name) end addEvent("getCurrentMap",true) addEventHandler("getCurrentMap",root,getCurrentMap) Client side: glp = getLocalPlayer() bindKey("F3","down",function() window = {} sx,sy = guiGetScreenSize() window['main'] = guiCreateWindow((sx/2)-320,(sy/2)-240,640,480,"My window",false) window['map'] = guiCreateLabel(0.4043,0.8478,0.589,0.1425,"",true,window['main']) triggerServerEvent("getCurrentMap",glp) end ) addEvent("returnCurrentMap",true) addEventHandler("returnCurrentMap",root, function (currentMap) guiSetText(window['map'],currentMap) end) Try it. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Castillo Posted September 4, 2011 Posted September 4, 2011 You welcome. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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