Jump to content

[HELP] DxDrawText Available Staff...


lolman

Recommended Posts

Hello,

I got a problem with my code...

client :

admens = "" 
  
function drew() 
     dxDrawText(admens, 449, 333, 921, 402, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) 
end 
addEvent("drawadmen", true) 
addEventHandler("drawadmen", getRootElement(), drew) 
  
function render ( ) 
    addEventHandler ( "onClientRender", root, drew ) 
end 
  
addEventHandler ( "onClientResourceStart", resourceRoot, render ) 

server :

admens = "" 
  
function admen(thePlayer) 
    if hasObjectPermissionTo(thePlayer, "function.kickPlayer", true) then 
    triggerClientEvent("drawadmen", getResourceRootElement(), admens) 
end 
end 
addEventHandler("onResourceStart", getRootElement(), admen) 

I want that it shows admins which have permission to kick players. If they have the permission then you will be able to see their names on the screen if they're online.

Link to comment

Client:

local gAdminTable = { }; 
  
addEvent( "getAdminTabel", true ); 
addEventHandler ( "getAdminTabel", root, 
    function( table ) 
        if table and type( table ) == 'table' then 
            gAdminTable = table; 
        else 
            error( 'No table.'); 
        end 
    end 
); 
  
addEventHandler ( "onClientRender", root, 
    function( ) 
        local index = 0 
        for admins in pairs( gAdminTable ) do 
            if admins and getElementType( admins ) == 'player' then 
                local color = tocolor( getPlayerNametagColor ( admins ) ); 
                dxDrawAdminsLabel ( admins, index, color ); 
                index = index + 1; 
            end 
        end 
    end 
); 
  
function dxDrawAdminsLabel ( player, index, color ) 
    local sx, sy = guiGetScreenSize ( ) 
    local px, py = sx - 200, sy * 0.4 + 20 * sy / sy * index 
    dxDrawText ( getPlayerName ( player ):gsub('#%x%x%x%x%x%x', ''), px + 1, py + 1, px, py, tocolor ( 10, 10, 10, 255 ), sy / sy, 'default-bold', 'left', 'top', false, false, true, true, false ) 
    dxDrawText ( getPlayerName ( player ), px, py, px, py, color, sy / sy, 'default-bold', 'left', 'top', false, false, true, true, false ) 
end 

Server:

local adminTable = { }; 
  
function isPlayerAdmin ( player ) 
    if player and isElement( player ) and getElementType( player ) == 'player' then 
        for _, aclGroup in ipairs ( { 'Admin', 'Moderator', 'SuperModerator' } ) do 
            if isObjectInACLGroup ( "user." ..getAccountName( getPlayerAccount( player ) ) , aclGetGroup ( aclGroup ) ) then 
                return true 
            else  
                return false 
            end 
        end 
    end 
end 
  
function updateOnlineAdmin ( ) 
    triggerClientEvent( 'getAdminTabel', root, adminTable ); 
end 
  
addEventHandler( 'onPlayerLogin', root, 
    function( ) 
        if isPlayerAdmin( source ) then 
            if adminTable[ source ] then 
                adminTable[ source ] = nil; 
            end 
            adminTable[ source ] = true; 
            updateOnlineAdmin( ); 
        end 
    end 
); 
  
addEventHandler ( 'onPlayerLogout',  root, 
    function( ) 
        if adminTable[ source ] then 
            adminTable[ source ] = nil; 
        end 
        updateOnlineAdmin( ); 
    end 
); 
  
addEventHandler ( "onPlayerQuit", root, 
    function( ) 
        if adminTable[ source ] then 
            adminTable[ source ] = nil; 
        end 
        updateOnlineAdmin( ); 
    end 
); 

Link to comment

here you go... IT'S IN CLIENT SIDE!

addEventHandler("onClientRender", root, 
    function()    
     dxDrawText(""..getStaffOnDuty(), 449, 333, 921, 402, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) 
            end 
) 
  
