Kraig Hellsing

Members
  • Content Count

    3
  • Joined

  • Last visited

Everything posted by Kraig Hellsing

  1. I did some work on it by myself and here's what i've accomplished so far: Server-Side function reward(p) if getElementType ( p ) == "ped" then local carro = getVehicleOccupant(getPedOccupiedVehicle(p), 0) givePlayerMoney(carro, 1000) destroyElement(p) outputChatBox("Perp has been turned in and you earned $1000!", carro, 0,255,0) end end policem = createMarker(1586,-1677,5, "cylinder", 5, 255, 0, 0, 170) addEventHandler("onMarkerHit", policem, reward) function teste(p) local x,y,z = getElementPosition(p) local pedestre = createPed(23, x,y,z) end addCommandHandler("teste", teste) team = createTeam("Criminal", 255,0,0) team2 = createTeam("Police", 0,0,255) --i play alone on my server, but it can easily be adapted to play with other players. function findRotation3D( x1, y1, z1, x2, y2, z2 ) local rotx = math.atan2 ( z2 - z1, getDistanceBetweenPoints2D ( x2,y2, x1,y1 ) ) rotx = math.deg(rotx) local rotz = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) rotz = rotz < 0 and rotz + 360 or rotz return rotx, 0,rotz end function func1(p) local x,y,z = getElementPosition(p) Marker = createMarker(x, y, z, "cylinder", 1, 255, 0, 0, 170) attachElements(Marker,p, 0,1,0) addEventHandler("onMarkerHit", Marker, bunda) addEventHandler("onMarkerHit", Marker, cu) end addCommandHandler("bust", func1) function release() destroyElement(Marker) timers = getTimers ( 1000) for timerKey, timerValue in ipairs(timers) do killTimer ( timerValue ) end end addCommandHandler("free", release) function func2(p,_) if getElementType ( p ) == "ped" then x2,y2,z2 = getElementPosition(Marker) x1,y1,z1 = getElementPosition(p) rx,ry,rz = findRotation3D(x1,y1,z1,x2,y2,z2) setElementRotation(p, rx+0,ry+0,rz+0) setPedAnimation(p, "ped", "walk_player") setTimer(function() func2(p,_) end, 999, 1) else return end end function func3(p, ped) if not getElementType ( ped ) == "ped" then return end addEventHandler("onVehicleEnter", root, function() setTimer(function() setPedAnimation(ped, false) end, 999, 1) timers = getTimers ( 1000) for timerKey, timerValue in ipairs(timers) do killTimer ( timerValue ) end destroyElement(Marker) end) end function sirenes(p, pp) carro = getPedOccupiedVehicle(p) if getVehicleSirensOn(carro) then local x,y,z = getElementPosition(carro) sir = createMarker(x,y,z, "cylinder", 5, 255,0,0, 170) attachElements(sir,carro, 0,-2,0) addEventHandler("onMarkerHit", sir, function(p) if getElementType(p) == "ped" then warpPedIntoVehicle(p, carro, math.random(2,3)) else return end end) else destroyElement(sir) end end addEventHandler("onVehicleStartExit", getRootElement(), sirenes) function sirenoff(p, pp) carro = getPedOccupiedVehicle(p) if getVehicleSirensOn(carro) then destroyElement(sir) end end addEventHandler("onVehicleEnter", getRootElement(), sirenoff)
  2. This is my first post, so forgive me if i make any mistakes! I'm creating a Police Script where i get to a random Ped and type a command(i'll change it to bind later) and it creates a Marker attached(0,1,0) to the Source that if it touches the Ped will activate a function that makes him follow the Marker. And this is the function so far: Everything is Server-Side (because i suck at Client-Side) function func1(p) local x,y,z = getElementPosition(p) Marker = createMarker(x, y, z, "cylinder", 1, 255, 0, 0, 170) attachElements(Marker,p, 0,1,0) addEventHandler("onMarkerHit", Marker, func2) addEventHandler("onMarkerHit", Marker, func3) end addCommandHandler("render", func1) function fun2(p,_) if getElementType ( p ) == "ped" then x2,y2,z2 = getElementPosition(Marker) x1,y1,z1 = getElementPosition(p) rx,ry,rz = findRotation3D(x1,y1,z1,x2,y2,z2) setElementRotation(p, rx+0,ry+0,rz+0) setPedAnimation(p, "ped", "walk_player") setTimer(function() bunda(p,_) end, 999, 1) end end And then here's the devil: function func3(p, ped) if not getElementType ( ped ) == "ped" then return end --else return end --carro = getElementType ( carro ) carro = getElementsByType("vehicle") --psha = getElementColShape(p) --elements = getElementsWithinColShape(psha) --if elements == carro == "vehicle" then --local vee = getElementsByType(carro) -- and getElementType ( carro ) == "vehicle" then --if getElementType(p2) == "player" then --local vei = getPedOccupiedVehicle(p2) --addEventHandler("onColShapeHit", psha, function(hit) --if carro == "vehicle" then addEventHandler("onVehicleEnter", root, function() setTimer(function() setPedAnimation(ped, false) vei = getPedOccupiedVehicle(p) warpPedIntoVehicle ( ped, root, math.random(2,4) ) end, 999, 1) timers = getTimers ( 1000) for timerKey, timerValue in ipairs(timers) do killTimer ( timerValue ) end destroyElement(Marker) --end end) end --end --end I tried everything my :~ty skills allowed me to and now i'm out of ideas on how to solve this without Client-Side. The idea is when the Ped approaches the car, it chooses between seats 2 or 3 and enters the car, but as i'm not creating the car in the script, instead you should be able to spawn any vehicle and as a Cop you could arrest people and take them to the car. Sorry for the ugly-ass code. EDIT: Making the Ped follow the Player and when the Player enters a Vehicle the Ped is warped into the back seat is fine too.