myyusuf Posted March 23, 2012 Share Posted March 23, 2012 server addEvent("GUIwins",true) addEventHandler("GUIwins",root,function() wins = getElementData(source,"wins") triggerClientEvent(source,"GUIwins",source,wins) end ) addEvent("GUIpoints",true) addEventHandler("GUIpoints",root,function() points = getElementData(source,"points") triggerClientEvent(source,"GUIpoints",source,points) end ) addEvent("GUIsecond",true) addEventHandler("GUIsecond",root,function() second = getElementData(source,"second") triggerClientEvent(source,"GUIsecond",source,second) end ) addEvent("GUIthird",true) addEventHandler("GUIthird",root,function() third = getElementData(source,"third") triggerClientEvent(source,"GUIthird",source,third) end ) addEvent("GUIrank",true) addEventHandler("GUIrank",root,function() rank = getElementData(source,"rank") triggerClientEvent(source,"GUIrank",source,rank) end ) client triggerServerEvent("GUIwins",getLocalPlayer()) triggerServerEvent("GUIpoints",getLocalPlayer()) triggerServerEvent("GUIsecond",getLocalPlayer()) triggerServerEvent("GUIthird",getLocalPlayer()) triggerServerEvent("GUIrank",getLocalPlayer()) addEvent ( "GUIwins", true ) addEventHandler ( "GUIwins", root, function ( wins ) if ( wins ) then GUIEditor_Label[10] = guiCreateLabel ( 49,72,246,21,"" ..wins.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIpoints", true ) addEventHandler ( "GUIpoints" ,root, function ( points ) if ( points ) then GUIEditor_Label[11] = guiCreateLabel ( 54,101,246,21,"" ..points.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIsecond", true ) addEventHandler ( "GUIsecond",root, function ( second ) if ( second ) then GUIEditor_Label[12] = guiCreateLabel ( 98,131,246,21,"" ..second.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIthird", true ) addEventHandler ( "GUIthird", root, function ( third ) if ( third ) then GUIEditor_Label[13] = guiCreateLabel ( 88,160,246,21,"" ..third.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIrank", true ) addEventHandler ( "GUIrank", root, function ( rank ) if ( rank ) then GUIEditor_Label[14] = guiCreateLabel ( 49,188,246,21,"" ..rank.. "",false,GUIEditor_Tab[1]) end end ) how can i make trigger in every 10 second? when data changes it doenst seen on gui. Link to comment
X-SHADOW Posted March 23, 2012 Share Posted March 23, 2012 use https://wiki.multitheftauto.com/wiki/SetTimer to update the resource Link to comment
myyusuf Posted March 23, 2012 Author Share Posted March 23, 2012 usehttps://wiki.multitheftauto.com/wiki/SetTimer to update the resource well i dont know to use settimer. can you give me an example? Link to comment
mjau Posted March 23, 2012 Share Posted March 23, 2012 function refreshWithTimer() triggerServerEvent("GUIwins",getLocalPlayer()) triggerServerEvent("GUIpoints",getLocalPlayer()) triggerServerEvent("GUIsecond",getLocalPlayer()) triggerServerEvent("GUIthird",getLocalPlayer()) triggerServerEvent("GUIrank",getLocalPlayer()) end setTimer(refreshWithTimer, 10000, 0) addEvent ( "GUIwins", true ) addEventHandler ( "GUIwins", root, function ( wins ) if ( wins ) then GUIEditor_Label[10] = guiCreateLabel ( 49,72,246,21,"" ..wins.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIpoints", true ) addEventHandler ( "GUIpoints" ,root, function ( points ) if ( points ) then GUIEditor_Label[11] = guiCreateLabel ( 54,101,246,21,"" ..points.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIsecond", true ) addEventHandler ( "GUIsecond",root, function ( second ) if ( second ) then GUIEditor_Label[12] = guiCreateLabel ( 98,131,246,21,"" ..second.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIthird", true ) addEventHandler ( "GUIthird", root, function ( third ) if ( third ) then GUIEditor_Label[13] = guiCreateLabel ( 88,160,246,21,"" ..third.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIrank", true ) addEventHandler ( "GUIrank", root, function ( rank ) if ( rank ) then GUIEditor_Label[14] = guiCreateLabel ( 49,188,246,21,"" ..rank.. "",false,GUIEditor_Tab[1]) end end ) Here timers are really simple Link to comment
myyusuf Posted March 23, 2012 Author Share Posted March 23, 2012 function refreshWithTimer() triggerServerEvent("GUIwins",getLocalPlayer()) triggerServerEvent("GUIpoints",getLocalPlayer()) triggerServerEvent("GUIsecond",getLocalPlayer()) triggerServerEvent("GUIthird",getLocalPlayer()) triggerServerEvent("GUIrank",getLocalPlayer()) end setTimer(refreshWithTimer, 10000, 0) addEvent ( "GUIwins", true ) addEventHandler ( "GUIwins", root, function ( wins ) if ( wins ) then GUIEditor_Label[10] = guiCreateLabel ( 49,72,246,21,"" ..wins.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIpoints", true ) addEventHandler ( "GUIpoints" ,root, function ( points ) if ( points ) then GUIEditor_Label[11] = guiCreateLabel ( 54,101,246,21,"" ..points.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIsecond", true ) addEventHandler ( "GUIsecond",root, function ( second ) if ( second ) then GUIEditor_Label[12] = guiCreateLabel ( 98,131,246,21,"" ..second.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIthird", true ) addEventHandler ( "GUIthird", root, function ( third ) if ( third ) then GUIEditor_Label[13] = guiCreateLabel ( 88,160,246,21,"" ..third.. "",false,GUIEditor_Tab[1]) end end ) addEvent ( "GUIrank", true ) addEventHandler ( "GUIrank", root, function ( rank ) if ( rank ) then GUIEditor_Label[14] = guiCreateLabel ( 49,188,246,21,"" ..rank.. "",false,GUIEditor_Tab[1]) end end ) Here timers are really simple thank you it worked. but i have another problem now. when timer triggered new data from serverside, old data wasnt deleted. so here is the picture. sorry for my bad english. i hope you understand me. Link to comment
mjau Posted March 23, 2012 Share Posted March 23, 2012 oh create the labels in another function and use guiSetText Link to comment
myyusuf Posted March 23, 2012 Author Share Posted March 23, 2012 oh create the labels in another function and use guiSetText addEvent ( "GUIwins", true ) addEventHandler ( "GUIwins", root, function ( wins ) if ( wins ) then local winslabel = guiCreateLabel ( 49,72,246,21,"" ..wins.. "",false,GUIEditor_Tab[1]) guiSetText ( winslabel, elementType ) setTimer ( guiSetText, 50, 0, winslabel, "" ) end end ) addEvent ( "GUIpoints", true ) addEventHandler ( "GUIpoints" ,root, function ( points ) if ( points ) then local pointslabel = guiCreateLabel ( 54,101,246,21,"" ..points.. "",false,GUIEditor_Tab[1]) guiSetText ( pointslabel, elementType ) setTimer ( guiSetText, 50, 0, pointslabel, "" ) end end ) addEvent ( "GUIsecond", true ) addEventHandler ( "GUIsecond",root, function ( second ) if ( second ) then local secondlabel = guiCreateLabel ( 98,131,246,21,"" ..second.. "",false,GUIEditor_Tab[1]) guiSetText ( secondlabel, elementType ) setTimer ( guiSetText, 50, 0, secondlabel, "" ) end end ) addEvent ( "GUIthird", true ) addEventHandler ( "GUIthird", root, function ( third ) if ( third ) then local thirdlabel = guiCreateLabel ( 88,160,246,21,"" ..third.. "",false,GUIEditor_Tab[1]) guiSetText ( thirdlabel, elementType ) setTimer ( guiSetText, 50, 0, thirdlabel, "" ) end end ) it doenst show anything.. Link to comment
drk Posted March 23, 2012 Share Posted March 23, 2012 You need learn Lua dude. It's a mess. addEvent ( "GUIwins", true ) addEventHandler ( "GUIwins", root, function ( wins ) if ( wins ) then local winslabel = guiCreateLabel ( 49,72,246,21,wins,false,GUIEditor_Tab[1]) setTimer ( guiSetText, 5000, 1, winslabel, "" ) end end ) addEvent ( "GUIpoints", true ) addEventHandler ( "GUIpoints" ,root, function ( points ) if ( points ) then local pointslabel = guiCreateLabel ( 54,101,246,21,points,false,GUIEditor_Tab[1]) setTimer ( guiSetText, 5000, 1, pointslabel, "" ) end end ) addEvent ( "GUIsecond", true ) addEventHandler ( "GUIsecond",root, function ( second ) if ( second ) then local secondlabel = guiCreateLabel ( 98,131,246,21,second,false,GUIEditor_Tab[1]) setTimer ( guiSetText, 5000, 1, secondlabel, "" ) end end ) addEvent ( "GUIthird", true ) addEventHandler ( "GUIthird", root, function ( third ) if ( third ) then local thirdlabel = guiCreateLabel ( 88,160,246,21,third,false,GUIEditor_Tab[1]) setTimer ( guiSetText, 5000, 1, thirdlabel, "" ) end end ) Link to comment
myyusuf Posted March 23, 2012 Author Share Posted March 23, 2012 You need learn Lua dude. It's a mess. addEvent ( "GUIwins", true ) addEventHandler ( "GUIwins", root, function ( wins ) if ( wins ) then local winslabel = guiCreateLabel ( 49,72,246,21,wins,false,GUIEditor_Tab[1]) setTimer ( guiSetText, 5000, 1, winslabel, "" ) end end ) addEvent ( "GUIpoints", true ) addEventHandler ( "GUIpoints" ,root, function ( points ) if ( points ) then local pointslabel = guiCreateLabel ( 54,101,246,21,points,false,GUIEditor_Tab[1]) setTimer ( guiSetText, 5000, 1, pointslabel, "" ) end end ) addEvent ( "GUIsecond", true ) addEventHandler ( "GUIsecond",root, function ( second ) if ( second ) then local secondlabel = guiCreateLabel ( 98,131,246,21,second,false,GUIEditor_Tab[1]) setTimer ( guiSetText, 5000, 1, secondlabel, "" ) end end ) addEvent ( "GUIthird", true ) addEventHandler ( "GUIthird", root, function ( third ) if ( third ) then local thirdlabel = guiCreateLabel ( 88,160,246,21,third,false,GUIEditor_Tab[1]) setTimer ( guiSetText, 5000, 1, thirdlabel, "" ) end end ) it shows only for 1 time. when i change 1 to 0 it shows only 1 time. after nothing shows. Link to comment
drk Posted March 23, 2012 Share Posted March 23, 2012 Obviously, it shows only 1 time. You need update the text of the label. Link to comment
HunT Posted March 23, 2012 Share Posted March 23, 2012 Maybe the dx functions is better for this ,without setTimer etc . . . 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