GetResourceAuthor

From GTA Network Wiki
Jump to: navigation, search

GetResourceAuthor
Server-Side Function

utilities-terminal.png Server-Side csharp.png C#

Returns the resource author's name.

Syntax

string NAPI.Resource.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)
	{
		NAPI.Chat.SendChatMessageToPlayer(player,"Please enter a resource name.");
		return;
	}
	
	//Scan resources, see if we can find the resource the player is looking for
	string resources = NAPI.Resource.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)
	{
		NAPI.Chat.SendChatMessageToPlayer(player,"Could not find a resource named " + resource);
		return;
	}
	
	//Output author to the player
	NAPI.Chat.SendChatMessageToPlayer(player,"* Resource Author: " + NAPI.Resource.GetResourceAuthor(resource));
}

Changelog

Version Description
1.0 Release.

References