Jump to content

Jusonex

Retired Staff
  • Posts

    507
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by Jusonex

  1. Jusonex

    GPS system

    Thank you very much
  2. Jusonex

    GPS system

    okay, but what have I to do?
  3. Jusonex

    GPS system

    function findRotation(x1,y1,x2,y2) local X = math.abs( x2 - x1 ) local Y = math.abs( y2 - y1 ) Rotm = math.deg( math.atan2( Y , X ) ) if ( x2 >= x1 ) and ( y2 > y1 ) then -- north-east Rotm = 90 - Rotm elseif ( x2 <= x1 ) and ( y2 > y1 ) then -- north-west Rotm = 270 + Rotm elseif ( x2 >= x1 ) and ( y2 <= y1 ) then -- south-east Rotm = 90 + Rotm elseif ( x2 < x1 ) and ( y2 <= y1 ) then -- south-west Rotm = 270 - Rotm end return (360-Rotm) end local x, y, z = 0, 0, 0 function showArrow(player, seat, jacked) if ( player == getLocalPlayer() ) then local px, py, pz = getElementPosition(player) arrow = createObject(1318, px, py, pz) setElementCollisionsEnabled(arrow, false) addEventHandler("onClientPreRender", getRootElement(), rotArrow) end end addEventHandler("onClientVehicleEnter", getRootElement(), showArrow) function rotArrow() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local px, py, pz = getElementPosition(vehicle) local rotX, rotY, rotZ = getElementRotation(vehicle) local rot = findRotation(px, py, x, y) setElementPosition(arrow, px, py, pz+2) setElementRotation(arrow, 0, 90, rot+rotZ) end Ohh..you're right. I forgot to add the rotation of the vehicle. I changed this, but the direction of the arrow is still wrong.
  4. Jusonex

    GPS system

    hmmm...the result is exactly the same
  5. repeat until spawnPlayer ( player, -1517+math.random(1,5), 920+math.random(5,9), 10, 90, 0 )
  6. Jusonex

    GPS system

    Hey guys, I am scripting at the moment on a little navigation/GPS System for mta, but I've some problems. First of all my script: function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end return t end local x, y, z = 0, 0, 0 function showArrow(player, seat, jacked) if ( player == getLocalPlayer() ) then local px, py, pz = getElementPosition(player) arrow = createObject(1318, px, py, pz) setElementCollisionsEnabled(arrow, false) attachElements(arrow, source, 0, 0, 2) addEventHandler("onClientRender", getRootElement(), rotArrow) end end addEventHandler("onClientVehicleEnter", getRootElement(), showArrow) function rotArrow() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local px, py, pz = getElementPosition(vehicle) detachElements(arrow, vehicle) local rot = findRotation(px, py, x, y) attachElements(arrow, vehicle, 0, 0, 2, 0, 0, rot) outputChatBox(rot) end I think the calculation in function findRotation is not right, because I always get coords between 220 and 250. Where is the error? Justus EDIT: I saw a sa-mp video on youtube: http://www.youtube.com/watch?v=S4NhdeYyC8k
  7. Jusonex

    XML to table

    oh nice. that looks like good. thanks
  8. Jusonex

    XML to table

    Hey guys, I am scripting at the moment on a new freeroam script and I want to create a gui gridlist with all the vehicles. But my problem is xml. This is my code: (vehicles.xml is from freeroam) function xmlToTable() local root = xmlLoadFile("vehicles.xml") local groups = xmlNodeGetChildren(root) local vehicles = {} for i, node in ipairs(groups) do vehicles[xmlNodeGetName(node)] = xmlNodeGetAttribute(node, "id") end end I want to have a table like for example this vehicles["Helicopters"] = {548, 425, 417, 487, 488, 497, 563, 447, 469} why doesn't it work? Justus
  9. If the code is serverside, you forgot the "visible to" argument.
  10. Hello, I have a big problem. I am making a housesystem with a cam, with which you can skip from house to house. It works fine, but if there's a house, what is bought, i must repeat skipping until a house isn't bought. That's the important part of the code: local HouseID = 0 --local theID = 0 function skipUp(player) local bought = 0 local houses = executeSQLQuery("SELECT * FROM Housesystem WHERE bought = '"..bought.."'") for i, v in pairs (houses) do outputChatBox("Alle: v.ID: "..v.ID, player, 255, 255, 0) outputChatBox("Alle: HouseID: "..HouseID, player, 255, 0, 0) --theID = v.ID if ( v.ID >= HouseID ) then local x, y, z = v.cX, v.cY, v.cZ triggerClientEvent(player, "onTriggerHouseCam", getRootElement(), x, y, z, v.pINx, v.pINy, v.pINz, v.prize) outputChatBox("Aktuell: v.ID: "..v.ID, player, 255, 255, 0) outputChatBox("Aktuell: HouseID: "..HouseID, player, 255, 0, 0) HouseID = HouseID + 1 --theID = theID + 1 break --else --while ( v.bought == 1 ) do -- HouseID = HouseID + 1 --end --local x, y, z = v.cX, v.cY, v.cZ --triggerClientEvent(player, "onTriggerHouseCam", getRootElement(), x, y, z, v.pINx, v.pINy, v.pINz, v.prize) end end end I tried different things, but the problem doesn't go away. I hope you can help me Justus
  11. Jusonex

    Ped driver?

    yes, that´s right, but for a "ped driver" he have to use setPedControlState - clientside.
  12. Jusonex

    Ped driver?

    And the peds are clientside -> not synced
  13. Now, I habe that: function gui() local screenWidth, screenHeight = guiGetScreenSize() if screenHeight < 700 then g_MapSide = 450 else g_MapSide = 700 end local width = g_MapSide + 20 local height = g_MapSide local X = 0 local Y = 0 wdwMap = guiCreateWindow( X, Y, width, height, "Map", false ) imgMap = guiCreateStaticImage ( X, Y, g_MapSide, g_MapSide, "map.png", false, wdwMap ) addEventHandler("onClientGUIDoubleClick", imgMap, map, false) end function make() gui() if (wdwMap ~= nil) then guiSetVisible(wdwMap, true) else outputChatBox("Ein Problem mit der GUI besteht, bitte benachrichtige einen Admin") end showCursor(true) guiSetInputEnabled(true) end function map(button, state, relX, relY) local px = relX*6000 - 3000 local py = 3000 - relY*6000 outputChatBox(px) end addCommandHandler("taxi", make) But the results are wrong (if i click in the middle of the map i get cords like 400000. What is wrong?
  14. Here is the code: function spawnMapDoubleClick(relX, relY) setPlayerPosition(relX*6000 - 3000, 3000 - relY*6000, 0) closeWindow(wndSpawnMap) end function closeSpawnMap() showCursor(false) removeEventHandler('onClientRender', g_Root, updatePlayerBlips) for elem,data in pairs(g_PlayerData) do for i,name in ipairs({'mapBlip', 'mapLabelShadow', 'mapLabel'}) do if data.gui[name] then destroyElement(data.gui[name]) data.gui[name] = nil end end end end wndSpawnMap = { 'wnd', text = 'Select spawn position', width = g_MapSide + 20, controls = { {'img', id='map', src='map.png', width=g_MapSide, height=g_MapSide, ondoubleclick=spawnMapDoubleClick}, {'lbl', text='Welcome to freeroam. Double click a location on the map to spawn.', width=g_MapSide-60, align='center'}, {'btn', id='close', closeswindow=true} }, oncreate = warpMapInit, onclose = closeSpawnMap } But I don't understand it. Have someone a better and simpler example?
  15. No, i don't mean that. I want to do this for a taxi system. The co-driver gets a map, if he enters a taxi and he can click on the position (like in freeroam). But how can I create that. (scripting) Sorry for bad english
  16. Hello, how can I calc the coordinates/position from a map/image, like in resource "freeroam". Justus
×
×
  • Create New...