DeleteResource: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 21: Line 21:
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
function()
function()
resources = getResources() --Get all resources
  resources = getResources() --Get all resources
   if (getResourceState(resource) == "loaded" and "running" or "loaded" and "starting") then --Checks to see if there's to resources that's loaded and running or loaded and starting up
   if (getResourceState(resources) == "loaded" and "running" or "loaded" and "starting") then --Checks to see if there's to resources that's loaded and running or loaded and starting up
     stopResource(resource)
     stopResource(resources)
     deleteResource(resource)
     deleteResource(resources)
   end
   end
end)
end)

Revision as of 23:34, 16 November 2011

Accessories-text-editor.png Script Example Missing Function DeleteResource needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.

This function deletes a resource.

Syntax

bool deleteResource ( string resourceName )

Required Arguments

  • resourceName: The name of resource to delete.

Returns

Returns true if the resource has been deleted successfully, false otherwise.

Example

This example checks to see if there's 2 resources.

addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
function()
   resources = getResources() --Get all resources
   if (getResourceState(resources) == "loaded" and "running" or "loaded" and "starting") then --Checks to see if there's to resources that's loaded and running or loaded and starting up
    stopResource(resources)
    deleteResource(resources)
   end
end)

Requirements

Minimum server version 1.1.1-9.03316
Minimum client version n/a

Note: Using this feature requires the resource to have the above minimum version declared in the meta.xml <min_mta_version> section. e.g. <min_mta_version server="1.1.1-9.03316" />

See Also