WASSIm. Posted September 19, 2013 Share Posted September 19, 2013 how use getMaxPlayers to show in DxDrawText ? Link to comment
TAPL Posted September 19, 2013 Share Posted September 19, 2013 setElementData getElementData OR triggerServerEvent triggerClientEvent Link to comment
WASSIm. Posted September 19, 2013 Author Share Posted September 19, 2013 this is problem idk how use triggerServerEvent triggerClientEvent Link to comment
DakiLLa Posted September 19, 2013 Share Posted September 19, 2013 createElement setElementData Create an element and set its data to max-players and then retrieve it from the client side. There are other ways of solving your problem, this way is just one of them. Link to comment
WASSIm. Posted September 19, 2013 Author Share Posted September 19, 2013 createElement setElementData Create an element and set its data to max-players and then retrieve it from the client side. There are other ways of solving your problem, this way is just one of them. i have this function server-side i want show in dxdrawtext but how function getPlayerBantime( thePlayer ) assert ( isElement ( thePlayer ) and getElementType ( thePlayer ) == "player", "Bad player element" ) local ip = getPlayerIP ( thePlayer ) local serial = getPlayerSerial ( thePlayer ) if ( thePlayer ) then local theBans = xmlNodeGetChildren( banlist ) for i, theNode in ipairs( theBans ) do local theValueSerial = xmlNodeGetAttribute( theNode, "Serial" ) local theValueIP = xmlNodeGetAttribute( theNode, "IP" ) if ( theValueSerial == serial) or ( theValueIP == ip ) then local theValue = xmlNodeGetAttribute( theNode, "Bantime" ) return theValue else return false end end end end Link to comment
kevenvz Posted September 19, 2013 Share Posted September 19, 2013 addEvent addEventHandler triggerServerEvent Link to comment
WASSIm. Posted September 19, 2013 Author Share Posted September 19, 2013 BUT HOW. MAKE LIKE THIS FAIL???? SERVER addEvent ( "onShowInfoBan", true ) addEventHandler ( "onShowInfoBan", getRootElement(), function ( ) getPlayerBantime( source ) end ) CLIENT addEventHandler( "onClientRender", getRootElement(), function ( ) local btime = triggerServerEvent ( "onShowInfoBan", localPlayer ) dxDrawText( btime, sx*0.2, sy*0.1, sx, sy, tocolor(255,0,0,255),(sx/1024)*0.5,"bankgothic","left","top",false,false,false ) end ) Link to comment
kevenvz Posted September 19, 2013 Share Posted September 19, 2013 Server: function clientBanTime (player) getPlayerBanTime (player) end addEvent ("onShowInfoBan", true) addEventHandler ("onShowInfoBan", getRootElement (), clientBanTime) Client: addEventHandler( "onClientRender", getRootElement(), function ( ) local btime = triggerServerEvent ( "onShowInfoBan", getLocalPlayer (), getLocalPlayer ()) dxDrawText( tostring (btime), sx*0.2, sy*0.1, sx, sy,tocolor(255,0,0,255),(sx/1024)*0.5,"bankgothic","left","top",false,false,false ) end) Link to comment
WASSIm. Posted September 19, 2013 Author Share Posted September 19, 2013 he is show me true Link to comment
Sasu Posted September 19, 2013 Share Posted September 19, 2013 Server: addEvent("onResourceStartClient", true) addEventHandler("onResourceStartClient", root, function() triggerClientEvent("passXMLBans", source, banlist) end) addEventHandler("onPlayerJoin", root, function() setElementData(source, "PlayerIP", getPlayerIP(source)) end) Client: addEventHandler("onClientResourceStart", resourceRoot, function() triggerServerEvent("onResourceStartClient", localPlayer) end) addEvent("passXMLBans", true) addEventHandler("passXMLBans", root, function(theXML) banlist = theXML end) function getPlayerBantime( ) assert ( isElement ( localPlayer ) and getElementType ( localPlayer ) == "player", "Bad player element" ) local ip = getElementData( localPlayer, "PlayerIP" ) or "N/A" local serial = getPlayerSerial ( localPlayer ) if ( localPlayer ) then local theBans = xmlNodeGetChildren( banlist ) for i, theNode in ipairs( theBans ) do local theValueSerial = xmlNodeGetAttribute( theNode, "Serial" ) local theValueIP = xmlNodeGetAttribute( theNode, "IP" ) if ( theValueSerial == serial) or ( theValueIP == ip ) then local theValue = xmlNodeGetAttribute( theNode, "Bantime" ) return theValue else return false end end end end addEventHandler( "onClientRender", getRootElement(), function() local btime = getPlayerBantime( ) dxDrawText( btime, sx*0.2, sy*0.1, sx, sy, tocolor(255,0,0,255),(sx/1024)*0.5,"bankgothic","left","top",false,false,false ) end) Link to comment
WASSIm. Posted September 19, 2013 Author Share Posted September 19, 2013 what do you mean ? Link to comment
WASSIm. Posted September 19, 2013 Author Share Posted September 19, 2013 Try that. my function server side an you show me it in client and file xml is in server not client Link to comment
Sasu Posted September 19, 2013 Share Posted September 19, 2013 I sent the XML to the client. Try that and tell me if it's wrong Link to comment
xXMADEXx Posted September 20, 2013 Share Posted September 20, 2013 Just a little advice: Its a really, really bad idea to trigger a server event on every render for every player. You should use getTickCount or setTimer. Link to comment
Blaawee Posted September 20, 2013 Share Posted September 20, 2013 -- Server addEventHandler( 'onPlayerJoin', root, function( ) triggerClientEvent( 'getTheMaxPlayers', source, getMaxPlayers( ) ); end ); --Client addEvent ( 'getTheMaxPlayers', true ); addEventHandler ( 'getTheMaxPlayers', root, function ( count ) howMany = count; end ); addEventHandler( 'onClientRender', root, function ( ) dxDrawText( howMany, sx * 0.2, sy * 0.1, sx, sy, tocolor( 255, 0, 0, 255 ),( sx / 1024 ) * 0.5, "bankgothic", "left", "top", false, false, false ); end ); Link to comment
WASSIm. Posted September 20, 2013 Author Share Posted September 20, 2013 -- Server addEventHandler( 'onPlayerJoin', root, function( ) triggerClientEvent( 'getTheMaxPlayers', source, getMaxPlayers( ) ); end ); --Client addEvent ( 'getTheMaxPlayers', true ); addEventHandler ( 'getTheMaxPlayers', root, function ( count ) howMany = count; end ); addEventHandler( 'onClientRender', root, function ( ) dxDrawText( howMany, sx * 0.2, sy * 0.1, sx, sy, tocolor( 255, 0, 0, 255 ),( sx / 1024 ) * 0.5, "bankgothic", "left", "top", false, false, false ); end ); thank you this what i need 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