Fabioxps Posted April 1, 2013 Share Posted April 1, 2013 (edited) messages are for players of the same language if getElementData(player,"Idiomas") == "inglês" then Client local g_Window = nil function exemplo() if g_Window then return end g_Window = {} local screenWidth, screenHeight = guiGetScreenSize() g_Window.windowWidth, g_Window.windowHeight = 400, 315 local left = screenWidth/2 - g_Window.windowWidth/2 local top = screenHeight/2 - g_Window.windowHeight/2 g_Window.window = guiCreateWindow(left, top, g_Window.windowWidth, g_Window.windowHeight, "Idiomas", false) g_Window.portugues = guiCreateButton(50, 100, 150, 100, "Portugues", false, g_Window.window) g_Window.ingles = guiCreateButton(200, 100, 150, 100, "inglês", false, g_Window.window) g_Window.closeBtn = guiCreateButton(320, 285, 150, 100, "Close", false, g_Window.window) guiWindowSetSizable(g_Window.window, false) guiWindowSetMovable(g_Window.window, false) guiSetEnabled(g_Window.window, false) guiSetVisible(g_Window.window, true) g_Window.startTime = getTickCount() g_Window.startSize = {0, 0} g_Window.endSize = {g_Window.windowWidth, g_Window.windowHeight} g_Window.endTime = g_Window.startTime + 1000 addEventHandler("onClientRender", getRootElement(), popWindowUp) end bindKey ( "f1", "down", exemplo) function Portugues() outputChatBox("idioma Portugues.", 0, 255, 0, false) setElementData(localPlayer, "Idioma", "Portugues") end function Ingles() outputChatBox("idioma inglês.", 0, 255, 0, false) setElementData(localPlayer, "Idioma", "inglês") end function on_closeBtn_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end if not g_Window then return end showCursor(false) guiSetEnabled(g_Window.window, false) guiWindowSetMovable(g_Window.window, false) local screenWidth, screenHeight = guiGetScreenSize() local posX, posY = guiGetPosition(g_Window.window, false) g_Window.startTime = getTickCount() g_Window.startSize = {g_Window.windowWidth, g_Window.windowHeight} g_Window.startCenter = { posX + g_Window.windowWidth/2, posY + g_Window.windowHeight/2, } g_Window.endSize = {0, 0} g_Window.endTime = g_Window.startTime + 1000 g_Window.endCenter = { screenWidth, screenHeight } addEventHandler("onClientRender", getRootElement(), popWindowDown) end function popWindowUp() local now = getTickCount() local elapsedTime = now - g_Window.startTime local duration = g_Window.endTime - g_Window.startTime local progress = elapsedTime / duration local width, height, _ = interpolateBetween ( g_Window.startSize[1], g_Window.startSize[2], 0, g_Window.endSize[1], g_Window.endSize[2], 0, progress, "OutElastic") guiSetSize(g_Window.window, width, height, false) local screenWidth, screenHeight = guiGetScreenSize() guiSetPosition(g_Window.window, screenWidth/2 - width/2, screenHeight/2 - height/2, false) if not guiGetVisible(g_Window.window) then guiSetVisible(g_Window.window, true) guiBringToFront(g_Window.window) end if now >= g_Window.endTime then guiSetEnabled(g_Window.window, true) guiBringToFront(g_Window.window) removeEventHandler("onClientRender", getRootElement(), popWindowUp) addEventHandler("onClientGUIClick", g_Window.closeBtn, on_closeBtn_clicked, false) addEventHandler("onClientGUIClick", g_Window.portugues, Portugues, false) addEventHandler("onClientGUIClick", g_Window.ingles, Ingles, false) showCursor(true) guiWindowSetMovable(g_Window.window, true) end end function popWindowDown() local now = getTickCount() local elapsedTime = now - g_Window.startTime local duration = g_Window.endTime - g_Window.startTime local progress = elapsedTime / duration local width, height, _ = interpolateBetween ( g_Window.startSize[1], g_Window.startSize[2], 0, g_Window.endSize[1], g_Window.endSize[2], 0, progress, "InQuad") guiSetSize(g_Window.window, width, height, false) local centerX, centerY, _ = interpolateBetween ( g_Window.startCenter[1], g_Window.startCenter[2], 0, g_Window.endCenter[1], g_Window.endCenter[2], 0, progress, "InQuad") guiSetPosition(g_Window.window, centerX - width/2, centerY - height/2, false) if now >= g_Window.endTime then removeEventHandler("onClientRender", getRootElement(), popWindowDown) destroyElement(g_Window.window) g_Window = nil end end Server chat_range=100 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"l","down","chatbox","Language") bindKey(source,"g","down","chatbox","Global") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"l","down","chatbox","Language") bindKey(player,"g","down","chatbox","Global") end end) function isPlayerInRangeOfPoint(player,x,y,z,range) local px,py,pz=getElementPosition(player) return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range end function onChat(player,_,...) --if getElementData(player,"Idiomas") == "inglês" then local px,py,pz = getElementPosition(player) local msg = table.concat({...}, " ") local nick = getPlayerName(player) local idiomas = getElementData(player,"Idioma") for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("#ff0000("..idiomas..")#ffffff "..nick.."#ffffff: "..msg,v,r,g,b,true) end end --end end addCommandHandler("Language",onChat) function Globals(player,_,...) local px,py,pz = getElementPosition(player) local msg = table.concat({...}, " ") local nick = getPlayerName(player) for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("#FF6464(Global)#ffffff "..nick.."#ffffff: "..msg,v,r,g,b,true) end end end addCommandHandler("Global",Globals) Edited April 1, 2013 by Guest Link to comment
DNL291 Posted April 2, 2013 Share Posted April 2, 2013 Try this (client): function Portugues() if getElementData(localPlayer,"Idioma") == "inglês" then return end outputChatBox("idioma Portugues.", 0, 255, 0, false) setElementData(localPlayer, "Idioma", "Portugues") end function Ingles() if getElementData(localPlayer,"Idioma") == "Portugues" then return end outputChatBox("idioma inglês.", 0, 255, 0, false) setElementData(localPlayer, "Idioma", "inglês") end 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