SpoC^ Posted April 11, 2015 Share Posted April 11, 2015 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 Studios™ Posted April 11, 2015 Share Posted April 11, 2015 Make a server side function to check if the user is in the admin acl group, export it, so that it can be called in an `if` in the client side function you created. Link to comment
#RooTs Posted April 11, 2015 Share Posted April 11, 2015 @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
RenanPG Posted April 12, 2015 Share Posted April 12, 2015 You mean sending to client if certain player is or not an admin? Link to comment
SpoC^ Posted April 12, 2015 Author Share Posted April 12, 2015 You mean sending to client if certain player is or not an admin? YES friend. Link to comment
RenanPG Posted April 12, 2015 Share Posted April 12, 2015 -- 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
SpoC^ Posted April 18, 2015 Author Share Posted April 18, 2015 (edited) 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 April 19, 2015 by Guest Link to comment
Castillo Posted April 18, 2015 Share Posted April 18, 2015 You wrote "AddEventHandler", but it's "addEventHandler". And also, the "onResourceStart" event doesn't have any player element ( obviously, it's a resource, not a player ). You can loop every online player instead. Use getElementsByType to get the players online. Link to comment
SpoC^ Posted April 19, 2015 Author Share Posted April 19, 2015 @Solidsnake14 corrected, but did not understand much what you said, can help-me? Link to comment
ALw7sH Posted April 19, 2015 Share Posted April 19, 2015 You can use onPlayerLogin instead of onResourceStart also dxDraw functions must be in onClientRender event Link to comment
#RooTs Posted April 19, 2015 Share Posted April 19, 2015 You can use onPlayerLogin instead of onResourceStartalso dxDraw functions must be in onClientRender event 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
#RooTs Posted April 19, 2015 Share Posted April 19, 2015 @ALw7sH, sorry my friend more if not will help, please not hinder Link to comment
ALw7sH Posted April 19, 2015 Share Posted April 19, 2015 I cant understand what do you mean Link to comment
#RooTs Posted April 19, 2015 Share Posted April 19, 2015 I cant understand what do you mean the script is not working, that I did with the Spoc^ Link to comment
ALw7sH Posted April 19, 2015 Share Posted April 19, 2015 Because as i told you, you cant use dxDraw functions without onClientRender And the server side code is worng as Solidsnake14 already said that Link to comment
#RooTs Posted April 19, 2015 Share Posted April 19, 2015 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
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