Miika Posted August 17, 2014 Share Posted August 17, 2014 Hi! I have problem with rob the burger shot resource. WARNING: smarket\smarketS.lua:38: Bad argument @'addEventHandler' [Expected element at argument 2, got nill] WARNING: smarket\smarketS.lua:51: Bad argument @'addEventHandler' [Expected element at argument 2, got nill] My code is: enterMarker = createMarker ( 811.2, -1616.1, 13.5, "corona", 1.5, 0, 255, 0 ) bl = createBlipAttachedTo(enterMarker,10) function createItems() exitMarker = createMarker ( 363.3, -74.7, 1001.5, "corona", 1.5, 0, 255, 0 ) setElementInterior ( exitMarker, 10 ) setElementDimension ( exitMarker, 1 ) robMarker = createMarker ( 376.1, -65, 1000.5, "cylinder", 1.5, 255, 255, 0 ) setElementInterior ( robMarker, 10 ) setElementDimension ( robMarker, 1 ) vendor = createPed ( 167, 375.9, -65.5, 1001.5, 0, 0, 180 ) setElementInterior ( vendor, 10 ) setElementDimension ( vendor, 1 ) end function warpPedIntoBurger( robber ) outputChatBox("[burger shot] Käy peremmälle!", robber, 255, 0, 255) setElementPosition ( robber, 364.7, -73.5, 1001.5 ) setElementDimension ( robber, 1 ) setElementInterior ( robber, 10 ) playSoundFrontEnd ( robber, 1 ) end addEventHandler("onMarkerHit", enterMarker, warpPedIntoBurger) function robberExit(exitrobber) outputChatBox("[burger shot] Tervetuloa uudelleen!", exitrobber, 255, 0, 255) setElementDimension ( exitrobber, 0 ) setElementInterior ( exitrobber, 0 ) setElementPosition ( exitrobber, 814.9, -1616.7, 13.5 ) playSoundFrontEnd ( exitrobber, 1 ) end addEventHandler("onMarkerHit", exitMarker, robberExit) function robberyHit( hitPlayer ) outputChatBox("ALARM! The player "..getPlayerName(hitPlayer).." is robbing the burger shot!", player, 255, 255, 0) setPlayerWantedLevel(hitPlayer, 3) destroyElement( robMarker ) destroyElement( exitMarker ) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) outputChatBox("Odota minuutti. Älä poistu paikalta!", hitPlayer,0,255,0) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) setTimer ( seconds30, 30000, 1 ) end addEventHandler("onMarkerHit", robMarker, robberyHit) function seconds30() outputChatBox("30 seconds remaining...", player, 255, 255, 0) setTimer ( robTimer, 30000, 1 ) end function robTimer( finishrobber ) outputChatBox("Now you can go out", player, 255, 255, 0) givePlayerMoney( player, 10000 ) setTimer ( createItems, 1000, 1 ) end What is the problem? Link to comment
Mr_Moose Posted August 17, 2014 Share Posted August 17, 2014 exitMarker and robMarker is never created, you added them into a function which is never called and then you assign their event handlers as soon the resource is started. Move the event handlers to a place below where you defined the markers and add another event handler for onResourceStart to trigger the function. Link to comment
Miika Posted August 17, 2014 Author Share Posted August 17, 2014 exitMarker and robMarker is never created, you added them into a function which is never called and then you assign their event handlers as soon the resource is started. Move the event handlers to a place below where you defined the markers and add another event handler for onResourceStart to trigger the function. Oh, I find the problem! Thx for helping: function createItems() exitMarker = createMarker ( 363.3, -74.7, 1001.5, "corona", 1.5, 0, 255, 0 ) setElementInterior ( exitMarker, 10 ) setElementDimension ( exitMarker, 1 ) robMarker = createMarker ( 376.1, -65, 1000.5, "cylinder", 1.5, 255, 255, 0 ) setElementInterior ( robMarker, 10 ) setElementDimension ( robMarker, 1 ) vendor = createPed ( 167, 375.9, -65.5, 1001.5, 0, 0, 180 ) setElementInterior ( vendor, 10 ) setElementDimension ( vendor, 1 ) addEventHandler("onMarkerHit", robMarker, robberyHit) addEventHandler("onMarkerHit", exitMarker, robberExit) end addEventHandler("onResourceStart", resourceRoot, createItems) Link to comment
Miika Posted August 17, 2014 Author Share Posted August 17, 2014 Next problem. It not give cash: WARNING: smarket\smarketS.lua:65: Bad argument @'givePlayerMoney' enterMarker = createMarker ( 811.2, -1616.1, 13.5, "corona", 1.5, 0, 255, 0 ) bl = createBlipAttachedTo(enterMarker,10) function createItems() exitMarker = createMarker ( 363.3, -74.7, 1001.5, "corona", 1.5, 0, 255, 0 ) setElementInterior ( exitMarker, 10 ) setElementDimension ( exitMarker, 1 ) vendor = createPed ( 167, 375.9, -65.5, 1001.5, 180 ) setElementInterior ( vendor, 10 ) setElementDimension ( vendor, 1 ) addEventHandler("onMarkerHit", exitMarker, robberExit) end addEventHandler("onResourceStart", resourceRoot, createItems) function createRobMarker() robMarker = createMarker ( 376.1, -65, 1000.5, "cylinder", 1.5, 255, 255, 0 ) setElementInterior ( robMarker, 10 ) setElementDimension ( robMarker, 1 ) addEventHandler("onMarkerHit", robMarker, robberyHit) end addEventHandler("onResourceStart", resourceRoot, createRobMarker) function warpPedIntoBurger( robber ) outputChatBox("[burger shot] Käy peremmälle!", robber, 255, 0, 255) setElementPosition ( robber, 364.7, -73.5, 1001.5 ) setElementDimension ( robber, 1 ) setElementInterior ( robber, 10 ) playSoundFrontEnd ( robber, 1 ) end addEventHandler("onMarkerHit", enterMarker, warpPedIntoBurger) function robberExit(exitrobber) outputChatBox("[burger shot] Tervetuloa uudelleen!", exitrobber, 255, 0, 255) setElementDimension ( exitrobber, 0 ) setElementInterior ( exitrobber, 0 ) setElementPosition ( exitrobber, 814.9, -1616.7, 13.5 ) playSoundFrontEnd ( exitrobber, 1 ) end function robberyHit( hitPlayer ) outputChatBox("ALARM! The player "..getPlayerName(hitPlayer).." is robbing the burger shot!", player, 255, 255, 0) setPlayerWantedLevel(hitPlayer, 3) destroyElement( robMarker ) destroyElement( exitMarker ) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) outputChatBox("Odota minuutti. Älä poistu paikalta!", hitPlayer,0,255,0) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) setTimer ( seconds30, 30000, 1 ) end function seconds30() outputChatBox("30 seconds remaining...", player, 255, 255, 0) setTimer ( robTimer, 30000, 1 ) end function robTimer( thePlayer ) givePlayerMoney ( thePlayer, 10000 ) setTimer ( createItems, 1000, 1 ) setTimer ( createRobMarker, 300000, 1 ) outputChatBox("Now you can go out", player, 255, 255, 0) end Link to comment
Mr_Moose Posted August 17, 2014 Share Posted August 17, 2014 You never added thePlayer as an argument to the payout function, check the timer that calls the function robTimer and make sure you set the first function argument (argument 4 in the timer function) to the player variable like this: setTimer ( robTimer, 30000, 1, player ) on line 61. Also change line 59 so it can receive the player element, that chatbox output on line 60 is visible to all currently and will also be fixed by the next step. Now edit line 59 to this: function seconds30(player) That will let the function receive the player so it can be used within it. And finally, at line 56 which needs the player element, change line 56 to this: setTimer ( seconds30, 30000, 1, hitPlayer ) And that should solve everything related to missing player pointers as well as payments. Link to comment
Miika Posted August 17, 2014 Author Share Posted August 17, 2014 You never added thePlayer as an argument to the payout function, check the timer that calls the function robTimer and make sure you set the first function argument (argument 4 in the timer function) to the player variable like this: setTimer ( robTimer, 30000, 1, player ) on line 61. Also change line 59 so it can receive the player element, that chatbox output on line 60 is visible to all currently and will also be fixed by the next step. Now edit line 59 to this: function seconds30(player) That will let the function receive the player so it can be used within it. And finally, at line 56 which needs the player element, change line 56 to this: setTimer ( seconds30, 30000, 1, hitPlayer ) And that should solve everything related to missing player pointers as well as payments. Thx Link to comment
Miika Posted August 17, 2014 Author Share Posted August 17, 2014 Another problem. It not cancel rob, if player wasted: WARNING: smarket\smarketS.lua:81: Bad argument @'addEventHandler' [Expected element at argument 2, got nill] enterMarker = createMarker ( 811.2, -1616.1, 13.5, "corona", 1.5, 0, 255, 0 ) bl = createBlipAttachedTo(enterMarker,10) function createItems() exitMarker = createMarker ( 363.3, -74.7, 1001.5, "corona", 1.5, 0, 255, 0 ) setElementInterior ( exitMarker, 10 ) setElementDimension ( exitMarker, 1 ) vendor = createPed ( 167, 375.9, -65.5, 1001.5, 180 ) setElementInterior ( vendor, 10 ) setElementDimension ( vendor, 1 ) addEventHandler("onMarkerHit", exitMarker, robberExit) end addEventHandler("onResourceStart", resourceRoot, createItems) function createRobMarker() outputChatBox("Burger shot robbery is now available!", getRootElement(), 255, 255, 0) robMarker = createMarker ( 376.1, -65, 1000.5, "cylinder", 1.5, 255, 255, 0 ) setElementInterior ( robMarker, 10 ) setElementDimension ( robMarker, 1 ) addEventHandler("onMarkerHit", robMarker, robberyHit) end addEventHandler("onResourceStart", resourceRoot, createRobMarker) function warpPedIntoBurger( robber ) outputChatBox("[burger shot] Käy peremmälle!", robber, 255, 0, 255) setElementPosition ( robber, 364.7, -73.5, 1001.5 ) setElementDimension ( robber, 1 ) setElementInterior ( robber, 10 ) playSoundFrontEnd ( robber, 1 ) end addEventHandler("onMarkerHit", enterMarker, warpPedIntoBurger) function robberExit(exitrobber) outputChatBox("[burger shot] Tervetuloa uudelleen!", exitrobber, 255, 0, 255) setElementDimension ( exitrobber, 0 ) setElementInterior ( exitrobber, 0 ) setElementPosition ( exitrobber, 814.9, -1616.7, 13.5 ) playSoundFrontEnd ( exitrobber, 1 ) end function robberyHit( hitPlayer ) outputChatBox(" #FF0000ALARM! #00FF00the player #FF0000"..getPlayerName(hitPlayer).." #00FF00is robbing the burger shot!",getRootElement(),255, 255, 255, true ) setPlayerTeam(hitplayer, Criminal) setPlayerWantedLevel(hitPlayer, 3) destroyElement( robMarker ) destroyElement( exitMarker ) killPed (vendor, hitPlayer) setTimer ( destryPedAfterKill, 5000, 1 ) giveWeapon ( hitPlayer, 31, 200 ) setPedWeaponSlot ( hitPlayer, 5) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) outputChatBox("Wait in one minute. Do not leave the building!", hitPlayer,0,255,0) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) setTimer ( seconds30, 30000, 1, hitPlayer ) end function destryPedAfterKill() destroyElement( vendor ) end function onPedDeath() killTimer ( seconds30 ) killTimer ( robTimer ) outputChatBox("Robbery failed!", hitPlayer, 255, 0, 255 ) setTimer ( createItems, 1000, 1 ) setTimer ( createRobMarker, 300000, 1 ) end addEventHandler ( "onPlayerWasted", hitPlayer, onPedDeath ) function seconds30(player) outputChatBox("30 seconds remaining...", player, 255, 255, 0) setTimer ( robTimer, 30000, 1, player ) end function robTimer( thePlayer ) givePlayerMoney ( thePlayer, 10000 ) setTimer ( createItems, 1000, 1 ) setTimer ( createRobMarker, 300000, 1 ) outputChatBox("Now you can go out", player, 255, 255, 0) end Link to comment
Miika Posted August 17, 2014 Author Share Posted August 17, 2014 Another problem. It not cancel rob, if player wasted: WARNING: smarket\smarketS.lua:81: Bad argument @'addEventHandler' [Expected element at argument 2, got nill] enterMarker = createMarker ( 811.2, -1616.1, 13.5, "corona", 1.5, 0, 255, 0 ) bl = createBlipAttachedTo(enterMarker,10) function createItems() exitMarker = createMarker ( 363.3, -74.7, 1001.5, "corona", 1.5, 0, 255, 0 ) setElementInterior ( exitMarker, 10 ) setElementDimension ( exitMarker, 1 ) vendor = createPed ( 167, 375.9, -65.5, 1001.5, 180 ) setElementInterior ( vendor, 10 ) setElementDimension ( vendor, 1 ) addEventHandler("onMarkerHit", exitMarker, robberExit) end addEventHandler("onResourceStart", resourceRoot, createItems) function createRobMarker() outputChatBox("Burger shot robbery is now available!", getRootElement(), 255, 255, 0) robMarker = createMarker ( 376.1, -65, 1000.5, "cylinder", 1.5, 255, 255, 0 ) setElementInterior ( robMarker, 10 ) setElementDimension ( robMarker, 1 ) addEventHandler("onMarkerHit", robMarker, robberyHit) end addEventHandler("onResourceStart", resourceRoot, createRobMarker) function warpPedIntoBurger( robber ) outputChatBox("[burger shot] Käy peremmälle!", robber, 255, 0, 255) setElementPosition ( robber, 364.7, -73.5, 1001.5 ) setElementDimension ( robber, 1 ) setElementInterior ( robber, 10 ) playSoundFrontEnd ( robber, 1 ) end addEventHandler("onMarkerHit", enterMarker, warpPedIntoBurger) function robberExit(exitrobber) outputChatBox("[burger shot] Tervetuloa uudelleen!", exitrobber, 255, 0, 255) setElementDimension ( exitrobber, 0 ) setElementInterior ( exitrobber, 0 ) setElementPosition ( exitrobber, 814.9, -1616.7, 13.5 ) playSoundFrontEnd ( exitrobber, 1 ) end function robberyHit( hitPlayer ) outputChatBox(" #FF0000ALARM! #00FF00the player #FF0000"..getPlayerName(hitPlayer).." #00FF00is robbing the burger shot!",getRootElement(),255, 255, 255, true ) setPlayerTeam(hitplayer, Criminal) setPlayerWantedLevel(hitPlayer, 3) destroyElement( robMarker ) destroyElement( exitMarker ) killPed (vendor, hitPlayer) setTimer ( destryPedAfterKill, 5000, 1 ) giveWeapon ( hitPlayer, 31, 200 ) setPedWeaponSlot ( hitPlayer, 5) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) outputChatBox("Wait in one minute. Do not leave the building!", hitPlayer,0,255,0) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) setTimer ( seconds30, 30000, 1, hitPlayer ) end function destryPedAfterKill() destroyElement( vendor ) end function onPedDeath() killTimer ( seconds30 ) killTimer ( robTimer ) outputChatBox("Robbery failed!", hitPlayer, 255, 0, 255 ) setTimer ( createItems, 1000, 1 ) setTimer ( createRobMarker, 300000, 1 ) end addEventHandler ( "onPlayerWasted", hitPlayer, onPedDeath ) function seconds30(player) outputChatBox("30 seconds remaining...", player, 255, 255, 0) setTimer ( robTimer, 30000, 1, player ) end function robTimer( thePlayer ) givePlayerMoney ( thePlayer, 10000 ) setTimer ( createItems, 1000, 1 ) setTimer ( createRobMarker, 300000, 1 ) outputChatBox("Now you can go out", player, 255, 255, 0) end Link to comment
.:HyPeX:. Posted August 17, 2014 Share Posted August 17, 2014 In place 2 you should assign an element to bound the handler (If you bound it to a single player then it will only work for him). Thought, it should work if correctly assigned. (Check if hitPlayer is defined before that function goes on.) Link to comment
Miika Posted August 17, 2014 Author Share Posted August 17, 2014 killTimers not working: enterMarker = createMarker ( 811.2, -1616.1, 13.5, "corona", 1.5, 0, 255, 0 ) bl = createBlipAttachedTo(enterMarker,10) function createItems() exitMarker = createMarker ( 363.3, -74.7, 1001.5, "corona", 1.5, 0, 255, 0 ) setElementInterior ( exitMarker, 10 ) setElementDimension ( exitMarker, 1 ) vendor = createPed ( 167, 375.9, -65.5, 1001.5, 180 ) setElementInterior ( vendor, 10 ) setElementDimension ( vendor, 1 ) addEventHandler("onMarkerHit", exitMarker, robberExit) end addEventHandler("onResourceStart", resourceRoot, createItems) function createRobMarker() outputChatBox("Burger shot robbery is now available!", getRootElement(), 255, 255, 0) robMarker = createMarker ( 376.1, -65, 1000.5, "cylinder", 1.5, 255, 255, 0 ) setElementInterior ( robMarker, 10 ) setElementDimension ( robMarker, 1 ) addEventHandler("onMarkerHit", robMarker, robberyHit) end addEventHandler("onResourceStart", resourceRoot, createRobMarker) function warpPedIntoBurger( robber ) outputChatBox("[burger shot] Käy peremmälle!", robber, 255, 0, 255) setElementPosition ( robber, 364.7, -73.5, 1001.5 ) setElementDimension ( robber, 1 ) setElementInterior ( robber, 10 ) playSoundFrontEnd ( robber, 1 ) end addEventHandler("onMarkerHit", enterMarker, warpPedIntoBurger) function robberExit(exitrobber) outputChatBox("[burger shot] Tervetuloa uudelleen!", exitrobber, 255, 0, 255) setElementDimension ( exitrobber, 0 ) setElementInterior ( exitrobber, 0 ) setElementPosition ( exitrobber, 814.9, -1616.7, 13.5 ) playSoundFrontEnd ( exitrobber, 1 ) end function robberyHit( hitPlayer ) outputChatBox(" #FF0000ALARM! #00FF00the player #FF0000"..getPlayerName(hitPlayer).." #00FF00is robbing the burger shot!",getRootElement(),255, 255, 255, true ) setPlayerTeam(hitplayer, Criminal) setPlayerWantedLevel(hitPlayer, 3) destroyElement( robMarker ) destroyElement( exitMarker ) killPed (vendor, hitPlayer) setTimer ( destryPedAfterKill, 5000, 1 ) giveWeapon ( hitPlayer, 31, 200 ) setPedWeaponSlot ( hitPlayer, 5) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) outputChatBox("Wait in one minute. Do not leave the building!", hitPlayer,0,255,0) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) setTimer ( seconds30, 30000, 1, hitPlayer ) addEventHandler ( "onPlayerWasted", hitPlayer, onPedDeath ) end function destryPedAfterKill() destroyElement( vendor ) end function onPedDeath() killTimer ( seconds30 ) killTimer ( robTimer ) outputChatBox("Robbery failed!", hitPlayer, 255, 0, 255 ) setTimer ( createItems, 1000, 1 ) setTimer ( createRobMarker, 300000, 1 ) end function seconds30(player) outputChatBox("30 seconds remaining...", player, 255, 255, 0) setTimer ( robTimer, 30000, 1, player ) end function robTimer( thePlayer ) givePlayerMoney ( thePlayer, 10000 ) setTimer ( createItems, 1000, 1 ) setTimer ( createRobMarker, 300000, 1 ) outputChatBox("Now you can go out", player, 255, 255, 0) end Link to comment
.:HyPeX:. Posted August 17, 2014 Share Posted August 17, 2014 Becouse you are not defining the timers... should be instead: seconds30 = setTimer ( seconds30, 30000, 1, hitPlayer ) the function isnt the timer name, if you dont assign it a name then it is not killable. Link to comment
Anubhav Posted August 17, 2014 Share Posted August 17, 2014 enterMarker = createMarker ( 811.2, -1616.1, 13.5, "corona", 1.5, 0, 255, 0 ) bl = createBlipAttachedTo(enterMarker,10) function createItems() exitMarker = createMarker ( 363.3, -74.7, 1001.5, "corona", 1.5, 0, 255, 0 ) setElementInterior ( exitMarker, 10 ) setElementDimension ( exitMarker, 1 ) vendor = createPed ( 167, 375.9, -65.5, 1001.5, 180 ) setElementInterior ( vendor, 10 ) setElementDimension ( vendor, 1 ) addEventHandler("onMarkerHit", exitMarker, robberExit) end addEventHandler("onResourceStart", resourceRoot, createItems) function createRobMarker() outputChatBox("Burger shot robbery is now available!", getRootElement(), 255, 255, 0) robMarker = createMarker ( 376.1, -65, 1000.5, "cylinder", 1.5, 255, 255, 0 ) setElementInterior ( robMarker, 10 ) setElementDimension ( robMarker, 1 ) addEventHandler("onMarkerHit", robMarker, robberyHit) end addEventHandler("onResourceStart", resourceRoot, createRobMarker) function warpPedIntoBurger( robber ) outputChatBox("[burger shot] Käy peremmälle!", robber, 255, 0, 255) setElementPosition ( robber, 364.7, -73.5, 1001.5 ) setElementDimension ( robber, 1 ) setElementInterior ( robber, 10 ) playSoundFrontEnd ( robber, 1 ) end addEventHandler("onMarkerHit", enterMarker, warpPedIntoBurger) function robberExit(exitrobber) outputChatBox("[burger shot] Tervetuloa uudelleen!", exitrobber, 255, 0, 255) setElementDimension ( exitrobber, 0 ) setElementInterior ( exitrobber, 0 ) setElementPosition ( exitrobber, 814.9, -1616.7, 13.5 ) playSoundFrontEnd ( exitrobber, 1 ) end function robberyHit( hitPlayer ) outputChatBox(" #FF0000ALARM! #00FF00the player #FF0000"..getPlayerName(hitPlayer).." #00FF00is robbing the burger shot!",getRootElement(),255, 255, 255, true ) setPlayerTeam(hitPlayer, "Criminal") setPlayerWantedLevel(hitPlayer, 3) destroyElement( robMarker ) destroyElement( exitMarker ) killPed (vendor, hitPlayer) setTimer ( destryPedAfterKill, 5000, 1 ) giveWeapon ( hitPlayer, 31, 200 ) setPedWeaponSlot ( hitPlayer, 5) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) outputChatBox("Wait in one minute. Do not leave the building!", hitPlayer,0,255,0) outputChatBox("--------------------------------------------------------------------------------------------------------------------- ", hitPlayer,255,255,0) seconds30 = setTimer ( seconds30, 30000, 1, hitPlayer ) addEventHandler ( "onPlayerWasted", hitPlayer, onPedDeath, false ) end function destryPedAfterKill() destroyElement( vendor ) end function onPedDeath() if isTimer( seconds30 ) then killTimer ( seconds30 ) end if isTimer( robTimer ) then killTimer ( robTimer ) end outputChatBox("Robbery failed!", source, 255, 0, 255 ) setTimer ( createItems, 1000, 1 ) setTimer ( createRobMarker, 300000, 1 ) end function seconds30(player) outputChatBox("30 seconds remaining...", player, 255, 255, 0) robTimer = setTimer ( robTimer, 30000, 1, player ) end function robTimer( thePlayer ) givePlayerMoney ( thePlayer, 10000 ) setTimer ( createItems, 1000, 1 ) setTimer ( createRobMarker, 300000, 1 ) outputChatBox("Now you can go out", player, 255, 255, 0) 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