Jump to content

.:HyPeX:.

Members
  • Posts

    1,255
  • Joined

  • Last visited

Everything posted by .:HyPeX:.

  1. function drowning() getPedOxygenLevel ( localPlayer ) local oxygen = getPedOxygenLevel ( localPlayer ) if oxygen == 0 then if not sounding then local sound = playSound("sounds/drowning_sound.mp3",false) setSoundVolume (sound, 3.5) sounding = true setTimer(function() sounding = nil end, 3000,1) end end end addEventHandler("onClientPlayerDamage", getLocalPlayer(), drowning) Btw, the first lina is wrong, or at least weird... (Or you copied the code over badly)
  2. Search down this forum,i remember there was a topic about this. And by the way, string.split is a useful function, you added it into the script? (Also check debug)
  3. Aaaah i see. It was your bad. You didnt defined Look at XYZ. Check for some matrices on how to find the front of the ped to aim and then add an extra rotation according to aim
  4. Try this. it should have an effect upon moving the ped... function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix (element) local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z end addEventHandler("onClientRender", getRootElement(), function() local _,_,rot = getElementRotation(localPlayer) local max = 3 local angle = math.rad(rot+90) -- +90 to actually make it from the "back" of the ped. local plusX,plusY = math.cos(angle)*max,math.sin(angle)*max local x,y,z = getPositionFromElementOffset(localPlayer,plusX,plusY, 0.5) setCameraMatrix(x, y, z, x, y, z) end )
  5. Ah you mean when the ped rotates to make the camera follow him? Try this, i'm not sure thought. function getPositionFromElementOffset(element,offX,offY,offZ) local m = getElementMatrix (element) local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1] local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] return x, y, z end addEventHandler("onClientRender", getRootElement(), function() local _,_,rot = getElementRotation(localPlayer) local max = 3 local angle = math.rad(rot+90) -- +90 to actually make it from the "back" of the ped. local plusX,plusY = math.cos(angle)*max,math.sin(angle)*max local x,y,z = getPositionFromElementOffset(localPlayer, 0.5 + plusX, -3 + plusY, 0.5) setCameraMatrix(x, y, z, x, y, z) end )
  6. Why so? its just moving off with the event..
  7. Yeah, pretty much. https://wiki.multitheftauto.com/wiki/GetElementMatrix Read the examples mostly. Then for rotation, https://wiki.multitheftauto.com/wiki/OnClientCursorMove.
  8. a shader transform seems the only other viable option, but i dont have any experience/knowledge with shaders.. so i'll have to wait aswell.. Thanks for your help BTW: The texts apart from the toptimes & mapname are not being drawn, but i think i know the issue for that. (Not using 0 as start for the drawn being on render target)
  9. Yes, there's a bug with that. But now it looks bad as shit. http://i.imgur.com/L5pv5GA.jpg Plus, there's a delay if you move the camera, so it looks weird. My whole idea was to make a 3D animation, in wich else way could i do this? a texture?
  10. I dont know how that code should help me... But ineeded, the drawing values should actually be fine... local width2 = 450/1360+((50/1360)*2) local space = dxGetTextWidth(" ",1,"default") local topspace = dxGetTextWidth(" 1",1,"default") local namespace = dxGetTextWidth("2222222222222222222222",1,"default") local timespace = dxGetTextWidth("22:22:22",1,"default") local datespace = dxGetTextWidth("56.56.56",1,"default") local flagspace= dxGetTextWidth("2222",1,"default") local width = space+topspace+space+namespace+space+timespace+space+flagspace+space+datespace+space +((50/1360)*x*2) local centerX = x - width/2 local startX = centerX - width/2 - (20/1360)*x --- local nX,nY,nZ = getWorldFromScreenPosition(startX,hd*y+(h*y/2),0) local nX2,nY2,nZ2 = getWorldFromScreenPosition(startX+(width2*x),hd*y+(h*y/2),0) EDIT: Just came across something.. i'm using distance 0, so that could cause a bug in MTA (Cause the image is being drawn exactly behind my camera?) i'll test it right now. If that was the cause, i'll edit the wiki and notice that.
  11. If there is, i would certainly start working in prototypes to be inbetween the first ones to have an ingame browser
  12. Yeah, apparently that was kinda fucking up. Now my issue is: On your code nothing is being drawn. (Thought it should, as long as the material line is being "drawn" and there are no debug errors...)
  13. Well, in my dxDrawImage with render target i see the png, in the material line with render target, i dont. (I still see some text i drawed on it thought) local nX,nY,nZ = getWorldFromScreenPosition(startX,hd*y+(h*y/2),0) local nX2,nY2,nZ2 = getWorldFromScreenPosition(startX+(width2*x),hd*y+(h*y/2),0) local eX,eY,eZ = getWorldFromScreenPosition(startX+(width2*x/2),hd*y+h*y,0) dxSetRenderTarget(target,true) dxSetBlendMode("modulate_add") dxDrawImage(0, 0,width2*x,h*y,"misc/bg.png") dxSetRenderTarget() dxSetBlendMode("blend") if target then --dxDrawImage(startX, hd*y,width2*x,h*y,target) dxDrawMaterialLine3D(nX,nY,nZ,nX2,nY2,nZ2,target,width2*x) end EDIT: Drawing the actual image as a texture with the function doesnt work either. local mat = dxCreateTexture("misc/bg.png") -- dxDrawMaterialLine3D(nX,nY,nZ,nX2,nY2,nZ2,mat,width2*x) dxDrawMaterialLine3D(nX,nY,nZ,nX2,nY2,nZ2,target,width2*x) EDIT: Whole function, what i'm doing wrong? if i stop drawing the material lines it should stop drawing the texts.. that they're assumed to be drawn on the target.. function renderToptimes() if not bold then return end local nX,nY,nZ = getWorldFromScreenPosition(startX,hd*y+(h*y/2),0) local nX2,nY2,nZ2 = getWorldFromScreenPosition(startX+(width2*x),hd*y+(h*y/2),0) local eX,eY,eZ = getWorldFromScreenPosition(startX+(width2*x/2),hd*y+h*y,0) dxSetRenderTarget(target) dxSetBlendMode("modulate_add") dxDrawImage(0, 0,width2*x,h*y,"misc/bg.png") --dxDrawImage(fix3+sx2, hd*y+h/2*y,width*x,h*y,"misc/bg.png") --dxDrawRectangle(sx, hd*y,width*x,y*0.03,tocolor(70,70,70,150)) --dxDrawRectangle(sx, hd*y,width*x,h*y,tocolor(0,0,0,180)) local width22 = dxGetTextWidth("Toptimes ", 1*scale,sansb) local width33 = dxGetTextWidth(mapname,1*scale,sansd) dxDrawText("Toptimes ", 0+fix4+((width3*x)/2)-width33/2-width22,0+fixy3,width+fix4,0+y*0.025+fixy3,tocolor(255,255,255,255),1*scale,sansb,"left","center") dxDrawText(mapname, 0+fix4+(width3*x/2)-width33/2,0+fixy3,width+fix4,0+y*0.025+fixy3,tocolor(255,255,255,255),1*scale,sansd,"left","center") --[[dxDrawText("#",fix+sx+x*0.01,fixy+y*0.05+ hd*y+y*0.01,width*x+sx,fixy+y*0.05+hd*y,tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,true,true,true) dxDrawText("Name",fix+sx+x*0.025,fixy+y*0.05+ hd*y+y*0.01,width*x+sx,fixy+y*0.05+hd*y,tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,true,true,true) dxDrawText("Time",fix+sx+x*0.145,fixy+y*0.05+ hd*y+y*0.01,width*x+sx,fixy+y*0.05+hd*y,tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,true,true,true) dxDrawText("Location",fix+sx+x*0.2,fixy+y*0.05+ hd*y+y*0.01,width*x+sx,fixy+y*0.05+hd*y,tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,true,true,true) dxDrawText("Date",fix+sx+x*0.26,fixy+y*0.05+ hd*y+y*0.01,width*x+sx,fixy+y*0.05+hd*y,tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,true,true,true) ]] local flagwidth = 15/1280*x local flagheight = 10/720*y local fwidth = dxGetTextWidth("Location", 1*scale,sansb) local base = base or 1 local tablefind = nil for i=base, base+7 do if not defaultTable[i] then defaultTable[i] = {serial="...",name="-- Empty --",time=0,country="ZZ",date=getRealTime().timestamp} end local serial = defaultTable[i].serial or "" local name = defaultTable[i].name or "-- Empty --" local time = defaultTable[i].time or 0 local date = defaultTable[i].date or getRealTime().timestamp local country = defaultTable[i].country or "ZZ" if serial == getPlayerSerial(localPlayer) then --dxDrawRectangle(sx,y*0.04+hd*y+y*0.005 +(y*0.025*(i-base+1)),width*x,y*0.025,tocolor(100,100,100,50)) --dxDrawImage(fix+sx,fixy+y*0.04+hd*y+y*0.005 +(y*0.025*(i-base+1)),width*x,y*0.025,"misc/chosen.png",0,0,0,tocolor(255,255,255,255)) dxDrawRectangle(0+fix4,fixy+0+y*0.045+(y*0.025*(i-base+1)),width-fix5,y*0.025,tocolor(10,10,10,100)) end dxDrawText(i,startX2+space,fixy+y*0.04+ hd*y+y*0.01 + (y*0.025*(i-base+1)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(i+1-base+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,true,true,true) dxDrawText(defaultTable[i].name,startX2+space+topspace+space,y*0.04+ hd*y+fixy+y*0.01 + (y*0.025*(i-base+1)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(i+1-base+1)),tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,true,true,true) if time then if time == 0 then ms,min,sec = "---","--","--" else time = tostring(defaultTable[i].time) ms = tostring(math.round(tonumber((time/1000 - ("%02d"):format(time/1000))*1000))) min = (((time-ms)/1000)/(60)) diff = (min - math.floor(min))*60 ms = ("%03d"):format(tostring(math.round(ms))) min = ("%02d"):format(tostring(math.round(min))) sec = ("%02d"):format(tostring(math.round(diff))) end dxDrawText(min..":"..sec..":"..ms,startX2+space+topspace+space+namespace+space,fixy+hd*y+y*0.05 + (y*0.025*(i-base+1)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(i+1-base+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,true,true,true) end --dxDrawText(defaultTable[i].country,sx+x*0.01,y*0.04+ hd*y+y*0.01 + (y*0.025*i),width*x+sx,y*0.04+hd*y+(y*0.025*(i+1)),tocolor(255,255,255,255),0.55,semibold,"left","center",false,false,true,true) if defaultTable[i].country:lower()~="zz" then dxDrawImage(startX2+space+topspace+space+namespace+space+timespace+space+flagwidth/2,fixy+hd*y+y*0.057+(y*0.025*(i-base+1))-flagheight/2,flagwidth,flagheight,"flags/"..defaultTable[i].country:lower()..".png",0,0,0,tocolor(220,220,220,255),true) end local time = getRealTime(defaultTable[i].date) local str = time.monthday or 1 local months = {"Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"} local str = str.."."..(time.month+1) local str = str.."."..time.year+1900 dxDrawText(str,startX2+space+topspace+space+namespace+space+timespace+space+flagspace+space,y*0.04+fixy+ hd*y+y*0.01 + (y*0.025*(i-base+1)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(i+1-base+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,true,true,true) end for a=1, table.size(defaultTable) do if defaultTable[a] then if defaultTable[a].serial == getPlayerSerial(localPlayer) then local a,b = a,9 dxDrawRectangle(0+fix4,0+y*0.085 +(y*0.025*(b)),width-fix5,y*0.025,tocolor(10,10,10,100)) dxDrawText(a,startX2+space,fixy+y*0.04+ hd*y+y*0.01 + (y*0.025*(b)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(b+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,true,true,true) dxDrawText(defaultTable[a].name,startX2+space+topspace+space,y*0.04+ hd*y+fixy+y*0.01 + (y*0.025*(b)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(b+1)),tocolor(255,255,255,255),1*scale,sansb,"left","center",false,false,true,true,true) local time = tostring(defaultTable[a].time) local ms = tostring(math.round(tonumber((time/1000 - ("%02d"):format(time/1000))*1000))) local min = (((time-ms)/1000)/(60)) local diff = (min - math.floor(min))*60 local ms = ("%03d"):format(tostring(math.round(ms))) local min = ("%02d"):format(tostring(math.round(min))) local sec = ("%02d"):format(tostring(math.round(diff))) if tonumber(time) == 0 then dxDrawText("--:--:---",startX2+space+topspace+space+namespace+space,fixy+hd*y+y*0.05 + (y*0.025*(b)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(b+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,true,true,true) else dxDrawText(min..":"..sec..":"..ms,startX2+space+topspace+space+namespace+space,fixy+hd*y+y*0.05 + (y*0.025*(b)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(b+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,true,true,true) end local time = getRealTime(defaultTable[a].date) local str = time.monthday or 1 local months = {"Jan","Feb","March","April","May","June","July","Aug","Sep","Oct","Nov","Dec"} local str = str.."."..(time.month+1) local str = str.."."..time.year+1900 dxDrawText(str,startX2+space+topspace+space+namespace+space+timespace+space+flagspace+space,y*0.04+fixy+ hd*y+y*0.01 + (y*0.025*(b)),width*x+sx,fixy+y*0.04+hd*y+(y*0.025*(b+1)),tocolor(255,255,255,255),1*scale,sansd,"left","center",false,false,true,true,true) if defaultTable[a].country:lower()~="zz" then dxDrawImage(startX2+space+topspace+space+namespace+space+timespace+space+flagwidth/2,fixy+hd*y+y*0.057+(y*0.025*(b))-flagheight/2,flagwidth,flagheight,"flags/"..defaultTable[a].country:lower()..".png",0,0,0,tocolor(255,255,255,255),true) end end end end --dxDrawText("Test Text", x*0.4,y*0.5,x,y,tocolor(255,255,255,255),6.1,"clear","left","top",false,false,true,true,true) --dxDrawText("Test Text", x*0.4,y*0.65,x,y,tocolor(255,255,255,255),1,clear,"left","top",false,false,true,true,true) dxSetRenderTarget() dxSetBlendMode("blend") if target then --dxDrawImage(startX, hd*y,width2*x,h*y,target) --dxDrawMaterialLine3D(nX,nY,nZ,nX2,nY2,nZ2,mat,width2*x) --dxDrawMaterialLine3D(nX,nY,nZ,nX2,nY2,nZ2,target,width2*x) end end
  14. Actually, i like the simplicity of mysql sorting over table.sort, rather than by its performance. I'll do a live test later. Thanks guys.
  15. That didnt worked... http://www.w3schools.com/sql/trysql.asp ... t_distinct
  16. Hello, how can i order a table by a column? I can already retrive the value while selecting with "ORDER BY", but that wont change the table rows. How can i actually change the table rows? Greetz HyPeX
  17. Oh. That would explain kinda some things... Hah.
  18. Hey i always wondered if there was some way to create a multi-pixel thingy animation (Like random pixels would start to appear to eventually form a full image), would you be able to recreate that? So far, amazing work, loved day 5!
  19. Well, this always returns "ZZ", wich means the country wasnt retrived. local country = call(getResourceFromName("admin"),"getPlayerCountry",source) or "ZZ" local country = country:lower() Source is correctly defined, i already checked. But somehow, this function doesnt works. I cant retrive a player's country.
  20. Thanks, and about the braticks part, i'll check later on.
  21. Well, i cant check if the serial was already introduced, it simply does not retrive the values.. function addNewTime(map,player,serial,time,name,country,date) local map = getMapName(map) outputChatBox(map) local query = dbQuery(Database,"SELECT * FROM "..md5(map).." WHERE serial = '"..serial.."';") local result = dbPoll(query,-1) local g_Time=nil local vask = nil if result then outputChatBox("rowing") for _,row in ipairs(result) do outputChatBox("rowing2") for column,value in ipairs(row) do outputChatBox(column) outputChatBox(value) outputChatBox(column.." "..value) if column == "serial" then if value == serial then vask = true end elseif column == "time" then g_Time = value end end end if not vask then local query = dbQuery(Database,"INSERT INTO "..md5(map).." (serial,name,time,country,date) VALUES ('"..serial.."','"..name.."','"..time.."','"..country.."','"..date.."');") local result = dbPoll(query,-1) if result then outputChatBox("top added!") else outputChatBox("top not added!") end Output: Hypex-Testtopmap rowing rowing2 rowing2 top added! Table in mysql.. http://i.imgur.com/V4MAVHK.png Thanks in advance
  22. Found my issue... -- Race_joiner triggerServerEvent('onLoadedAtClient', g_Me) -- My login triggerServerEvent('onLoadedAtClient', getResourceRootElement(getResourceFromName("race")), localPlayer ) Changed it to this and worked triggerServerEvent('onLoadedAtClient', localPlayer, localPlayer )
  23. I dont have an issue on scaling. I have an issue more on how to get rounded numbers after doing math.. most likely i will need to do an after check..
  24. local x,y = guiGetScreenSize() local scale = 2 local maxW = x*0.103 function callBackMe3() local text = "WAITING FOR PLAYERS.." local w = dxGetTextWidth(text, scale, "arial") local scale = scale if w > maxW then else killTimer(callMe3) fontCreation() outputChatBox(scale) end end callMe3 = setTimer(function() scale = scale - 0.01 callBackMe3() end, 50, 0) Takes some time to actually load if the resolution is small, and it isnt guaranteed to work in extrememly large resolutions. Other than that, flawless. If you're bored, make it onClientRender re-sizing. will be much faster. But anyways..
×
×
  • Create New...