Jump to content

[Help] Add event of Server to Client


SpoC^

Recommended Posts

hello friends, wanted to add this function to the text in dx, but do not know import and export for server and client.

I am new to the moon, and I am studying hard and learning gradually

someone with a good heart can do for me?

obs: sorry my english

if (isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(playersource)), aclGetGroup("Admin")))  then 

function tagAdminStaff() 
    local cx, cy, cz, lx, ly, lz = getCameraMatrix() 
    if(getElementData(localPlayer, "special.event")) then 
        drawDistance = eventDrawDistance 
    else 
        drawDistance = normalDrawDistance 
    end 
    local target = getPedTarget(localPlayer) 
    for k, player in pairs(getElementsByType("player", root, true)) do 
        if(player ~= localPlayer or getElementData(player, "isgod")) then 
            local vx, vy, vz = getPedBonePosition(player, -- s8) -->
            local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz ) 
            if dist < drawDistance or player == target then 
                if( isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) ) then 
                    local x, y = getScreenFromWorldPosition (vx, vy, vz + 0.3) 
                    if(x and y) then 
                        local tag = getElementData(player, "gang.tag") or "" 
                        local name = unfuck(tag .. getPlayerName(player)) .. "" .. (getElementData(player, "") or "") .. "" 
                         
                        local w = dxGetTextWidth(name, 1, "default-bold") 
                        local h = dxGetFontHeight(1, "default-bold") 
                        local color = tocolor(getPlayerNametagColor(player)) 
  
                        -- text add to ACL group (admin) 
                        dxDrawText("STAFF", x - 1  - w / 15,y - 55 - h - 1, w, h, tocolor(0,0,0), 0.9, "default-bold") 
                        dxDrawText("STAFF", x - 1  - w / 15,y - 56 - h - 1, w, h, tocolor(233, 137, 136, 255), 0.9, "default-bold") 
  
                        dxDrawText("ADMINS", x - 1  - w / 15,y - 45+3 - h - 1, w, h, tocolor(0, 0, 0, 255), 1.0, "default-bold") 
                        dxDrawText("ADMINS", x - 1  - w / 15,y - 46+3 - h - 1, w, h, tocolor(255, 255, 255, 255), 1.0, "default-bold")                       
                    end 
                end 
            end 
        end 
    end 
end 

Link to comment

@TrapLord , I think you did not helped, it has done that

if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( playersource ) ) , aclGetGroup ( "Admin" ) ) )  then 

he has said he did not know how to do it

but do not know import and export for server and client.

Link to comment
  
-- server 
  
addEventHandler("onResourceStart", resourceRoot, function() 
    for index, player in ipairs(getElementsByType("player")) do 
        if(isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(player)), aclGetGroup("Admin"))) then 
            setElementData(player, "player:isAdmin", true) 
        end      
    end 
end) 
  
  
  
-- client 
addEventHandler("onClientRender", root, function() 
    for index, player in ipairs(getElementsByType("player")) do 
        local isAdmin = getElementData(player, "player:isAdmin")   
        if(isAdmin) then 
             
        end   
    end 
end 
  
  

This should work, just check your debugscript.

Link to comment

I tried this, more not work. what will the error?

Client.lua

function user_tag2 () 
    local cx, cy, cz, lx, ly, lz = getCameraMatrix() 
    if(getElementData(localPlayer, "special.event")) then 
        drawDistance = eventDrawDistance 
    else 
        drawDistance = normalDrawDistance 
    end 
    local target = getPedTarget(localPlayer) 
    for k, player in pairs(getElementsByType("player", root, true)) do 
        if(player ~= localPlayer or getElementData(player, "isgod")) then 
            local vx, vy, vz = getPedBonePosition(player, 5 )  
            local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz ) 
            if dist < drawDistance or player == target then 
                if( isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) ) then 
                    local x, y = getScreenFromWorldPosition (vx, vy, vz + 0.3) 
                    if(x and y) then 
                        local tag = getElementData(player, "gang.tag") or "" 
                        local name = (tag .. getPlayerName(player)) .. "" .. (getElementData(player, "") or "") .. "" 
                        
                        local w = dxGetTextWidth(name, 1, "default-bold") 
                        local h = dxGetFontHeight(1, "default-bold") 
                        local color = tocolor(getPlayerNametagColor(player)) 
  
                        -- text add to ACL group (admin) 
                        dxDrawText("STAFF", x - 1  - w / 15,y - 55 - h - 1, w, h, tocolor(0,0,0), 0.9, "default-bold") 
                        dxDrawText("STAFF", x - 1  - w / 15,y - 56 - h - 1, w, h, tocolor(233, 137, 136, 255), 0.9, "default-bold") 
  
                        dxDrawText("ADMINS", x - 1  - w / 15,y - 45+3 - h - 1, w, h, tocolor(0, 0, 0, 255), 1.0, "default-bold") 
                        dxDrawText("ADMINS", x - 1  - w / 15,y - 46+3 - h - 1, w, h, tocolor(255, 255, 255, 255), 1.0, "default-bold")                     
                    end 
                end 
            end 
        end 
    end 
