Thread: [Solved] First time creating natives
View Single Post
Author Message
LiveAndLetDie
Junior Member
Join Date: Sep 2019
Location: Finland
Old 03-31-2021 , 22:51   First time creating natives
Reply With Quote #1

Hey, I am learning how to create natives and after reading the article on wiki I came up with this. Does it seem correct? At least it works but it doesn't necessarily mean that's it's 'smartly' done.

.inc file

Code:
/**
 * Check if a client has a certain admin flag.
 *
 * @param num1    a client.
 * @param num2    a flag.
 * @return        True if the client has the flag, false otherwise.
 */
 
 native bool CheckClientFlag(int client, char[] flag);
.sp file

Code:
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
	CreateNative("CheckClientFlag", Native_FlagHelper);
	return APLRes_Success;
}

public any Native_FlagHelper(Handle plugin, int numParams)
{
	int client = GetNativeCell(1);
	char flag = view_as<int>(GetNativeCell(2));
	return(CheckCommandAccess(client, "", flag, true));
}
example

Code:
CheckClientFlag(client, "b");

Last edited by LiveAndLetDie; 04-04-2021 at 10:52.
LiveAndLetDie is offline