Jump to content

codeluaeveryday

Members
  • Posts

    575
  • Joined

Everything posted by codeluaeveryday

  1. My server's one is based on tables, for an example, the button would be the exact language, I use the same method bandi recommended, so this is an example. Tables are more reliable and quicker than XML files: local translations = {} translations['English'] = { ['not well'] = 'not well`', ['Hello'] = 'Hello' } translations['Spanish'] = { ['not well'] = 'Mal', ['Hello'] = 'Hola' } -- Main Code addEventHandler('onClientResourceStart', resourceRoot, function() local englishButton = guiCreateButton(237, 61, 73, 29, "English", false, false) local spanishButton = guiCreateButton(237, 27, 73, 29, "Spanish", false, false) helloLabel = guiCreateLabel(242, 189, 146, 21, translations['English']['Hello'], false, false) notWellLabel = guiCreateLabel(242, 168, 146, 21,translations['English']['not well'], false, false) addEventHandler('onClientGUIClick', englishButton, buttonHandler) addEventHandler('onClientGUIClick', spanishButton, buttonHandler) end function buttonHandler() local selectedLanguage = guiGetText(source) guiSetText(helloLabel, translations[selectedLanguage]['Hello']) guiSetText(helloLabel, translations[selectedLanguage]['notWell']) end)
  2. Bandi94 appears to be missing the actual use of this code, I am using my own to create multi-lingual GUI's, if I was to ever use this I would use it for my GUI's.
  3. @Joker, The most common problem is most likely the port, try changing the SQL default port.
  4. StevyDK, whats your skype? I will give you my private one if you never share it with anyone else... My one is much more effective than these.
  5. Creating objects outside of the GTA:SA map creates multiple problems. It's not a MTA bug it's a GTA bug. Not using bandwidth reduction might increase the latency depending on how many clients and codes are running.
  6. Use onClientMinimize and onClientRestore Please read the wiki before asking... local scoreboardColumn = 'status' addEventHandler('onClientMinimize', getRootElement(), function() setElementData(localPlayer, scoreboardColumn, 'AFK') end ) addEventHandler('onClientRestore', getRootElement(), function() setElementData(localPlayer, scoreboardColumn, 'Active') end )
  7. Keep in mind race pickups use col shapes and other crap in the middle of it, try deleteing the colshape, or getElementsByType('race-pickup')
  8. You can't get the country from a local IP, it's simply impossible. Your local IP is related to your router and not other servers. It's just impossibru... just add a manual check for it.
  9. @Oxsotus, Using the map editor won't allow you to delete those bushes ( they have no col file ). You will need to manually find the ID of the bushes and then you need to make a lua script using the function provided by SolidSnake.
  10. Sorry this took so long, I am at school and I don't have much free time to do this: function privateMessage(thePlayer,commandName,sendToName,...) local pmWords = { ... } local pmMessage = table.concat( pmWords, " " ) if sendToName then if (getPlayerFromParticalName (sendToName)) then local toPlayer = (getPlayerFromParticalName (sendToName)) local toPlayerTeam = getPlayerTeam(toPlayer) if toPlayerTeam then local toRed, toGreen, toBlue = getTeamColor(toPlayerTeam) toColor = string.format("#%02X%02X%02X", toRed, toGreen, toBlue) else toColor = '#ffffff' end local fromPlayerTeam = getPlayerTeam(thePlayer) if fromPlayerTeam then local fromRed, fromGreen, fromBlue = getTeamColor(fromPlayerTeam) fromColor = string.format("#%02X%02X%02X", fromRed, fromGreen, fromBlue) else fromColor = '#ffffff' end if not (toPlayer == thePlayer) then if not (pmMessage == "") then outputChatBox("#0096ff[PM] to ".. toColor .. getPlayerName(toPlayer) .. ":#FFFFFF " .. pmMessage, thePlayer, 255, 255, 255, true) outputChatBox("#0096ff[PM] from " .. fromColor .. getPlayerName(thePlayer) .. ":#FFFFFF " .. pmMessage, toPlayer, 255, 255, 255, true) else outputChatBox("#0044FF[PM]#FFFFFF Invalid syntax! Usage:#FFFFFF /pm [player name] [message]", thePlayer, 255, 255, 255, true) return false end else outputChatBox("#0044FF[PM]#FFFFFF You cannot PM yourself#FFFFFF!", thePlayer, 255, 255, 255, true) return false end else outputChatBox("#0044FF[PM]#FFFFFF Player not found! #FFFF00(#FFFFFF"..sendToName.."#FFFF00)", thePlayer, 255, 255, 255, true) return false end else outputChatBox("#0044FF[PM]#FFFFFF Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", thePlayer, 255, 255, 255, true) return false end end addCommandHandler("pm", privateMessage) function getPlayerFromParticalName(thePlayerName) local thePlayer = getPlayerFromName(thePlayerName) if thePlayer then return thePlayer end for _,thePlayer in ipairs(getElementsByType("player")) do if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then return thePlayer end end return false end
  11. __ Hello Mossy, I have processed your idea and have came up with 2 possible solutions. I recommend Option 2, but I am not in the mood to really program it, I will help with Option 1 if you need help. Option #1) Modifying the race's default resource will block ALL maps from being able to call the respawn function. Option #2) I could create a small standalone Lua file and send it to you, you would place it in the folder of all maps then just run it and it will scan through each folder changing that attribute. You will have to give me a few moment's to code it, you should also add my Skype: chrisinater22.
  12. I saw it too, it's why my code actually changed it. I literally learn't that in grade 6 maths.
  13. You would have to create a php file to download the youtube video and convert it to a mp3 and then return it. I've been wondering this too...
  14. It pretty much works like that ^^, I usually use it for google graphs, I get the image data and then draw it in mta. It should work for you. I think its base 64.I guess you could do a screenshot system. Just trial and error it, you'll be fine.
  15. Remember to define the id or just replace it.
  16. I'm not the best person for opening up ports, my ISP doesn't allow us to open those connections, so unfortunatly I am unable to host a server on this network.
  17. Not sure if this is what you want, please edit it if it has errors: local soundLocation = 'http://d.liveatc.net/kjfk_twr' local soundMessage = 'Connecting to air traffic control (jka), please stand by.' addEventHandler('onClientResourceStart', getRootElement(), function(startedRes) if startedRes == getThisResource() then if isPedInVehicle(localPlayer) and getVehicleType(getPedOccupiedVehicle(localPlayer)) == 'Plane' then if getRadioChannel() ~= 0 then soundElement = playSound(soundLocation) outputChatBox(soundMessage) end end end end ) addEventHandler('onClientPlayerRadioSwitch', getRootElement(), function(radioID) if isPedInVehicle(localPlayer) and getVehicleType(getPedOccupiedVehicle(localPlayer)) == 'Plane' then if radioID ~= 0 then cancelEvent() soundElement = playSound(soundLocation) outputChatBox(soundMessage) elseif soundElement then setRadioChannel(0) stopSound(soundElement) soundElement = nil end end end ) addEventHandler('onClientPlayerVehicleEnter', getRootElement(), function(theVehicle, theSeat) if getVehicleType(theVehicle) == 'Plane' then if getRadioChannel() ~= 0 then soundElement = playSound(soundLocation) outputChatBox(soundMessage) end end end ) addEventHandler('onClientPlayerVehicleExit', getRootElement(), function(theVehicle, theSeat) if getVehicleType(theVehicle) == 'Plane' then if soundElement then setRadioChannel(0) stopSound(soundElement) soundElement = nil end end end )
  18. You guys didn't read what he wanted, learn English before attempting to read it. You guys failed at helping him, now please don't make this a rage war, it's a simple code.
  19. Claudio is a popular race mapper, he makes some of my most favourite maps, but Legend, you have no right to publish his map without his permission. You should censor the link.
  20. Your welcome! Guys I'd like to make more tutorials, suggest some too me
  21. Hey man, sorry that all these other scripters didn't know how to help you. Tell me if there's an error. function unemploy ( thePlayer ) local wlevel = getPlayerWantedLevel( thePlayer ) if wlevel < 6 then -- Changed from > to < local theTeam = getPlayerTeam ( thePlayer ) local teamName = getTeamName ( theTeam ) if teamName == "Police" or teamName == "SWAT" or teamName == "FBI" or teamName == "Army" then setPlayerTeam(thePlayer, getTeamFromName("Unemployed")) outputChatBox ("Menetit työsi koska olet korruptoitunut!", thePlayer, 255, 0, 0) end end end addCommandHandler('unemploy', unemploy)
  22. You can modify the me command using onPlayerChat: addEventHandler('onPlayerChat', getRootElement(), function(msg, msgType) if msgType == 1 then cancelEvent() outputChatBox('(ME) '..msg, getRootElement, 100, 200, 100) -- do what evah here end end )
  23. Client.lua local sounds = { ['join'] = 'join.wav', ['quit'] = 'quit.wav', ['login'] = 'login.wav', ['logout'] = 'logout.wav' } function startSound(sound) playSound(sounds[sound], false) end addEvent('startSound', true) addEventHandler('startSound', getRootElement(), startSound) addEventHandler('onClientPlayerJoin', getRootElement(), function() startSound('join') end ) addEventHandler('onClientPlayerQuit', getRootElement(), function() startSound('logout') end ) Server.lua: addEventHandler('onPlayerLogin', getRootElement(), function() triggerClientEvent('startSound', getRootElement(), 'login') end ) addEventHandler('onPlayerLogout', getRootElement(), function() triggerClientEvent('startSound', getRootElement(), 'logout') end )
  24. Ofc it wouldn't work, you didn't explain that was in a table... Edit line 11 to your liking. ------------------------------ -- -- Dashboard by Xiti -- ------------------------------ --48,110,255 #306EFF sX,sY = guiGetScreenSize() sY = sY - 100 scale = (sX/1920)*(sY/1200) menu = { anim = false, animate = false, top = { size = {sX,sY/13}, pos = {0,0-sY/13-sY/13/40}, fontS = 6*scale, }, bottom = { size = {sX,sY/10}, pos = {0,sY+sY/10+sY/40}, img = { url = {"data/img/map.png","data/img/tune.png","data/img/music.png","data/img/stats.png","data/img/plus.png","data/img/options.png"}, pos = {{sX/2-(((sY/10)+(sY/40))*3),sY},{sX/2-(((sY/10)+(sY/40))*2),sY},{sX/2-((sY/10)+(sY/40)),sY},{sX/2+(sY/40),sY},{sX/2+(((sY/10)+((sY/40)*2))),sY},{sX/2+(((sY/10))*2+(sY/40)*3),sY}}, size = {sY/10,sY/10}, alpha = {150,255,255,255,255,255,255} }, label = {"Map Shop","Tune","Music","Stats","Donator","Options"} }, alpha = 0, tick = getTickCount(), hover = 0, block = true, } digitalFont = dxCreateFont("data/font/digital.ttf",60*scale) function drawMenu() day,month,year,hours,minutes,seconds,day_name = getServerTime () -- Background -- Bottom bar -- dxDrawRectangle(menu.bottom.pos[1],menu.bottom.pos[2],menu.bottom.size[1],menu.bottom.size[2],tocolor(0,0,0,150),true) -- dxDrawRectangle(menu.bottom.pos[1],menu.bottom.pos[2]-menu.top.size[2]/40,menu.top.size[1],menu.top.size[2]/40,tocolor(48,110,255,120),true) for i=1,#menu.bottom.img.url do dxDrawImage(menu.bottom.img.pos[i][1],menu.bottom.img.pos[i][2],menu.bottom.img.size[1],menu.bottom.img.size[2],menu.bottom.img.url[i],0,0,0,tocolor(255,255,255,menu.bottom.img.alpha[i]),true) end end addEventHandler("onClientRender",getRootElement(),drawMenu) function animateMenu() if not menu.anim then menu.tick = getTickCount() menu.anim = true menu.animate = true showCursor(true) addEventHandler("onClientPreRender",getRootElement(),animMenuOn) addEventHandler("onClientPreRender",getRootElement(),animTopMenuOn) addEventHandler("onClientPreRender",getRootElement(),fadeBackground) else menu.anim = false menu.tick = getTickCount() menu.animate = true window.current = 0 showCursor(false) closeAllPickers() resetAllElementStates() addEventHandler("onClientPreRender",getRootElement(),animMenuOff) addEventHandler("onClientPreRender",getRootElement(),animTopMenuOff) addEventHandler("onClientPreRender",getRootElement(),fadeBackgroundOff) end end function openUserpanel() if not menu.animate then if not menu.block then animateMenu() else outputChatBox("#306EFF[OPEN] #ffffffYou need to be logged to open the userpanel.",255,255,255,true) end end end bindKey("u","down",openUserpanel) function allowBind(bOl) menu.block = not bOl if bOl then startLoginNotification() end end function animMenuOn() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animMenuOn) menu.animate = false end menu.bottom.pos[2] = interpolateBetween(sY,0,0,sY-sY/10,0,0,progress,"Linear") for i=1,#menu.bottom.img.url do menu.bottom.img.pos[i][2] = menu.bottom.pos[2] end end function animTopMenuOn() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animTopMenuOn) end menu.top.pos[2] = interpolateBetween(0-sY/13,0,0,0,0,0,progress,"Linear") end function fadeBackground() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),fadeBackground) end menu.alpha = interpolateBetween(0,0,0,90,0,0,progress,"Linear") end function animMenuOff() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animMenuOff) menu.animate = false end menu.bottom.pos[2] = interpolateBetween(sY-sY/10,0,0,sY+menu.top.size[2]/40,0,0,progress,"Linear") for i=1,#menu.bottom.img.url do menu.bottom.img.pos[i][2] = menu.bottom.pos[2] end end function animTopMenuOff() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),animTopMenuOff) end menu.top.pos[2] = interpolateBetween(0,0,0,0-sY/13-menu.top.size[2]/40,0,0,progress,"Linear") end function fadeBackgroundOff() local tick = getTickCount() - menu.tick local progress = tick/500 if progress >= 1 then progress = 1 removeEventHandler("onClientPreRender",getRootElement(),fadeBackgroundOff) end menu.alpha = interpolateBetween(90,0,0,0,0,0,progress,"Linear") end function hoverButtons() if isCursorShowing() and menu.anim then local x,y = getCursorPosition() local x,y = x*sX,y*sY if x>=menu.bottom.img.pos[1][1] and x<=menu.bottom.img.pos[1][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(1) elseif x>=menu.bottom.img.pos[2][1] and x<=menu.bottom.img.pos[2][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(2) elseif x>=menu.bottom.img.pos[3][1] and x<=menu.bottom.img.pos[3][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(3) elseif x>=menu.bottom.img.pos[4][1] and x<=menu.bottom.img.pos[4][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(4) elseif x>=menu.bottom.img.pos[5][1] and x<=menu.bottom.img.pos[5][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(5) elseif x>=menu.bottom.img.pos[6][1] and x<=menu.bottom.img.pos[6][1]+menu.bottom.img.size[1] and y>= menu.bottom.img.pos[1][2] then fadeButton(6) elseif x>=sX-dxGetTextWidth(day..", "..month.." "..year,menu.top.fontS,"default-bold")-100*scale and x<=sX and y<= menu.top.pos[2]+menu.top.size[2] then fadeButton(7) else fadeButton(0) end end end addEventHandler("onClientRender",getRootElement(),hoverButtons) fade = { current = 0, tick = getTickCount(), } function fadeButton(id) menu.hover = id if fade.current ~= id then fade.current = id fade.tick = getTickCount() end if fade.current ~= 0 then if fade.current ~= 7 then local tick = getTickCount() - fade.tick local progress = tick/1000 if progress >= 1 then progress = 1 end menu.bottom.img.alpha[fade.current] = interpolateBetween(menu.bottom.img.alpha[fade.current],0,0,255,0,0,progress,"Linear") drawLabel(fade.current) for i=1,#menu.bottom.img.alpha do if i ~= id then menu.bottom.img.alpha[i] = interpolateBetween(menu.bottom.img.alpha[i],0,0,150,0,0,progress,"Linear") end end else local tick = getTickCount() - fade.tick local progress = tick/1000 if progress >= 1 then progress = 1 end menu.top.fontS = interpolateBetween(menu.top.fontS,0,0,7*scale,0,0,progress,"Linear") drawLabel(fade.current) for i=1,#menu.bottom.img.alpha do menu.bottom.img.alpha[i] = interpolateBetween(menu.bottom.img.alpha[i],0,0,150,0,0,progress,"Linear") end end else local tick = getTickCount() - fade.tick local progress = tick/1000 if progress >= 1 then progress = 1 end for i=1,#menu.bottom.img.alpha do menu.bottom.img.alpha[i] = interpolateBetween(menu.bottom.img.alpha[i],0,0,150,0,0,progress,"Linear") end menu.top.fontS = interpolateBetween(menu.top.fontS,0,0,6*scale,0,0,progress,"Linear") end end function drawLabel(id) if id ~= 0 and menu.anim then if id ~= 7 then local text = menu.bottom.label[id] local rectX, rectY = dxGetTextWidth(text,3*scale,"default-bold")+(60*scale), dxGetFontHeight(3*scale,"default-bold")+(20*scale) dxDrawRectangle(menu.bottom.img.pos[id][1]+(menu.bottom.img.size[1]/2)-(rectX/2),menu.bottom.img.pos[1][2]-((menu.bottom.img.pos[1][2]/10)/2)-(rectY/2),rectX,rectY,tocolor(0,0,0,200),true) dxDrawText(text,menu.bottom.img.pos[id][1],menu.bottom.img.pos[1][2],menu.bottom.img.pos[id][1]+menu.bottom.img.size[1],menu.bottom.img.pos[1][2]-(menu.bottom.img.pos[1][2]/10),tocolor(48,110,255,255),3*scale,"default-bold","center","center",false,false,true) else local text = "news" local rectX, rectY = dxGetTextWidth(text,3*scale,"default-bold")+(60*scale), dxGetFontHeight(3*scale,"default-bold")+(20*scale) dxDrawRectangle(sX-(dxGetTextWidth(day..", "..month.." "..year,menu.top.fontS,"default-bold")/2)-(100*scale)/2-(rectX)/2,menu.top.pos[2]+menu.top.size[2]+((menu.bottom.img.pos[1][2]/10)/2)-(rectY/2),rectX,rectY,tocolor(0,0,0,200),true) dxDrawText(text,sX-dxGetTextWidth(day..", "..month.." "..year,menu.top.fontS,"default-bold")-100*scale,menu.top.pos[2]+menu.top.size[2],sX,menu.top.pos[2]+menu.top.size[2]+(menu.bottom.img.pos[1][2]/10),tocolor(48,110,255,255),3*scale,"default-bold","center","center",false,false,true) end end end window = { current = 0, tick = getTickCount(), draw = false, close = { hover = false, }, } function openWindow(id) if window.current ~= id then window.current = id window.tick =
×
×
  • Create New...