ViRuZGamiing Posted December 22, 2013 Share Posted December 22, 2013 Hi, My entranceMarker works but exit doesn't; exitMarker = createMarker(-30.9,-91.6, 1002.5, 'cylinder', 1.0, 0, 100, 255, 255) setElementInterior (exitMarker, 18) entranceMarker = createMarker(-2442.6001, 754.70001, 34.1, 'cylinder', 2.0, 0, 100, 255, 255) function enterHit( thePlayer, matchingDimension ) local elementType = getElementType( thePlayer ) if (elementType) then setElementInterior (thePlayer, 18) setElementPosition (thePlayer, -31, -90.2, 1003.5) end end function exitHit ( thePlayer, matchingDimension ) local elementType = getElementType( thePlayer ) if (elementType) then setElementInterior (thePlayer, 0) setElementPosition (thePlayer, -2442.3999, 751.59998, 35.2) end end addEventHandler( "onMarkerHit", exitMarker, exitHit ) addEventHandler( "onMarkerHit", entranceMarker, enterHit ) Link to comment
TAPL Posted December 22, 2013 Share Posted December 22, 2013 The size of exitMarker is too small, try increase the size. Link to comment
ViRuZGamiing Posted December 22, 2013 Author Share Posted December 22, 2013 Thx works, Now i'm trying to use some Pedistrian functions. I want to do that when a player aims at pedistrian test, ped test gets a weapon and shoots at the player. This is what I got; --server function testAttack () target = getPedTarget ( testKeeper ) if ( target ) then giveWeapon (testPed, 31, 100) triggerClientEvent (thePlayer, "testShoot", root) end end addEventHandler ( "onPlayerDamage", root, testAttack ) --client function testShoot () setPedControlState(testPed, fire, true) end addEvent( "testShoot", true ) addEventHandler( "testShoot", root, testShoot) Link to comment
TAPL Posted December 22, 2013 Share Posted December 22, 2013 Try this (Not tested). --server testPed = createPed(skin, x, y, z) function testAttack(target) if getElementType(target) == "ped" and target == testPed then giveWeapon(target, 31, 100) triggerClientEvent(root, "testShoot", source, target) end end addEventHandler("onPlayerTarget", root, testAttack) --client function testShoot(target) local x, y, z = getElementPosition(source) setPedAimTarget(target, x, y, z) setPedControlState(target, "fire", true) end addEvent("testShoot", true) addEventHandler("testShoot", root, testShoot) Link to comment
ViRuZGamiing Posted December 22, 2013 Author Share Posted December 22, 2013 Error when aiming [12:47:52] WARNING: test\server.lua:31: Bad argument @ 'getElementType' [Exp ected element at argument 1, got boolean] if getElementType(target) == "ped" and target == testPed then He doesn't take his weapon and he punches once with his fist Link to comment
TAPL Posted December 22, 2013 Share Posted December 22, 2013 Change this: if getElementType(target) == "ped" and target == testPed then To: if target and getElementType(target) == "ped" and target == testPed then And Change this: giveWeapon(target, 31, 100) To: giveWeapon(target, 31, 100, true) Link to comment
ViRuZGamiing Posted December 22, 2013 Author Share Posted December 22, 2013 No errors, no debug but now he doesn't take weapon or punches he just does nothing Link to comment
ViRuZGamiing Posted December 22, 2013 Author Share Posted December 22, 2013 Works now, had a small mistake Link to comment
ViRuZGamiing Posted December 22, 2013 Author Share Posted December 22, 2013 Thx, can I add a setTimer and then respawn the ped? otherwise I need to restart script for a new ped Link to comment
TAPL Posted December 22, 2013 Share Posted December 22, 2013 (edited) There no function to respawn the ped, you will need to create the ped again. You can use this event: onPedWasted. Edited December 22, 2013 by Guest Link to comment
ViRuZGamiing Posted December 22, 2013 Author Share Posted December 22, 2013 You can attack it and he attacks back, but if he dies he needs to respawn after a while. They are like bodyguards Link to comment
ViRuZGamiing Posted December 22, 2013 Author Share Posted December 22, 2013 @TA-PL I have this function testPed() ..... if ( isPedDead ( shopKeeper ) ) then triggerClientEvent (source, "testMessage1", root) testMarker = createMarker(-27,-91.6, 1002.5, 'cylinder', 1.5, 0, 100, 255, 255) setElementInterior (robMarker, 18) end end function testHit ( thePlayer, matchingDimension ) local elementType = getElementType( thePlayer ) if (elementType) then triggerClientEvent (source, "testMessage2", root) end end addEventHandler( "onMarkerHit", testMarker, testHit ) I want to get testMarker out of testPed and trigger testHit but it doesn't work... The event handler doesn't see testMarker Link to comment
TAPL Posted December 22, 2013 Share Posted December 22, 2013 function testPed() ..... if ( isPedDead ( shopKeeper ) ) then triggerClientEvent (source, "testMessage1", root) testMarker = createMarker(-27,-91.6, 1002.5, 'cylinder', 1.5, 0, 100, 255, 255) addEventHandler( "onMarkerHit", testMarker, testHit ) setElementInterior (robMarker, 18) end end function testHit ( thePlayer, matchingDimension ) local elementType = getElementType( thePlayer ) if (elementType) then triggerClientEvent (source, "testMessage2", root) end end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now