gghvcffcv Posted June 25, 2014 Share Posted June 25, 2014 It says me addEventHandler argument 2 got nil Why this?. and how solve it?- local HouseRob = createMarker ( 2024.5205078125, 1545.6474609375, 9.81995010376, "cylinder", 10, 255, 0, 0, 150) function Money(hElement) local Criminals = getPlayerTeam ( hElement ) if ( Criminals ) then setTimer(givePlayerMoney,60000,1,hElement, 10000) setTimer(setPlayerWantedLevel,60000,1,hElement, 6) setTimer (destroyElement,60000,1,HouseRob) end end addEventHandler ("onMarkerHit", HouseRob, Money) function Otro(hElement) HouseRobC = createMarker ( 2027.5205078125, 1545.6474609375, 9.81995010376, "cylinder", 10, 255, 0, 0, 150) end addEventHandler ("onElementDestroy", HouseRob, Otro) function Otro(hElement) local Criminals = getPlayerTeam ( hElement ) if ( Criminals ) then setTimer(givePlayerMoney,60000,1,hElement, 10000) setTimer(setPlayerWantedLevel,60000,1,hElement, 6) setTimer (destroyElement,60000,1,HouseRobC) end end addEventHandler ("onMarkerHit", HouseRobC, Otro) Link to comment
Et-win Posted June 25, 2014 Share Posted June 25, 2014 addEventHandler ("onMarkerHit", HouseRobC, Otro) HouseRocC is not given before the script reads the event handler. (If the script starts, it reads this event handler, he checks it but can't find HouseRobC, because that marker gets created later. Add the event handler in the function when you create that marker. Link to comment
gghvcffcv Posted June 25, 2014 Author Share Posted June 25, 2014 I can't do that because I need two event handler Link to comment
Et-win Posted June 25, 2014 Share Posted June 25, 2014 local HouseRob = createMarker ( 2024.5205078125, 1545.6474609375, 9.81995010376, "cylinder", 10, 255, 0, 0, 150) function Money(hElement) local Criminals = getPlayerTeam ( hElement ) if ( Criminals ) then setTimer(givePlayerMoney,60000,1,hElement, 10000) setTimer(setPlayerWantedLevel,60000,1,hElement, 6) setTimer (destroyElement,60000,1,HouseRob) end end addEventHandler ("onMarkerHit", HouseRob, Money) function Otro(hElement) HouseRobC = createMarker ( 2027.5205078125, 1545.6474609375, 9.81995010376, "cylinder", 10, 255, 0, 0, 150) if (markerevent == nil) then markerevent = addEventHandler ("onMarkerHit", HouseRobC, Otro) end end addEventHandler ("onElementDestroy", HouseRob, Otro) function Otro(hElement) local Criminals = getPlayerTeam ( hElement ) if ( Criminals ) then setTimer(givePlayerMoney,60000,1,hElement, 10000) setTimer(setPlayerWantedLevel,60000,1,hElement, 6) setTimer (destroyElement,60000,1,HouseRobC) 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