Jump to content

Help... please.


12p

Recommended Posts

Hi everybody. I'm beginning in the LUA "World" and I'm doing a scripted map. Well, my problem is this: when I start that map, the console tells me "WARNING: Bad Argument @ addEventHandler (string-defined function)" 2 times. By some ways, I discovered that those "addEventHandler"s are these:

addEventHandler ('onMarkerHit', markerEntrar, entrar1)
function entrar1 ()
moveObject (puerta,1000,2304.2231445313,-12.65851020813,27.748359680176)
end
 
addEventHandler ("onMarkerLeave",markerEntrar, entrar2)
function entrar2 ()
moveObject (puerta,1000,2304.2231445313,-15.65851020813,27.748359680176)
end

If you can help me, I will really regreet to everybody.

PS: Here is my full code by now:

addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()),
 
function ()
local banquera = createPed (172,2318.3, -15.36, 27.74)
setPedRotation (banquera,90)
 
local vendedorArmas = createPed (73,2306.7954101,-2.43528,27.7021875)
setPedRotation (vendedorArmas, 270)
setPedAnimation (vendedorArmas, "MISC", "SEAT_LR", -1, true, false, false)
 
local puerta = createObject (5856,2304.2231445313,-15.65851020813,27.748359680176)
local markerEntrar = createMarker (2304.2231445313,-15.65851020813,26.748359680176,'cylinder',2,0,0,0,0)
end)
 
 
 
addEventHandler ('onMarkerHit', markerEntrar, entrar1)
function entrar1 ()
moveObject (puerta,1000,2304.2231445313,-12.65851020813,27.748359680176)
end
 
addEventHandler ("onMarkerLeave",markerEntrar, entrar2)
function entrar2 ()
moveObject (puerta,1000,2304.2231445313,-15.65851020813,27.748359680176)
end

PS2: No, it doesn't tell me what's the bad line.

Edited by Guest
Link to comment

No, it doesn't work ¬¬. But thanks.

EDIT: I solved it. The problem was the "local" thing xD. I must not put "local" in the elements used in another parts of the code.

Now I have another problem (sorry xD): my ped "vendedorArmas" (down the new code) doesn't do the animation I tell him to do.

The block is right, the animation name is right too, why it doesn't work?

local banquera = createPed (172,2318.3, -15.36, 27.74)
setPedRotation (banquera,90)
 
local vendedorArmas = createPed (73,2306.7954101,-2.43528,27.7021875)
setPedRotation (vendedorArmas, 270)
setPedAnimation (vendedorArmas, "MISC", "SEAT_LR", -1, true, false, false)
 
 puerta = createObject (5856,2304.2231445313,-15.65851020813,27.748359680176)
 markerEntrar = createMarker (2304.2231445313,-15.65851020813,26.748359680176,'cylinder',2,0,0,0,0)
 
 
 
 
function entrar1 ()
moveObject (puerta,1000,2304.2231445313,-12.65851020813,27.748359680176)
end
addEventHandler ('onMarkerHit', markerEntrar, entrar1)
 
function entrar2 ()
moveObject (puerta,1000,2304.2231445313,-15.65851020813,27.748359680176)
end
addEventHandler ("onMarkerLeave",markerEntrar, entrar2)

Link to comment

That's actually, what I told you.

If you attach an event handler, the element, to which it gets attached to, has to be created beforehand.

Later on I realized that also your function, which you use as handler function, needs to be located before adding the event handler.

I just tried this animation and it works for me, so there's nothing wrong with the animation line itself.

Just a wild guess, but try to comment out the "setPedRotation" thing.

Btw, there is an extra parameter for the rotation already for createPed, so there is no need for an extra "setPedRotation" line.

EDIT:

I just tried your weapon merchant ped code lines for myself and it worked fine.

I really can't figure out your problem.

You don't get any error, do you?

Link to comment

No, I don't get any error... Or that's what the console tells me. ¬_¬, but the PED doesn't play the animation...

Does a collision stops animations on local PEDs?

EDIT: I will leave that try of setting PED animation. Thanks for the help. By now, I'm ok.

Link to comment

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...