BriGhtx3 Posted January 19, 2012 Share Posted January 19, 2012 function getthesite(textaa) sitetext = tostring(textaa) --guiSetVisible(Laptop_LBLPhish,true) -- guiSetText(Laptop_LBLPhish,sitetext) removeEventHandler("onClientRender",getRootElement(),drawsitetext) addEventHandler("onClientRender",getRootElement(),drawsitetext) end addEvent("getTextClient",true) addEventHandler("getTextClient",getRootElement(),getthesite) function drawsitetext() dxDrawColoredText(sitetext, 200, 250, 900, 900, tocolor(255,255,255,255),0.7,"bankgothic") end This is my code, if you want the function dxDrawColoredText : IT IS NOT MINE!!! local screen_width, screen_height = guiGetScreenSize() function dxDrawColoredText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) -- Making them optional. right = right or screen_width bottom = bottom or screen_height while(left < 0) do left = screen_width - math.abs(left) end while(top < 0) do top = screen_height - math.abs(top) end while(right < 0) do right = screen_width - math.abs(right) end while(bottom < 0) do bottom = screen_height - math.abs(bottom) end if(right > screen_width)then right = screen_width end if(bottom > screen_height)then bottom = screen_height end color = color or tocolor(255, 255, 255, 200) scale = scale or 1 font = font or "default" alignX = alignX or "left" alignY = alignY or "top" clip = clip or false wordBreak = wordBreak or false postGUI = postGUI or true local alpha = intToAlpha(color) local text_width = 0 local offset = 0 local text_height = dxGetFontHeight(scale, font) local TEXT_WIDTH = dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), scale, font) local off = -TEXT_WIDTH local width = 0 local height = 0 if(alignX == "center")then left = left + width/2 - TEXT_WIDTH/2 end if(alignX == "right")then left = left + width - TEXT_WIDTH end if(alignY == "center")then top = top + height/2 - text_height/2 end if(alignY == "bottom")then top = top + height - text_height end alignX = "left" alignY = "top" -- 0 index ? local col1, col2 = string.find(text, "#%x%x%x%x%x%x") if col1 ~= nil then col1 = col1-1 end -- draw text with the color we sent until we find hexadecimal code. for i = 1, col1 or string.len(text) do text_width = dxGetTextWidth(string.sub(text, i, i), scale, font) dxDrawText(string.sub(text, i, i), left + offset, top, right-off+offset, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) offset = offset + text_width end while(string.find(text, "#%x%x%x%x%x%x", i))do local hex1, hex2 = string.find(text, "#%x%x%x%x%x%x") local r, g, b, a = getColorFromString(string.sub(text, hex1, hex2)) text = string.sub(text, hex2 + 1) hex1, hex2 = string.find(text, "#%x%x%x%x%x%x") if hex1 ~= nil then hex1 = hex1-1 end for i = 1, hex1 or string.len(text) do text_width = dxGetTextWidth(string.sub(text, i, i), scale, font) dxDrawText(string.sub(text, i, i), left + offset, top, right-off+offset, bottom, tocolor(r, g, b, alpha), scale, font, alignX, alignY, clip, wordBreak, postGUI) offset = offset + text_width end end end function intToAlpha(color) local a = 16777216 local red, green, blue, alpha = 0, 0, 0, 0 local ap = 1 if(color < 0)then color = 2147483648 + (-color) alpha = 383 ap = -ap end while(color >= a)do alpha = alpha + ap color = color - a end return alpha end my problem is, it is visible for all players. but it should be just visible for me oO Link to comment
DarkLink Posted January 19, 2012 Share Posted January 19, 2012 instead of attaching the event to all the root attach to only local player like this: from this: addEventHandler("getTextClient",getRootElement(),getthesite) to this: addEventHandler("getTextClient",getLocalPlayer(),getthesite) i hope it fixes, gl Link to comment
BriGhtx3 Posted January 19, 2012 Author Share Posted January 19, 2012 Already tried this. Doesn't work Link to comment
BriGhtx3 Posted January 19, 2012 Author Share Posted January 19, 2012 got it : I triggered it wrong triggerClientEvent("getTextClient",source,tostring(thetext)) Link to comment
unknooooown Posted January 19, 2012 Share Posted January 19, 2012 Don't know if you already know this, but it's a good little tip if you don't know it. There are some predefined variables in MTA. Clientside: localPlayer = getLocalPlayer() root = getRootElement() Serverside: root = getRootElement() You don't have to write those lines to make it work. root and localPlayer works just fine without being defined in your script. 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