Jump to content

LiOneLMeSsIShoT

Members
  • Posts

    609
  • Joined

  • Last visited

Everything posted by LiOneLMeSsIShoT

  1. when i hit marker nothing happen...even no error..Check: server side: local pbags = { { 2293.154296875, 561.470703125, 7.78125 }, } local marker = createMarker ( 2291.1999511719, 537, 0.80000001192093, "cylinder", 1.5, 255, 0, 0 ) function createBags ( thePlayer ) local x, y, z = unpack ( pbags [ math.random ( #pbags ) ] ) local baga = createPickup ( x, y, z, 3, 1210 ) addEventHandler ( "onPickupHit", baga, onPickupHit ) addEventHandler ("onPlayerQuit", baga, onPlayerQuit) addEventHandler ("onClientMarkerHit", marker, onMarkerHit) end addEventHandler ( "onResourceStart", getRootElement(), createBags ) function onPickupHit ( thePlayer ) if ( isPedInVehicle ( thePlayer ) ) then return end if ( isPedDead ( thePlayer ) ) then return end local bagb = createObject ( 1210, 0, 0, 0 ) setElementData ( thePlayer, "baga", true ) exports.bone_attach:attachElementToBone(bagb,thePlayer,12,0,0.1,0.3,0,180,0) end function onMarkerHit () triggerClientEvent (source, "OCMHjob", marker) end function onPlayerQuit ( ) destroyElement ( baga ) if getElementData (source, "baga") then setElementData ( source, "baga", false ) end end client side: function onHit () localPlayer = getLocalPlayer () local Mrandom = math.random (1000, 2000, 3000, 500, 100, 50) if getElementData(source, "baga") then givePlayerMoney (localPlayer, Mrandom) else outputChatBox ("get the bag and back", source, 255, 0, 0, false) end end addEvent ("OCMHjob", true) addEventHandler ("OCMHjob", getRootElement, onHit)
  2. yeah yeah...now see...not work too... server: function follow (thePlayer) local x,y,z = getElementPosition (thePlayer) local guard = createPed (240, x, y, z) triggerClientEvent (thePlayer, "moveGuard", guard) end addCommandHandler ("guard", follow) client: function me () setPedControlState (source, "forwards", true) setPedLookAt (source, getElementPosition(localPlayer)) end addEvent ("moveGuard", true) addEventHandler ("moveGuard", getRootElement(), me)
  3. server: function follow (thePlayer) local x,y,z = getElementPosition (thePlayer) local guard = createPed (240, x, y, z) triggerClientEvent (thePlayer, "moveGuard", guard) setPedLookAt (guard, x, y, z) end addCommandHandler ("guard", follow) client: function me () setPedControlState (source, "forwards", true) end addEvent ("moveGuard", true) addEventHandler ("moveGuard", getRootElement(), me) Still not follows me and error: attempt to call global 'setPedLookAt' (a nil value)
  4. Alright..!! Edited it but still not follows me and no errors! the ped move Forward only server: function follow (thePlayer) local x,y,z = getElementPosition (thePlayer) local guard = createPed (240, x, y, z) local tx,ty,tz = getElementPosition (guard) triggerClientEvent (thePlayer, "moveGuard", guard) setPedRotation(guard, findRotation(tx, ty, x, y)) end addCommandHandler ("guard", follow) 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 client: function me () setPedControlState (source, "forwards", true) end addEvent ("moveGuard", true) addEventHandler ("moveGuard", getRootElement(), me)
  5. Actually removed lines 4, 5, 6 i've edited the script now and it works. with the ped moves forward..but not follows me..check this server: function follow (thePlayer) local x1,y1,z1 = getElementPosition (thePlayer) local guard = createPed (240, x1, y1, z1) local x2,y2,z2 = getElementRotation (guard) triggerClientEvent (thePlayer, "moveGuard", guard) setElementRotation(guard,x1, y1, x2, y2) end addCommandHandler ("guard", follow) client: function me () setPedControlState (source, "forwards", true) end addEvent ("moveGuard", true) addEventHandler ("moveGuard", getRootElement(), me) no errors
  6. why makes no sense? i triggerd client event because setPedControlState is Client side .
  7. Tried already here viewtopic.php?f=91&t=67858 but need help now !
  8. i've made a script which make the ped follows the player but the ped don't even move..and no errors..please check this server: function follow (thePlayer) local x1,y1,z1 = getElementPosition (thePlayer) local guard = createPed (240, x1, y1, z1) local x2,y2,z2 = getElementPosition (guard) local distance = getDistanceBetweenPoints2D (x1, y1, x2, y2) if distance >= 2 then triggerClientEvent (thePlayer, "moveGuard", guard) end end addCommandHandler ("guard", follow) client: function me () setPedControlState (guard, "forwards", true) end addEvent ("moveGuard", true) addEventHandler ("moveGuard", getRootElement(), me)
  9. Well, what is x1, y1, x2, y2? https://wiki.multitheftauto.com/wiki/FindRotation math.deg and math.atan2 is lua math function, findRotation is useful function you don't need to know how and why it made like this just use it. The example already showed how it used. ped = createPed(0, getElementPosition(localPlayer)) addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(ped) local dis = getDistanceBetweenPoints2D(x, y, tx, ty) if dis > 2 then setPedControlState(ped, "forwards", true) else setPedControlState(ped, "forwards", false) end setPedRotation(ped, findRotation(tx, ty, x, y)) end) 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 Line 13 is used to make the ped face you, so when it move forwards it will follow you. Alright well Thanks but can you make the script more simple with server side and trigger clinet side ?
  10. Well, what is x1, y1, x2, y2? and what's "math.deg and math.atan2..and what's x2-x1,y2-y1 ..and what's t = t +360 ...please man tell me what or even how they work
  11. ped = createPed(0, getElementPosition(localPlayer)) addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) local tx, ty, tz = getElementPosition(ped) local dis = getDistanceBetweenPoints2D(x, y, tx, ty) if dis > 2 then setPedControlState(ped, "forwards", true) else setPedControlState(ped, "forwards", false) end setPedRotation(ped, findRotation(tx, ty, x, y)) end) 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 Alright yeah this Example...but i don't understand the script 100% can you explain me somethings on it? 1- setPedRotation(ped, findRotation(tx, ty, x, y)) 2- 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 Thanks
  12. actually it's not...try to use the script man and you will see
  13. ok i will try. Alright tried..work as the ped follows, but when i stop the ped starts to jump behind me and move around me like a mad guy
  14. i mean. the bot is hardly follows me...the bot stop for long time then starts to keep following.. i mean not always follow me .. why?
  15. Alright tried it and works as the guard don't try to do anything on me... but there's some problem ..the bot takes long time to follow me...like not follows me when i move...the bot wait for long distance.. and then "jumps" follows me "move around me" "stop behind me" like the bot don't know what he should to do.
  16. i think i have to put big number ? whatever i tried 9999999 and after fail tried 250 or even 1000...not works too....
  17. Alright.. i did it and still attacks me. function guard (thePlayer) local x,y,z = getElementPosition (thePlayer) local Guard = exports ["slothbot"]:spawnBot (x,y,z, 0, 240, 0, 0, nil, 0, "follow", "following") setTimer(function() exports ["slothbot"]:setBotAttackEnabled(Guard, false) end, 9999999999999999, 1) end addCommandHandler ("guard", guard)
  18. and could i disable the timer? or you have way to do this ...
  19. Alright i understand about that..but i think the timer is not good idea for the script..so there's some way to remove the timer? if not then please tell me how to set the timer. and Thank you man
  20. Alright but i set him to not attack anyone in setBotAttackEnabled (Guard, false) it's not going to make sense?
  21. if you have a problem in this post..then don't reply please. THanks.
×
×
  • Create New...