function getStaffOnDuty() 
  theTableMembersOnline = "" 
  for i, player in ipairs(getElementsByType ( "player" )) do 
        if getElementData(player,"admin") == true then -- my bad :3 
      theTableMembersOnline = theTableMembersOnline .. ", " .. getPlayerName(player) 
        end 
    end 
  if theTableMembersOnline == "" then 
    return "" 
  else 
    return "Admins Online: " .. theTableMembersOnline 
  end 
end 
  

Edited by Guest
Link to comment

It works, thank you very much... :D

But I got a problem with this another code which I made...

function team() 
    stafff = createTeam("Staff", 255, 255, 255) 
end 
addEventHandler("onResourceStart", getRootElement(), team) 
  
  
  
function set(thePlayer) 
    --if hasObjectPermissionTo(thePlayer, "function.kickPlayer", true) then 
    local skins = 211 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) )  
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    setPedStat(thePlayer, 69, 1000) 
    setPedStat(thePlayer, 70, 1000) 
    setPedStat(thePlayer, 71, 1000) 
    setPedStat(thePlayer, 72, 1000) 
    setPedStat(thePlayer, 73, 1000) 
    setPedStat(thePlayer, 74, 1000) 
    setPedStat(thePlayer, 75, 1000) 
    setPedStat(thePlayer, 76, 1000) 
    setPedStat(thePlayer, 77, 1000) 
    setPedStat(thePlayer, 78, 1000) 
    setPedStat(thePlayer, 79, 1000) 
    setPedWalkingStyle(thePlayer, 69) 
    setElementModel(thePlayer, skins) 
    giveWeapon(thePlayer, 26, 9999) 
    giveWeapon(thePlayer, 28, 9999) 
    giveWeapon(thePlayer, 38, 9999) 
    setPlayerTeam ( thePlayer, stafff ) 
end 
end 
--addCommandHandler("staff", set) 
  
function bindd() 
    bindKey(source, "F3", "down", set) 
end 
addEventHandler("onPlayerJoin", getRootElement(), bindd) 
addEventHandler("onPlayerSpawn", getRootElement(), bindd) 

Sometimes it doesn't set me in the team Staff and sometimes I can't use it (as example when I restart the resource).... And I want that if you've pressed on F3 (you become staff) but when you press again F3 then it should change your skin back to the old one and the team too. If someone could help me out on this..

Link to comment
It works, thank you very much... :D

But I got a problem with this another code which I made...

function team() 
    stafff = createTeam("Staff", 255, 255, 255) 
end 
addEventHandler("onResourceStart", getRootElement(), team) 
  
  
  
function set(thePlayer) 
    --if hasObjectPermissionTo(thePlayer, "function.kickPlayer", true) then 
    local skins = 211 
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) )  
    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
    setPedStat(thePlayer, 69, 1000) 
    setPedStat(thePlayer, 70, 1000) 
    setPedStat(thePlayer, 71, 1000) 
    setPedStat(thePlayer, 72, 1000) 
    setPedStat(thePlayer, 73, 1000) 
    setPedStat(thePlayer, 74, 1000) 
    setPedStat(thePlayer, 75, 1000) 
    setPedStat(thePlayer, 76, 1000) 
    setPedStat(thePlayer, 77, 1000) 
    setPedStat(thePlayer, 78, 1000) 
    setPedStat(thePlayer, 79, 1000) 
    setPedWalkingStyle(thePlayer, 69) 
    setElementModel(thePlayer, skins) 
    giveWeapon(thePlayer, 26, 9999) 
    giveWeapon(thePlayer, 28, 9999) 
    giveWeapon(thePlayer, 38, 9999) 
    setPlayerTeam ( thePlayer, stafff ) 
end 
end 
--addCommandHandler("staff", set) 
  
function bindd() 
    bindKey(source, "F3", "down", set) 
end 
addEventHandler("onPlayerJoin", getRootElement(), bindd) 
addEventHandler("onPlayerSpawn", getRootElement(), bindd) 

Sometimes it doesn't set me in the team Staff and sometimes I can't use it (as example when I restart the resource).... And I want that if you've pressed on F3 (you become staff) but when you press again F3 then it should change your skin back to the old one and the team too. If someone could help me out on this..

