Jump to content

[HELP] ExitMarker doesn't work


ViRuZGamiing

Recommended Posts

Posted

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 ) 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

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) 

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

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) 

CiTLh.png
Posted

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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

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) 

CiTLh.png
Posted

No errors, no debug but now he doesn't take weapon or punches he just does nothing

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

Thx, can I add a setTimer and then respawn the ped?

otherwise I need to restart script for a new ped

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

You can attack it and he attacks back, but if he dies he needs to respawn after a while.

They are like bodyguards xD

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted

@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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
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 

CiTLh.png

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...