Jump to content

Question


WASSIm.

Recommended Posts

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

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
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

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
-- 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
-- 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 :D

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...