end 
addEvent("Tag",true) 
addEventHandler("Tag", root, user_tag2) 

Server.lua

function user_tag (player) 
     if not isElement(player) then return end 
     local account  = getPlayerAccount (player) 
     if not  isGuestAccount ( account ) then 
     local accName = getAccountName(account) 
     if accName == "Console" then 
     triggerClientEvent(player,"Tag",player) 
      end 
end 
addEventHandler ( "onResourceStart" , resourceRoot, user_tag ) 

Edited by Guest
Link to comment
You can use onPlayerLogin instead of onResourceStart

also dxDraw functions must be in onClientRender event

:lol::lol::lol: OMG

do not you see that he is importing the server and client functions

client.lua

addEvent("Tag",true) 
addEventHandler("Tag", root, user_tag2) 

Link to comment

this?

function user_tag2 () 
    local cx, cy, cz, lx, ly, lz = getCameraMatrix() 
    if(getElementData(localPlayer, "special.event")) then 
        drawDistance = eventDrawDistance 
    else 
        drawDistance = normalDrawDistance 
    end 
    local target = getPedTarget(localPlayer) 
    for k, player in pairs(getElementsByType("player", root, true)) do 
        if(player ~= localPlayer or getElementData(player, "isgod")) then 
            local vx, vy, vz = getPedBonePosition(player, 5 ) 
            local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz ) 
            if dist < drawDistance or player == target then 
                if( isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) ) then 
                    local x, y = getScreenFromWorldPosition (vx, vy, vz + 0.3) 
                    if(x and y) then 
                        local tag = getElementData(player, "gang.tag") or "" 
                        local name = (tag .. getPlayerName(player)) .. "" .. (getElementData(player, "") or "") .. "" 
                        
                        local w = dxGetTextWidth(name, 1, "default-bold") 
                        local h = dxGetFontHeight(1, "default-bold") 
                        local color = tocolor(getPlayerNametagColor(player)) 
  
                        -- text add to ACL group (admin) 
                        dxDrawText("STAFF", x - 1  - w / 15,y - 55 - h - 1, w, h, tocolor(0,0,0), 0.9, "default-bold") 
                        dxDrawText("STAFF", x - 1  - w / 15,y - 56 - h - 1, w, h, tocolor(233, 137, 136, 255), 0.9, "default-bold") 
  
                        dxDrawText("ADMINS", x - 1  - w / 15,y - 45+3 - h - 1, w, h, tocolor(0, 0, 0, 255), 1.0, "default-bold") 
                        dxDrawText("ADMINS", x - 1  - w / 15,y - 46+3 - h - 1, w, h, tocolor(255, 255, 255, 255), 1.0, "default-bold")                     
                    end 
                end 
            end 
        end 
    end 
end 
addEvent("Tag",true) 
addEventHandler("Tag", root, user_tag2) 
addEventHandler("onClientRender", root, user_tag2) 
  

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