acp___(PL) Posted September 12, 2009 Share Posted September 12, 2009 (edited) Easy to script, if someone has a basic knowledge: a) height at which there is a checkpoint; b) direction to the next checkpoint (graphical indicator); c) distance to the next checkpoint. http://img16.imageshack.us/img16/6397/m ... 170443.png ad.a) 1- being above the positive value of the difference in hight ad.a) 2- being below the negative value of the difference in hight In MTAGUS I wrote scripts*, but with this I give up I'm working and I don't have enough time for play MTA:SA *) 20 best times on the map; expanded scoring system for winning races, taking into account the length of the race, the number of players, etc.; etc. ... Edited October 24, 2009 by Guest Link to comment
acp___(PL) Posted September 26, 2009 Author Share Posted September 26, 2009 What is wrong? ... and no number on the screen are displayed ... [13:03:32] WARNING: gps_s.lua: Bad argument @ 'setElementData' - Line: 7 meta.xml <meta> <script src="gps_s.lua" /> <script src="gps_c.lua" type="client"/> </meta> gps_c.lua local gMe = getLocalPlayer() local screenWidth, screenHeight = guiGetScreenSize() g_rot = getRootElement() addEventHandler ('onClientRender', g-rot function () local myX, meY, myHigh = getElementPosition(gMe) local cps = getElementData(g_Me, 'next.checkpoint') local cpX, cpY, cpHigh = getElementPosition(getElementsByType('checkpoint') [cps]) local distHigh = myHigh - cpHigh local distance = getDistanceBetweenPoints3D(myX, meY, myHigh, cpX, cpY, cpHigh) dxDrawText( distHigh, 5, screenHeight-200, tocolor ( 0, 0, 0, 255 ), 1, "pricedown") dxDrawText( distance, 5, screenHeight-230, tocolor ( 255, 255, 255, 255 ), 1, "pricedown") end ) gps_s.lua g_rot = getRootElement() addEvent('onPlayerReachCheckpoint') addEventHandler('onPlayerReachCheckpoint', g_rot, function (checkpoint) local ncp = checkpoint + 1 setElementData (thePlayer, 'next.checkpoint', ncp) end ) Link to comment
DakiLLa Posted September 26, 2009 Share Posted September 26, 2009 setElementData (source, 'next.checkpoint', ncp) i think it should be 'source' there. Link to comment
acp___(PL) Posted October 1, 2009 Author Share Posted October 1, 2009 work only one thing: outputChatBox ( "Cp number: " ..ncp, source, 0, 255, 0, 255 ) 22-35 in gps_s.lua I added just because I wanted to check if the in chat box will appear gps_s.lua g_rot = getRootElement() addEvent('onPlayerReachCheckpoint') addEventHandler('onPlayerReachCheckpoint', g_rot, function (checkpoint) local ncp = checkpoint + 1 setElementData (source, 'next.checkpoint', ncp) outputChatBox ( "Cp number: " ..ncp, source, 0, 255, 0, 255 ) triggerClientEvent ( source, "ClientGPStest", g_rot ) end ) gps_s.lua local gMe = getLocalPlayer() local screenWidth, screenHeight = guiGetScreenSize() g_rot = getRootElement() function createGPS() local myX, meY, myHigh = getElementPosition(gMe) local cps = getElementData(gMe, 'next.checkpoint') if not cps then local cps = 1 end local cpX, cpY, cpHigh = getElementPosition(getElementsByType('checkpoint') [cps]) local distHigh = myHigh - cpHigh local distance = getDistanceBetweenPoints3D(myX, meY, myHigh, cpX, cpY, cpHigh) dxDrawText( "TEST GPS", 5, screenHeight - 140, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown") dxDrawText( myHigh, 5, screenHeight - 170, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown") dxDrawText( distHigh, 5, screenHeight - 200, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown") dxDrawText( distance, 5, screenHeight - 230, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown") end addEventHandler("onClientResourceStart", g_rot, addEventHandler ('onClientRender', g-rot, createGPS) ) function createGPStextCP () local myX, meY, myHigh = getElementPosition(gMe) local cps = getElementData(gMe, 'next.checkpoint') if not cps then local cps = 1 end local cpX, cpY, cpHigh = getElementPosition(getElementsByType('checkpoint') [cps]) local distHigh = myHigh - cpHigh local distance = getDistanceBetweenPoints3D(myX, meY, myHigh, cpX, cpY, cpHigh) outputChatBox ( "High: " ..distHigh, 0, 0, 255, 255 ) outputChatBox ( "Distance: " ..distance, 0, 0, 255, 255 ) end addEvent ('ClientGPStest') addEventHandler ('ClientGPStest', g-rot, createGPStextCP) Link to comment
acp___(PL) Posted October 11, 2009 Author Share Posted October 11, 2009 already forgot about this topic: P text would not appear, enough to add it and it's working:) edit in line: 15, 16, 17 dxDrawText( "High: " ..myHigh, 5, screenHeight - 170, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown") dxDrawText( "Dist high: " ..distHigh, 5, screenHeight - 200, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown") dxDrawText( "Distance: " ..distance, 5, screenHeight - 230, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" Now I have to do arrows indicating how to display the direction to the cp ... Link to comment
acp___(PL) Posted October 24, 2009 Author Share Posted October 24, 2009 I do not know why this happens - arrows (see minimap) indicate the direction to the next CP (as in GPS) arrow once pointing at the correct direction once pointing at the inverted 180 degrees direction local gMe = getLocalPlayer() local screenWidth, screenHeight = guiGetScreenSize() local screenPlayerWidth = screenWidth / 1280 local screenPlayerHeight = screenHeight / 1024 local g_rot = getRootElement() function createGPS() local myRX, myRY = nil local cp_listGPS = nil local cps = nil local cpX, cpY, cpHigh = nil local myX, myY, myHigh = getElementPosition(gMe) local playerGPSvehicle = getPedOccupiedVehicle(gMe) local in_what_player_are = getVehicleType(playerGPSvehicle) local distHigh = myHigh local distance = 0 if in_what_player_are then myRX, myRY, myRZ = getElementRotation ( playerGPSvehicle ) cp_listGPS = getElementsByType('checkpoint') cps = getElementData(gMe, 'next.checkpoint') cpX, cpY, cpHigh = getElementPosition(cp_listGPS[cps]) distHigh = myHigh - cpHigh distance = getDistanceBetweenPoints3D(myX, myY, myHigh, cpX, cpY, cpHigh) local distNorth = getDistanceBetweenPoints2D(myX, myY, myX, cpY) local distToPoint = getDistanceBetweenPoints2D(myX, myY, cpX, cpY) local cosinusGPS = distNorth / distToPoint local angelGPSbezwzgledny = math.acos(cosinusGPS) local angelDegGPSabs = angelGPSbezwzgledny * (180 / math.pi) local angelGPS = angelDegGPSabs + myRZ -- dxDrawImage( math.floor((174-(72/2))*screenPlayerWidth), math.floor((872-(130/2))*screenPlayerHeight), math.floor(72*screenPlayerWidth), math.floor(130*screenPlayerHeight), "strzalkagps.png", angelGPS) end end addEventHandler("onClientResourceStart", g_rot, addEventHandler ('onClientRender', g_rot, createGPS) ) 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