Blaawee Posted November 6, 2011 Share Posted November 6, 2011 hi all , all i wan't to do draw text only on admins head i made this but not shure local screenWidth, screenHeight = guiGetScreenSize() local name = getPlayerName() function createText ( ) if isObjectInACLGroup ( "user." .. playerName, aclGetGroup ( "Admin" ) ) then dxDrawText( "Admin"..tostring(name), 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1, "pricedown" ) end addEventHandler("onPlayerLogin",root, createText) Link to comment
Charlie_Jefferson Posted November 6, 2011 Share Posted November 6, 2011 isObjectInACLGroup = server-side. dxDrawText = Client-side. Won't work. Plus you have to attach the dxDrawText to the admin's head. Link to comment
Blaawee Posted November 6, 2011 Author Share Posted November 6, 2011 how i have to attach it the admin's Head Link to comment
JR10 Posted November 6, 2011 Share Posted November 6, 2011 Take a look in voice resource. Link to comment
Blaawee Posted November 6, 2011 Author Share Posted November 6, 2011 those all lines i want it right? : local WORLD_OFFSET = 0.4 local BONE_ID = 8 addEventHandler ( "onClientRender", root, function() local color = tocolor(getPlayerNametagColor ( player )) local headX,headY,headZ = getPedBonePosition(player,BONE_ID) headZ = headZ + WORLD_OFFSET local absX,absY = getScreenFromWorldPosition ( headX,headY,headZ ) if not absX or not absY then break end local camX,camY,camZ = getCameraMatrix() if not isLineOfSightClear ( camX, camY, camZ, headX, headY, headZ, true, false, false, true, false, true, false, player ) then break end dxDrawVoice ( absX, absY, color, getDistanceBetweenPoints3D(camX, camY, camZ, headX, headY, headZ) ) break end end end ) Link to comment
JR10 Posted November 6, 2011 Share Posted November 6, 2011 You need to get admins table server side, send it to client, and loop through it, and edit dxDrawVoice to be dxDrawText, with of course editing the arguments. Link to comment
Charlie_Jefferson Posted November 6, 2011 Share Posted November 6, 2011 AKA xmlLoadFile, xmlNodeGetValue, then triggerClientEvent, dxDrawText. If you look through those, it should work. Link to comment
Charlie_Jefferson Posted November 6, 2011 Share Posted November 6, 2011 Server: local account = getPlayerAccount(getPlayerName(source)) function ifAdmin ( ) if isObjectInACLGroup ( "user." .. account, aclGetGroup ( "Admin" ) ) then triggerClientEvent("dxText", getRootElement()) else end end Client: local screenHeight, screenWidth = guiGetScreenSize() function aTag(thePlayer) name = getPlayerName(thePlayer) dxDrawText( "Admin"..tostring(name), 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1, "pricedown" ) end addEvent("dxText", true) addEventHandler("dxText", getRootElement(), aTag) addEventHandler ( "onClientResourceStart", getRootElement(), aTag ) Pretty basic, not sure if it's correct, but from here you'll have to attach it to the player's head, somehow. Link to comment
TAPL Posted November 6, 2011 Share Posted November 6, 2011 Server: local account = getPlayerAccount(getPlayerName(source)) function ifAdmin ( ) if isObjectInACLGroup ( "user." .. account, aclGetGroup ( "Admin" ) ) then triggerClientEvent("dxText", getRootElement()) else end end Client: local screenHeight, screenWidth = guiGetScreenSize() function aTag(thePlayer) name = getPlayerName(thePlayer) dxDrawText( "Admin"..tostring(name), 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1, "pricedown" ) end addEvent("dxText", true) addEventHandler("dxText", getRootElement(), aTag) addEventHandler ( "onClientResourceStart", getRootElement(), aTag ) Pretty basic, not sure if it's correct, but from here you'll have to attach it to the player's head, somehow. the code is realy mess Link to comment
Castillo Posted November 6, 2011 Share Posted November 6, 2011 I would set element data to the player when login, and remove it when logout. -- server side: addEventHandler("onPlayerLogin",root, function () local account = getPlayerAccount(source) if account and not isGuestAccount(account) then local accountName = getAccountName(account) if isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Admin" ) ) then setElementData(source,"isAdmin",true) end end end) addEventHandler("onPlayerLogout",root, function () setElementData(source,"isAdmin",false) end) -- client side: addEventHandler("onClientRender",getRootElement(), function () for i,v in ipairs(getElementsByType("player")) do if getElementData(v,"isAdmin") then local x,y,z = getElementPosition(v) local cx,cy,cz = getCameraMatrix() if getDistanceBetweenPoints3D(cx,cy,cz,x,y,z) <= 15 then local px,py = getScreenFromWorldPosition(x,y,z+1.3,0.06) if px then local text = "Admin ".. tostring(getPlayerName(v)) local width = dxGetTextWidth(text,1,"sans") dxDrawText(text, px, py, px, py, tocolor(0, 255, 0, 255), 2, "sans", "center", "center", false, false) end end end end end) Link to comment
Blaawee Posted November 6, 2011 Author Share Posted November 6, 2011 Solidsnake14 i'v try your code and nothing show i used debug and it say's line 15 in client side here is photo Link to comment
Castillo Posted November 6, 2011 Share Posted November 6, 2011 I don't know what are you talking about, the script works perfectly, want proof? Here: http://imageshack.us/photo/my-images/9/ ... 01228.png/ Link to comment
Blaawee Posted November 6, 2011 Author Share Posted November 6, 2011 (edited) EDIT : ops My Bad i didn't copy the last end) thx soildsnake i make some change Edited November 6, 2011 by Guest Link to comment
Castillo Posted November 6, 2011 Share Posted November 6, 2011 I don't know, but I know that is not my script. Do you have anything else in that resource? Link to comment
^Dev-PoinT^ Posted November 6, 2011 Share Posted November 6, 2011 SoldSnake it Happend with me to He Have To Use /logout then /login Link to comment
Castillo Posted November 6, 2011 Share Posted November 6, 2011 What are you talking about? what has logout or login to do with this? the script cannot generate a error because of not being logged in... Link to comment
^Dev-PoinT^ Posted November 6, 2011 Share Posted November 6, 2011 i tested it and show no thing Only if i dot /logout then / login PS. and its on Admin Group Link to comment
Castillo Posted November 6, 2011 Share Posted November 6, 2011 Of course, it only works after you login, when you logout it set's the isAdmin data to false. Link to comment
Blaawee Posted November 6, 2011 Author Share Posted November 6, 2011 Solidsnake14 it's work thx Link to comment
Charlie_Jefferson Posted November 7, 2011 Share Posted November 7, 2011 Server: local account = getPlayerAccount(getPlayerName(source)) function ifAdmin ( ) if isObjectInACLGroup ( "user." .. account, aclGetGroup ( "Admin" ) ) then triggerClientEvent("dxText", getRootElement()) else end end Client: local screenHeight, screenWidth = guiGetScreenSize() function aTag(thePlayer) name = getPlayerName(thePlayer) dxDrawText( "Admin"..tostring(name), 44, screenHeight-43, screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1, "pricedown" ) end addEvent("dxText", true) addEventHandler("dxText", getRootElement(), aTag) addEventHandler ( "onClientResourceStart", getRootElement(), aTag ) Pretty basic, not sure if it's correct, but from here you'll have to attach it to the player's head, somehow. the code is realy mess May I ask why it's a mess? Link to comment
Blaawee Posted November 7, 2011 Author Share Posted November 7, 2011 what did you mess Link to comment
Charlie_Jefferson Posted November 7, 2011 Share Posted November 7, 2011 No idea, but TAPL is being smart. The code isn't a mess. At least I bothered to try and help you. Link to comment
Castillo Posted November 7, 2011 Share Posted November 7, 2011 Sorry Charlie, but I agree with TAPL, that code is a mess, it just doesn't make any sense. 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