hamed Posted February 14, 2019 Posted February 14, 2019 hello . i want a resource for auto restart a rescourse for rewpawn cars every 10 min . pls help me who have this script?
Peti Posted February 15, 2019 Posted February 15, 2019 (edited) You can do it by yourself, you only need this: setTimer( function() if getResourceState(yourResource) == "running" then restartResource(yourResource) end end, 600000, 0) But I don't think this is very optimized if you ask me. Edited February 15, 2019 by Peti Scripts 1. Mission: Pizza delivery [OPEN SOURCE]
hamed Posted February 20, 2019 Author Posted February 20, 2019 (edited) Thx On 15/02/2019 at 05:18, Peti said: You can do it by yourself, you only need this: setTimer( function() if getResourceState(yourResource) == "running" then restartResource(yourResource) end end, 600000, 0) But I don't think this is very optimized if you ask me. He Dont Work Man Edited February 20, 2019 by hamed ss
Peti Posted February 20, 2019 Posted February 20, 2019 Which errors are you getting? Show me your code to see what is happening. Scripts 1. Mission: Pizza delivery [OPEN SOURCE]
Moderators Patrick Posted February 20, 2019 Moderators Posted February 20, 2019 (edited) Insert this line somewhere your code: -- SERVER SIDE setTimer(restartResource, 600000, 1, getThisResource()) Edited February 20, 2019 by stPatrick 1 community profile | map converters | map images | pDownloader | pAttach | model encrypter
VenomOG Posted February 20, 2019 Posted February 20, 2019 setTimer( function() createVehicle(ID,X,Y,Z,ROT,etc) end end, 600000, 0) Hope this helps!
hamed Posted February 21, 2019 Author Posted February 21, 2019 On 20/02/2019 at 19:15, Peti said: Which errors are you getting? Show me your code to see what is happening. WARNING: autor/server.lua:3: Bad argument @ 'getResourceState' [Expected resource-data at argument 1, got nil] On 20/02/2019 at 21:02, stPatrick said: Insert this line somewhere your code: -- SERVER SIDE setTimer(restartResource, 600000, 1, getThisResource()) just this? or add this on peti rescourse? On 20/02/2019 at 21:15, Knuck said: setTimer( function() createVehicle(ID,X,Y,Z,ROT,etc) end end, 600000, 0) Hope this helps! no men i want a script for automatic restart resource for respawn car maps . you get my mean?
Moderators IIYAMA Posted February 21, 2019 Moderators Posted February 21, 2019 local selectedResourceName = "" -- < fill in -- This function will be restarting a selected resource. local function restartSelectedResource (selectedResource) local resourceState = getResourceState(selectedResource) if resourceState == "running" then restartResource(selectedResource) elseif resourceState == "loaded" then startResource(selectedResource) end end addEventHandler("onResourceStart", resourceRoot, function () local selectedResource = getResourceFromName(selectedResourceName) if selectedResource then setTimer(restartSelectedResource, 600000, 0, selectedResource) else outputChatBox("Can't find the selected resource.") cancelEvent(true, "Can't find the selected resource.") end end) https://wiki.multitheftauto.com/wiki/SetTimer https://wiki.multitheftauto.com/wiki/OnResourceStart https://wiki.multitheftauto.com/wiki/GetResourceFromName https://wiki.multitheftauto.com/wiki/StartResource https://wiki.multitheftauto.com/wiki/RestartResource https://wiki.multitheftauto.com/wiki/GetResourceState https://wiki.multitheftauto.com/wiki/CancelEvent Make sure the resource has access to these functions <right name="function.startResource" access="true" /> <right name="function.restartResource" access="true" /> startResource restartResource Those functions are blocked by default because they are used for administration purposes. Step 1 The rights can be requested by the resource if you add these lines in to your meta.xml: <aclrequest> <right name="function.startResource" access="true" /> <right name="function.restartResource" access="true" /> </aclrequest> Step 2 Commands left to do: (fill in the <resourceName> of the resource that contains this script) /refreshall /aclrequest allow <resourceName> all 1 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
DNL291 Posted February 21, 2019 Posted February 21, 2019 (edited) Or maybe you just want to respawn vehicles with these functions: setVehicleRespawnPosition -- optional setTimer getElementsByType -- getElementsByType("vehicle", resourceRoot) : to retrieve all vehicles created on the same resource whose function is) respawnVehicle Edited February 21, 2019 by DNL291 Please do not PM me with scripting related question nor support, use the forums instead.
hamed Posted February 21, 2019 Author Posted February 21, 2019 34 minutes ago, IIYAMA said: local selectedResourceName = "" -- < fill in -- This function will be restarting a selected resource. local function restartSelectedResource (selectedResource) local resourceState = getResourceState(selectedResource) if resourceState == "running" then restartResource(selectedResource) elseif resourceState == "loaded" then startResource(selectedResource) end end addEventHandler("onResourceStart", resourceRoot, function () local selectedResource = getResourceFromName(selectedResourceName) if selectedResource then setTimer(restartSelectedResource, 600000, 0, selectedResource) else outputChatBox("Can't find the selected resource.") cancelEvent(true, "Can't find the selected resource.") end end) https://wiki.multitheftauto.com/wiki/SetTimer https://wiki.multitheftauto.com/wiki/OnResourceStart https://wiki.multitheftauto.com/wiki/GetResourceFromName https://wiki.multitheftauto.com/wiki/StartResource https://wiki.multitheftauto.com/wiki/RestartResource https://wiki.multitheftauto.com/wiki/GetResourceState https://wiki.multitheftauto.com/wiki/CancelEvent Make sure the resource has access to these functions <right name="function.startResource" access="true" /> <right name="function.restartResource" access="true" /> startResource restartResource Those functions are blocked by default because they are used for administration purposes. Step 1 The rights can be requested by the resource if you add these lines in to your meta.xml: <aclrequest> <right name="function.startResource" access="true" /> <right name="function.restartResource" access="true" /> </aclrequest> Step 2 Commands left to do: (fill in the <resourceName> of the resource that contains this script) /refreshall /aclrequest allow <resourceName> all very ty for help me man . good luck
MIKI785 Posted February 22, 2019 Posted February 22, 2019 18 hours ago, DNL291 said: Or maybe you just want to respawn vehicles with these functions: setVehicleRespawnPosition -- optional setTimer getElementsByType -- getElementsByType("vehicle", resourceRoot) : to retrieve all vehicles created on the same resource whose function is) respawnVehicle Isn't using these better? toggleVehicleRespawnsetVehicleRespawnDelaysetVehicleIdleRespawnDelay Lua Scripter Owner of mshost.cz MTA portal.
hamed Posted February 22, 2019 Author Posted February 22, 2019 4 hours ago, MIKI785 said: Isn't using these better? toggleVehicleRespawnsetVehicleRespawnDelaysetVehicleIdleRespawnDelay This script dont restart resources for respawn cars this script respawn cars without restart .
DNL291 Posted February 22, 2019 Posted February 22, 2019 6 hours ago, MIKI785 said: Isn't using these better? toggleVehicleRespawnsetVehicleRespawnDelaysetVehicleIdleRespawnDelay He said "respawn cars every 10 minutes", so I understood that he wants to respawn even if the vehicle is not idle or blown. But for some reason, it looks like he just wants the resource to be restarted so .. Please do not PM me with scripting related question nor support, use the forums instead.
Wineof Posted February 25, 2019 Posted February 25, 2019 On 22/02/2019 at 01:03, IIYAMA said: local selectedResourceName = "" -- < fill in -- This function will be restarting a selected resource. local function restartSelectedResource (selectedResource) local resourceState = getResourceState(selectedResource) if resourceState == "running" then restartResource(selectedResource) elseif resourceState == "loaded" then startResource(selectedResource) end end addEventHandler("onResourceStart", resourceRoot, function () local selectedResource = getResourceFromName(selectedResourceName) if selectedResource then setTimer(restartSelectedResource, 600000, 0, selectedResource) else outputChatBox("Can't find the selected resource.") cancelEvent(true, "Can't find the selected resource.") end end) https://wiki.multitheftauto.com/wiki/SetTimer https://wiki.multitheftauto.com/wiki/OnResourceStart https://wiki.multitheftauto.com/wiki/GetResourceFromName https://wiki.multitheftauto.com/wiki/StartResource https://wiki.multitheftauto.com/wiki/RestartResource https://wiki.multitheftauto.com/wiki/GetResourceState https://wiki.multitheftauto.com/wiki/CancelEvent Make sure the resource has access to these functions <right name="function.startResource" access="true" /> <right name="function.restartResource" access="true" /> startResource restartResource Those functions are blocked by default because they are used for administration purposes. Step 1 The rights can be requested by the resource if you add these lines in to your meta.xml: <aclrequest> <right name="function.startResource" access="true" /> <right name="function.restartResource" access="true" /> </aclrequest> Step 2 Commands left to do: (fill in the <resourceName> of the resource that contains this script) /refreshall /aclrequest allow <resourceName> all this is beter than all i thing
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