Jump to content

proracer

Members
  • Posts

    499
  • Joined

  • Last visited

Everything posted by proracer

  1. If you want to trigger function when player spawns use this: https://wiki.multitheftauto.com/wiki/OnClientPlayerSpawn Edit: Sorry, I understood wrong.
  2. https://wiki.multitheftauto.com/wiki/GetElementInterior https://wiki.multitheftauto.com/wiki/CreateObject
  3. Well you can save the account data when the car is spawned.
  4. Make sure you have ACL group called: "Admin".
  5. @Citizen: Text and picture is again in correct position but other people are reporting other positions and its in mess.What is wrong?
  6. Yes, I use 1920 x 1080 resolution in MTA if you mean that.
  7. My resolution is 1920 x 1080.
  8. Sorry if I'm so annoying but there is some small problem about DX Text and Image, player's are reporting that text and image are in mess (because of their resolution), I used frequently used method with optimizing text and image for every resolution but still nothing. So the conclusion: Problem is that people see text and image in wrong position that it needs to be... Here is the code: Important lines: 30-37 --[[ ** Distance To Hunter v1.0 - Made by Pr0RaC3R ** ** Special credits to Citizen & H5N1 from MTA Forum for helping me with some issues! ** --]] addEvent('onClientMapStarting') hunterX, hunterY, hunterZ = 0,0,0 local sWidth,sHeight = guiGetScreenSize ( ) function loadHunterPosition () for _,e in pairs ( getElementsByType ( "racepickup") or {} ) do -- Loop through race pickup elements (nitro, repair, vehiclechange) local t = getElementData (e, "type") if t and t == "vehiclechange" then local v = getElementData (e,"vehicle") if v and tonumber(v) == 425 then -- If it finds hunter pickup... hunterX, hunterY, hunterZ = getElementPosition ( e ) -- Get hunter position break end end end end function drawDistance ( ) loadHunterPosition ( ) local playerX, playerY, playerZ = getElementPosition ( getLocalPlayer( ) ) -- Get player position local distFromVehicleToHunter = getDistanceBetweenPoints3D ( playerX, playerY, playerZ, hunterX, hunterY, hunterZ ) -- Calculate distance dxDrawText ("Distance To Hunter:",sWidth-721,sHeight-55,sWidth-515,sHeight-36,tocolor(0,252,255,255),0.6,"bankgothic","left","top",false,false,false) -- Create DX Text dxDrawImage( (sWidth-699), (sHeight-31), (265), (30), "images/DistToHunter-Logo.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) dxDrawText( string.format("%.0f",distFromVehicleToHunter) .. " m ",sWidth-494,sHeight-54,sWidth-366,sHeight-35,tocolor(252,160,15,255),0.5,"bankgothic","left","top",false,false,false) end function handleRender ( ) addEventHandler ( 'onClientRender', root, drawDistance ) end addEventHandler ( 'onClientMapStarting', root, handleRender ) function delRender ( ) removeEventHandler ( 'onClientRender', root, drawDistance ) end addEventHandler ( 'onClientPlayerWasted', getLocalPlayer(), delRender ) function delRenderForDeath ( ) if ( getElementHealth ( getLocalPlayer() ) == '0' ) then removeEventHandler ( 'onClientRender', root, drawDistance ) end end
  9. Sorry, Citizen I understood your post somehow different but yeah it works thx dudes! +1 Lua XP
  10. Sorry for double post, but I found the problem that if there are more than 1 hunter pickup it duplicates text so how can I just retrieve position of 1 hunter pickup?
  11. --[[ ** Distance To Hunter v1.0 - Made by Pr0RaC3R ** --]] addEvent('onClientMapStarting') addEvent('onClientMapStopping') function distToHunter ( ) dxDrawText ("Distance To Hunter:",1199.0,1025.0,1405.0,1044.0,tocolor(0,252,255,255),0.6,"bankgothic","left","top",false,false,false) -- Create DX Text for _,e in pairs ( getElementsByType ( "racepickup") or {} ) do -- Loop through race pickup elements (nitro, repair, vehiclechange) local t = getElementData (e, "type") if t and t == "vehiclechange" then local v = getElementData (e,"vehicle") if v and tonumber(v) == 425 then -- If it finds hunter pickup... local hunterX, hunterY, hunterZ = getElementPosition ( e ) -- Get hunter position local playerX, playerY, playerZ = getElementPosition ( getLocalPlayer( ) ) -- Get player position local distFromVehicleToHunter = getDistanceBetweenPoints3D ( playerX, playerY, playerZ, hunterX, hunterY, hunterZ ) -- Calculate distance dxDrawText( string.format("%.0f",distFromVehicleToHunter) .. " m ",1426.0,1026.0,1554.0,1045.0,tocolor(252,160,15,255),0.5,"bankgothic","left","top",false,false,false) -- Draw it on the screen and format it to output without decimals end end end end function handleRender ( ) addEventHandler ( 'onClientRender', root, distToHunter ) end addEventHandler ( 'onClientMapStarting', root, handleRender ) function delRender ( ) removeEventHandler ( 'onClientRender', root, distToHunter ) end addEventHandler ( 'onClientMapStopping', root, delRender ) Shouldn't this delete text after map finished and then create it when map starts again? But it doesn't work .. still duplicates text (look my above post) Edit: Citizen, thx .. I will try it.
  12. Sure... Works (not duplicated) : Doesn't work (duplicated) :
  13. Sorry for double post, its buggy now only when it start other map but not the same as loaded the one before. I used race element data 's but I don't know if I used correctly because I can't found anywhere how it's called and what are their values... --[[ ** Distance To Hunter v1.0 - Made by Pr0RaC3R ** --]] function distToHunter ( ) dxDrawText ("Distance To Hunter:",1199.0,1025.0,1405.0,1044.0,tocolor(0,252,255,255),0.6,"bankgothic","left","top",false,false,false) -- Create DX Text for _,e in pairs ( getElementsByType ( "racepickup") or {} ) do -- Loop through race pickup elements (nitro, repair, vehiclechange) local t = getElementData (e, "type") if t and t == "vehiclechange" then local v = getElementData (e,"vehicle") if v and tonumber(v) == 425 then -- If it finds hunter pickup... local hunterX, hunterY, hunterZ = getElementPosition ( e ) -- Get hunter position local playerX, playerY, playerZ = getElementPosition ( getLocalPlayer( ) ) -- Get player position local distFromVehicleToHunter = getDistanceBetweenPoints3D ( playerX, playerY, playerZ, hunterX, hunterY, hunterZ ) -- Calculate distance dxDrawText( string.format("%.0f",distFromVehicleToHunter) .. " m ",1426.0,1026.0,1554.0,1045.0,tocolor(252,160,15,255),0.5,"bankgothic","left","top",false,false,false) -- Draw it on the screen and format it to output without decimals end end end end addEventHandler ( 'onClientRender', root, distToHunter ) --[[ - More simpler way is to just recreate it again with calling function again --]] function recreateDXText ( ) if (getElementData (getLocalPlayer( ), 'race.LoadingMap') == 'true') then distToHunter ( ) end end addEventHandler ( 'onClientElementDatachange', root, recreateDXText )
  14. https://wiki.multitheftauto.com/wiki/IsObjectInACLGroup
  15. Well ... the text won't appear when new map is started.
  16. I have done that already. Here is new code: addEvent("onClientMapStarting") addEvent("onClientMapStopping") function distToHunter ( ) dxDrawText ("Distance To Hunter:",1199.0,1025.0,1405.0,1044.0,tocolor(0,252,255,255),0.6,"bankgothic","left","top",false,false,false) -- Create DX Text for _,e in pairs ( getElementsByType ( "racepickup") or {} ) do -- Loop through race pickup elements (nitro, repair, vehiclechange) local t = getElementData (e, "type") if t and t == "vehiclechange" then local v = getElementData (e,"vehicle") if v and tonumber(v) == 425 then -- If it finds hunter pickup... local hunterX, hunterY, hunterZ = getElementPosition ( e ) -- Get hunter position local playerX, playerY, playerZ = getElementPosition ( getLocalPlayer( ) ) -- Get player position local distFromVehicleToHunter = getDistanceBetweenPoints3D ( playerX, playerY, playerZ, hunterX, hunterY, hunterZ ) -- Calculate distance dxDrawText( string.format("%.0f",distFromVehicleToHunter) .. " m ",1426.0,1026.0,1554.0,1045.0,tocolor(252,160,15,255),0.5,"bankgothic","left","top",false,false,false) -- Draw it on the screen (gets buggy when new map starts) end end end end addEventHandler ( "onClientRender", root, distToHunter ) addEventHandler ( "onClientMapStarting", getLocalPlayer ( ), distToHunter ) function destroyDXText ( ) removeEventHandler ( "onClientRender", root, distToHunter ) -- Force to remove it when player dies end addEventHandler ( "onClientMapStopping", getLocalPlayer ( ), destroyDXText )
  17. Hello guys.I have recently made script which calculates distance to the hunter .. but the problem is that it gets buggy when next map/s start (it duplicates again). I have already tried removing text when player dies but still nothing, please help. function distToHunter ( ) dxDrawText ("Distance To Hunter:",1199.0,1025.0,1405.0,1044.0,tocolor(0,252,255,255),0.6,"bankgothic","left","top",false,false,false) -- Create DX Text for _,e in pairs ( getElementsByType ( "racepickup") or {} ) do -- Loop through race pickup elements (nitro, repair, vehiclechange) local t = getElementData (e, "type") if t and t == "vehiclechange" then local v = getElementData (e,"vehicle") if v and tonumber(v) == 425 then -- If it finds hunter pickup... local hunterX, hunterY, hunterZ = getElementPosition ( e ) -- Get hunter position local playerX, playerY, playerZ = getElementPosition ( getLocalPlayer( ) ) -- Get player position local distFromVehicleToHunter = getDistanceBetweenPoints3D ( playerX, playerY, playerZ, hunterX, hunterY, hunterZ ) -- Calculate distance dxDrawText( distFromVehicleToHunter .. " m ",1426.0,1026.0,1554.0,1045.0,tocolor(252,160,15,255),0.5,"bankgothic","left","top",false,false,false) -- Draw it on the screen (gets buggy when new map starts) end end end end addEventHandler ( "onClientRender", root, distToHunter ) function destroyDXText ( ) removeEventHandler ( "onClientRender", root, distToHunter ) -- Force to remove it when player dies end addEventHandler ( "onClientPlayerWasted", getLocalPlayer ( ), destroyDXText ) Edit: Now it doesn't duplicate text but the text just wont appear on screen when next map starts.
  18. Teach yourself. https://wiki.multitheftauto.com/wiki/Main_Page
  19. Hm ... As I said I downloaded new textures from community and they give same error and I checked everything but I do not care now.
  20. I think it doesn't need to be that.I have some resource and everything is fine but with same error...
  21. Go take a look in meta.xml if everything is correct.
  22. proracer

    wht this?

    Probably you forgot to change file name in meta.xml and in lua file
  23. I also recommend SciTE (google it)
  24. Give it a try... (not tested) function playerStats() showCursor(true) -- GUI Elements local statWindow = guiCreateWindow ( 0.3367,0.0391,0.3352,0.3018, "Stats", true ) local label1 = guiCreateLabel(0.0676,0.1327,0.0956,0.0550, "Money:", true, statWindow) local label2 = guiCreateLabel(0.1702,0.1359,0.2153,0.0518, "" , true, statWindow) local label3 = guiCreateLabel(0.0676,0.2104,0.0956,0.0583, "Deaths:", true, statWindow) local label4 = guiCreateLabel(0.1725,0.2104,0.1538,0.0550, "" , true, statWindow) -- Element Data local playerMoney = getElementData (getLocalPlayer(), "data.cash") local playerDeaths = getElementData (getLocalPlayer(), "data.deaths") -- Set text for player to show element data guiSetText(label2, playerMoney) guiSetText(label4, playerDeaths) -- Visibility tweaking for stats if guiGetVisible(statWindow) == false then guiSetVisible(statWindow,true) else guiSetVisible(statWindow,false) end end addCommandHandler("stats", playerStats) You don't need to trigger any server event for this because you can use element data.
×
×
  • Create New...