GetResourceAuthor

From GT-MP
Jump to: navigation, search
GetResourceAuthor
Server-Side Function
Utilities-terminal.png Server-Side Csharp.png C#

Returns the resource author's name.


Syntax

API.getResourceAuthor(string resource);

Required Arguments

  • resource: parameter input should be in string type.

NOTE: This function returns data in string type.

Usage example(s)

Example Description

[Command("resourceauthor")]
public void getResourceAuthor(Client player, string resource)
{
	//Determine if the player has entered a resource name.
	if (resource.Length < 1)
	{
		API.sendChatMessageToPlayer(player,"Please enter a resource name.");
		return;
	}
	
	//Scan resources, see if we can find the resource the player is looking for
	string resources = API.getAllResources();
	bool found;
	foreach (r in resources)
	{
		if (r == resource)
		{
			found = true;
			break;
		}
	}
	
	//If we haven't found it, we'll tell the player and stop here.
	if (!found)
	{
		API.sendChatMessageToPlayer(player,"Could not find a resource named " + resource);
		return;
	}
	
	//Output author to the player
	API.sendChatMessageToPlayer(player,"* Resource Author: " + API.getResourceAuthor(resource));
}

References