Jump to content

Timiimit

Members
  • Posts

    142
  • Joined

  • Last visited

Everything posted by Timiimit

  1. i did: function checkLanding (hitElement, force, bodypart, colX, colY, colZ, normX, normY, normZ) if(source ~= veh)then return end local m = getElementMatrix(veh) local vecX, vecY, vecZ = m[3][1], m[3][2], m[3][3] local nRot = 0.05 if math.abs(vecX - normX) <= nRot and math.abs(vecY - normY) <= nRot and math.abs(vecZ - normZ) <= nRot then outputChatBox("landed like a boss!") end end and i get 0-2 outputs (depends on the speed) when i'm not even in the air yet (still on ramp or when ground angle changes) and 1-3 outputs when i land.
  2. this is what i got: function checkLanding (hitElement, force, bodypart, colX, colY, colZ, normX, normY, normZ) if(source ~= veh)then return end local m = getElementMatrix(veh) local vecX, vecY, vecZ = m[3][1], m[3][2], m[3][3] local nRot = 8 if not wasOnGround and (vecZ - normZ <= nRot) then outputChatBox("vZ: " .. vecZ .. ", normZ: " .. normZ) end end addEventHandler("onClientVehicleCollision", getRootElement(), checkLanding) wasOnGround is isVehicleOnGround of the previous frame. i thought that normZ is up vector of collision, but now i see that all normX, normY and normZ are direction. So how am i able to compare normX, Y and Z with ony one vecZ? (im not sure that i understand the picture here)
  3. I haven't learned matrices in school yet so i'm not sure how they work (all i know about them, is that they are table of numbers). Could anyone show me how you get the up vector of the vehicle and the up vector of the surface of collision (onClientVehicleCollision).
  4. Well the easiest way is still pretty hard! I'll try as soon as I'll be able to.
  5. Hello all! I haven't post for a very long time now mostly because i am using wiki . Does anyone know how to detect that vehicle landed on 4 wheels (not 0 XY rotation, but 0 XY rotation relative to the element that player landed on)? i have no clue how to even find element that vehicle landed on... please help!
  6. I have!! but don't know how to fix it!
  7. ok i figured it out! But i need to know how to calculate where is 1 unit infront of ped! And i have no idea how! help?!!
  8. Timiimit

    help fix bug!

    Hi! I must fix bug at map editor! look at this video to see what happens. you don't have to make comment if u know how to fix. You can make post here!!!
  9. help with working script!
  10. it can be deleted by anyone!
  11. ok! This is what i have: botPed = null function createBot() if (botPed == null ) then botPed = createPed( 312, 1989, -2190, 14, 180, 0, 180 ) outputConsole("Bot is in game!") else outputConsole("Bot already exists.") end end function deleteBot() if (botPed ~= null) then destroyElement( botPed ) outputConsole("Bot has been deleted.") botPed = null else outputConsole("No bot to remove.") end end function smartBotON() setPedAnimation( botPed, "ped", "run_player" ) -- detection event addEventHandler( "onClientRender", getRootElement(), detecting ) -- detecting event outputConsole( "Bot is now smart!" ) end function standBot() setPedAnimation( botPed ) outputConsole( "Bot is standing still." ) removeEventHandler( "onClientRender", getRootElement(), detecting ) end function detecting( element, dim ) -- detection hit -- if hit must do "botHit()" end function botTurn() if (botPed ~= null) then outputDebugString("Bot turned in random direction.") outputConsole("Bot turned in random direction.") setPedRotation(botPed, getPedRotation(botPed) + math.random(90, 270)) end end function botHit() outputDebugString("Bot detected obsticale infront of it.") outputConsole("Bot detected obsticale infront of it.") botTurn() end addCommandHandler( "smart", smartBotON ) addCommandHandler( "stand", standBot ) addCommandHandler( "botON", createBot ) addCommandHandler( "botOFF", deleteBot ) I really hope no one will copy this code! Is possible to delete topic?
  12. You have to add account! Type in console: addaccount Naser pass Now u can login by: /login Naser pass
  13. Same happens here. But u can connect to server in local to make it work+it works faster!
  14. yes ut when it's close to elements it doesn't turn?!!
  15. isn't this the same? + not working!
  16. not working! tried: local scan_radius = 10 local ped function getPointFromDistanceRotation(x, y, dist, angle) local a = math.rad(90 - angle); local dx = math.cos(a) * dist; local dy = math.sin(a) * dist; return x+dx, y+dy; end addCommandHandler( "botON", function() ped = createPed( 312, 1989, -2190, 14, 180, 0, 180 ) setPedAnimation( bot, "ped", "run_player" ) addEventHandler( 'onClientRender',root, function( ) local rot local bx,by,bz = getPedBonePosition( bot,8 ) rot = ( rot or 0 ) + 1 if rot > 360 then rot = 0 end local nx,ny = getPointFromDistanceRotation( bx,by,scan_radius,rot ) local hit = processLineOfSight( bx,by,bz,nx,ny,bz, true, -- checkBuildings false, -- checkVehicles false, -- checkPlayers false, -- checkObjects false, -- checkDummies false, -- seeThroughStuff false, -- ignoreSomeObjectsForCamera false, -- shootThroughStuff nil, -- ignoredElement false -- includeWorldModelInformation ) end ) end)
  17. If this 'fence' is mta element then it detected or otherwise not detected. If not detected you need use https://wiki.multitheftauto.com/wiki/ProcessLineOfSight and scan radius in onClientRender event. I don't know how to use Doesn't this detect only if you are ON element
  18. and how i I supposed to do this???????? i want to detect not only betwen two points!!!! I want to detect if ped hit anything(mta and gta objects) or if is close to anything!!
  19. then what can i use to detect GTA and MTA objects? mabye onPedContactElement ( i have ped and what to detect when he comes close to object or any other element)
×
×
  • Create New...