The problem with this is:

You must be logged into an account which is in the Admin ACL, otherwise it won't work...

so better to change onPlayerJoin by onPlayerLogin

Link to comment
here you go... IT'S IN CLIENT SIDE!
addEventHandler("onClientRender", root, 
    function()    
     dxDrawText(""..getStaffOnDuty(), 449, 333, 921, 402, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false) 
            end 
) 
  
function getStaffOnDuty() 
  theTableMembersOnline = "" 
  for i, player in ipairs(getElementsByType ( "player" )) do 
        if hasObjectPermissionTo(player, "function.kickPlayer", true) then 
      theTableMembersOnline = theTableMembersOnline .. ", " .. getPlayerName(player) 
        end 
    end 
  if theTableMembersOnline == "" then 
    return "" 
  else 
    return "Admins Online: " .. theTableMembersOnline 
  end 
end 
  

Are you kidding with me?? hasObjectPermissionTo is a client??

It works, thank you very much... :D

Which one is worked??

Link to comment
@blaawee yeah i just tested it hasObjectPermissionTo didn't work well thanks for telling me xD

If it shows up as orange when using the Lua tags on these forums, it means it's server-sided only. If it's red, it's client-side only. If it's blue, you can use it on either client or server. :)

Link to comment
@blaawee yeah i just tested it hasObjectPermissionTo didn't work well thanks for telling me xD

If it shows up as orange when using the Lua tags on these forums, it means it's server-sided only. If it's red, it's client-side only. If it's blue, you can use it on either client or server. :)

i know but i forgot :D :c

Link to comment
  • Moderators
  
local oldPlayerData = {} 
function team() 
    createTeam("Staff", 255, 255, 255) 
    for _,p in pairs(getElementsByType("player")) do 
        if not isGuestAccount(getPlayerAccount(p)) and isPlayerAdmin(p) then 
            bindKey(p, "F3", "down", setTeam) 
        end 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, team) 
  
function setTeam(thePlayer) 
    --if hasObjectPermissionTo(thePlayer, "function.kickPlayer", true) then 
    if oldPlayerData[thePlayer] then 
        setElementModel(oldPlayerData[thePlayer][1]) 
        if oldPlayerData[thePlayer][2] ~= "" then 
            setPlayerTeam(thePlayer, oldPlayerData[thePlayer][2]) 
        end 
        oldPlayerData[thePlayer] = nil 
        return 
    end 
    oldPlayerData[thePlayer] = { getElementModel(thePlayer), getPlayerTeam(thePlayer) or "" } 
    for _, id in pairs( {69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79} ) do 
        setPedStat(thePlayer, id, 1000) 
    end 
    setPedWalkingStyle(thePlayer, 69) 
    setElementModel(thePlayer, 211) 
    giveWeapon(thePlayer, 26, 9999) 
    giveWeapon(thePlayer, 28, 9999) 
    giveWeapon(thePlayer, 38, 9999) 
    setPlayerTeam ( thePlayer, getTeamFromName("Staff") ) 
end 
  
addEventHandler("onPlayerLogin", root, 
function() 
    if isPlayerAdmin(source) then 
        bindKey(source, "F3", "down", setTeam) 
    end 
end) 
  
addEventHandler("onPlayerLogout", root, 
function() 
    if isKeyBound(source, "F3", "down", setTeam) then 
        unbindKey(source, "F3", "down", setTeam) 
    end 
end) 
  
function isPlayerAdmin(p) 
    if isElement(p) then 
        return isObjectInACLGroup("user."..getAccountName ( getPlayerAccount ( p ) ), aclGetGroup ( "Admin" ) ) 
    end 
    return false 
end 
  

Try it.

Link to comment

You can add me to Admins Offline and Online ?

local gAdminTable = { }; 
  
addEvent( "getAdminTabel", true ); 
addEventHandler ( "getAdminTabel", root, 
    function( table ) 
        if table and type( table ) == 'table' then 
            gAdminTable = table; 
        else 
            error( 'No table.'); 
        end 
    end 
); 
  
