hamed Posted February 14, 2019 Share 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? Link to comment
Peti Posted February 15, 2019 Share 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 Link to comment
hamed Posted February 20, 2019 Author Share 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 Link to comment
Peti Posted February 20, 2019 Share Posted February 20, 2019 Which errors are you getting? Show me your code to see what is happening. Link to comment
Moderators Patrick Posted February 20, 2019 Moderators Share 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 Link to comment
VenomOG Posted February 20, 2019 Share Posted February 20, 2019 setTimer( function() createVehicle(ID,X,Y,Z,ROT,etc) end end, 600000, 0) Hope this helps! Link to comment
hamed Posted February 21, 2019 Author Share 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? Link to comment
Moderators IIYAMA Posted February 21, 2019 Moderators Share 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 Link to comment
DNL291 Posted February 21, 2019 Share 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 Link to comment
hamed Posted February 21, 2019 Author Share 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 Link to comment
MIKI785 Posted February 22, 2019 Share 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 Link to comment
hamed Posted February 22, 2019 Author Share 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 . Link to comment
DNL291 Posted February 22, 2019 Share 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 .. Link to comment
Wineof Posted February 25, 2019 Share 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 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