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");