Jump to content

Kamran3478

Members
  • Posts

    8
  • Joined

  • Last visited

Recent Profile Visitors

101 profile views

Kamran3478's Achievements

Newbie

Newbie (4/54)

1

Reputation

  1. How do i make a server sided setpedcontrolstate? I want to make a npc and that npc drives car, but i cant use setpedcontrolstate because its client sided function.
  2. But thats also not working when i set setTimer(function(). And i got same errors EDIT: also, i set my script file's type to shared
  3. I got these errors: attempt to perform arithmetic on local 'x2' (a boolean value) [DUP x4] Bad argument @ 'getElementPosition' [Expected element at argument 1, got nil] Bad argument @ 'getElementRotation' [Expected element at argument 1, got nil] Bad argument @ 'getDistanceBetweenPoints3D' [Expected vector3 at argument 1, got boolean] setTimer(function(localPlayer) setPedFollow(myPed, localPlayer) end, 1000, 0) function setPedFollow(theElement, theTarget) if theElement then local x, y, z = getElementPosition(theTarget) local rx, ry, rz = getElementRotation(theTarget) local ex, ey, ez = getElementPosition(theElement) local distance = getDistanceBetweenPoints3D(x, y, z, ex, ey, ez) local rotation = findRotation(ex, ey, x, y) setPedRotation(theElement, rotation) if distance > 2 then setPedControlState(theElement, "forwards", true) else setPedControlState(theElement, "forwards", false) end end end function findRotation( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end Thats the script. Why its not working
  4. what is timer? can you show a example for this?
  5. How that works? I meant its addEventHandler but i want to run this script with command. Can i use addCommandHandler?
  6. I want the ped to follow the nearest player and I use this script: function setPedFollow(theElement, theTarget) if theElement then local x, y, z = getElementPosition(theTarget) local rx, ry, rz = getElementRotation(theTarget) local ex, ey, ez = getElementPosition(theElement) local distance = getDistanceBetweenPoints3D(x, y, z, ex, ey, ez) local rotation = findRotation(ex, ey, x, y) setPedRotation(theElement, rotation) if distance > 2 then setPedControlState(theElement, "forwards", true) else setPedControlState(theElement, "forwards", false) end end end addCommandHandler("followplayer", setPedFollow) My script file type is client side and nothing happens when I use the followplayer command, I thought it was glitched, I changed the type of my script file from meta.xml to server side and tried again, I got some errors. I get that script from https://wiki.multitheftauto.com/wiki/SetPedFollow. What is wrong with my code? (btw im new to lua scripting :/)
×
×
  • Create New...