Xwad Posted October 12, 2015 Posted October 12, 2015 Hi! I downloaded this script for my server: https://community.multitheftauto.com/in ... ils&id=129 Its a very god script but i have a problem with it.. The bomb is only attaching to the plane if i hit the marker with the plane..And i wanted to make that the bomb will only be attached to the plane if a player enters it.. So i tryed to edit the script but its not working://I hope you can help me guys! original script (this is just a part of the script) function callbackMarkerHit(hitPlayer, matchingDimension) if (matchingDimension) then objBomber:callbackFunc("funcReloadBomber", hitPlayer) end end function callbackFunc(request, ...) objBomber:callbackFunc(request, source, arg[1]) end -- exports function regBombMarker(marker) addEventHandler("onMarkerHit", marker, callbackMarkerHit, false) end function regBombMarkers(markers) for _, marker in ipairs(markers) do addEventHandler("onMarkerHit", marker, callbackMarkerHit, false) end end function unregBombMarker(marker) removeEventHandler("onMarkerHit", marker, callbackMarkerHit) end function unregBombMarkers(markers) for _, marker in ipairs(markers) do removeEventHandler("onMarkerHit", marker, callbackMarkerHit) end end my edited script! (this is just a part of the script (bomber.lua).) function callbackMarkerHit(thePlayer) objBomber:callbackFunc("funcReloadBomber", thePlayer) end end function reloadTimer( thePlayer ) setTimer ( callbackMarkerHit, 5000, 1 ) end addEventHandler ( "onVehicleEnter", getRootElement(), reloadTimer )
Moderators IIYAMA Posted October 14, 2015 Moderators Posted October 14, 2015 Remove 'end' at line 5. Because there are end's for a reason... which is for closing a block of a function or conditions states etc. Replace line 13 with: setTimer ( callbackMarkerHit, 5000, 1,thePlayer ) Because you have to tell the timer that you are sending some extra information to another function. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Xwad Posted October 14, 2015 Author Posted October 14, 2015 one more question. I want to make a timer for reloading. So add a triggerserver event when the bomb is armed.. So i replaced this in ObjClientBomber.lua (client side) script: To this self._fuseTimers[3] = triggerServerEvent ( "reload", resourceRoot, thePlayer ) From this self._fuseTimers[3] = setTimer(outputChatBox, 2500, 1, "* Bomb is armed!") and i added this to the server side script addEvent( "reload", true ) addEventHandler( "reload", resourceRoot, reloadTimer ) the problem is that its not triggering the serverside script:/
Xwad Posted October 15, 2015 Author Posted October 15, 2015 so why is this triggerServerEvent not working? client triggerServerEvent("reload",localPlayer) server function reloadTimer( thePlayer ) outputChatBox ( "ddddddd" ) setTimer ( callbackMarkerHit, 4000, 1,thePlayer ) end addEvent( "reload", true ) addEventHandler( "reload", resourceRoot, reloadTimer )
Moderators IIYAMA Posted October 15, 2015 Moderators Posted October 15, 2015 triggerServerEvent("reload",[color=#FF0000][u]localPlayer[/u][/color],[color=#00FF00]localPlayer[/color]) function reloadTimer( [color=#00FF00]thePlayer[/color] ) outputChatBox ( "ddddddd" ) --local [color=#FF0000]sourceElement[/color] = [color=#FF0000]source[/color] setTimer ( callbackMarkerHit, 4000, 1,[color=#00FF00]thePlayer[/color] ) end addEvent( "reload", true ) addEventHandler( "reload", [color=#FF0000][u]resourceRoot[/u][/color], reloadTimer ) Activation element of the addEventHandler: addEventHandler + resourceRoot element only accepts the resourceRoot element. When you want this event to be able to activate by more element types, use root < IN THE addEventHandler. RED clientside = RED serverside GREEN clientside = GREEN serverside Two ways to fix the code: triggerServerEvent("reload",resourceRoot,localPlayer) or addEventHandler( "reload", root, reloadTimer ) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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