addEventHandler ( "onClientRender", root, 
    function( ) 
        local index = 0 
        for admins in pairs( gAdminTable ) do 
            if admins and getElementType( admins ) == 'player' then 
                local color = tocolor( getPlayerNametagColor ( admins ) ); 
                dxDrawAdminsLabel ( admins, index, color ); 
                index = index + 1; 
            end 
        end 
    end 
); 
  
function dxDrawAdminsLabel ( player, index, color ) 
    local sx, sy = guiGetScreenSize ( ) 
    local px, py = sx - 200, sy * 0.4 + 20 * sy / sy * index 
    dxDrawText ( getPlayerName ( player ):gsub('#%x%x%x%x%x%x', ''), px + 1, py + 1, px, py, tocolor ( 10, 10, 10, 255 ), sy / sy, 'default-bold', 'left', 'top', false, false, true, true, false ) 
    dxDrawText ( getPlayerName ( player ), px, py, px, py, color, sy / sy, 'default-bold', 'left', 'top', false, false, true, true, false ) 
end 

please add :(

function AdminOffline ( player, index, color ) 
    local sx, sy = guiGetScreenSize ( ) 
    local px, py = sx - 200, sy * 0.4 + 20 * sy / sy * index 
    dxDrawText ( "Offline", px + 1, py + 1, px, py, tocolor ( 10, 10, 10, 255 ), sy / sy, 'default-bold', 'left', 'top', false, false, true, true, false ) 
    dxDrawText ( "Offline", px, py, px, py, color, sy / sy, 'default-bold', 'left', 'top', false, false, true, true, false ) 
end 

Link to comment
  • Moderators
doesn't change my team and skin back to the old one :(

I think now it is fixed, try this:

  
local oldPlayerData = {} 
function team() 
    createTeam("Staff", 255, 255, 255) 
    for _,p in pairs(getElementsByType("player")) do 
        if not isGuestAccount(getPlayerAccount(p)) and isPlayerAdmin(p) then 
            oldPlayerData[p] = { getElementModel(p), getPlayerTeam(p) or ""} 
            bindKey(p, "F3", "down", setTeam) 
        end 
    end 
end 
addEventHandler("onResourceStart", resourceRoot, team) 
  
function setTeam(thePlayer) 
    if (getPlayerTeam(thePlayer) or "") ~= oldPlayerData[thePlayer][2] then 
        setElementModel(oldPlayerData[thePlayer][1]) 
        setPlayerTeam(thePlayer, oldPlayerData[thePlayer][2]) 
        return 
    end 
    for _, id in pairs( {69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79} ) do 
        setPedStat(thePlayer, id, 1000) 
    end 
    setPedWalkingStyle(thePlayer, 69) 
    setElementModel(thePlayer, 211) 
    giveWeapon(thePlayer, 26, 9999) 
    giveWeapon(thePlayer, 28, 9999) 
    giveWeapon(thePlayer, 38, 9999) 
    setPlayerTeam ( thePlayer, getTeamFromName("Staff") ) 
end 
  
addEventHandler("onPlayerLogin", root, 
function() 
    if isPlayerAdmin(source) then 
        oldPlayerData[source] = { getElementModel(source), getPlayerTeam(source) or ""} 
        bindKey(source, "F3", "down", setTeam) 
    end 
end) 
  
addEventHandler("onPlayerLogout", root, 
function() 
    if isKeyBound(source, "F3", "down", setTeam) then 
        unbindKey(source, "F3", "down", setTeam) 
        oldPlayerData[source] = nil 
    end 
end) 
  
function isPlayerAdmin(p) 
    if isElement(p) then 
        return isObjectInACLGroup("user."..getAccountName ( getPlayerAccount ( p ) ), aclGetGroup ( "Admin" ) ) 
    end 
    return false 
end 
  
addEventHandler( "onPlayerQuit", root, 
    function() 
        if oldPlayerData[source] then 
            oldPlayerData[source] = nil 
        end 
    end 
) 
  

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