can i do this? (||)
#1

pawn Code:
if(channel == g_Discord_Admin_CMD)
    {
        if(!strcmp(command, "!mycommand", true)) {
            if(role == (g_Role_Level_1 || g_Role_Level_2 || g_Role_Level_3 || g_Role_Level_4)) { //<<<<<<<<<<<<<<<<<<<<<
                //My action
            } else return DCC_SendChannelMessage(g_Discord_Admin_CMD, "```ERROR: You're not an admin!```");
        }
    }
Reply
#2

I am not sure you can. Try like this:
PHP Code:
if(channel == g_Discord_Admin_CMD)
{
    if(!
strcmp(command"!mycommand"true)) 
    {
        if(
role == g_Role_Level_1 || role == g_Role_Level_2 || role == g_Role_Level_3 || role == g_Role_Level_4)
        {
            
//My action
        

        else return 
DCC_SendChannelMessage(g_Discord_Admin_CMD"```ERROR: You're not an admin!```");
    }

Reply
#3

Quote:
Originally Posted by SharpenBlade
View Post
I am not sure you can. Try like this:
PHP Code:
if(channel == g_Discord_Admin_CMD)
{
    if(!
strcmp(command"!mycommand"true)) 
    {
        if(
role == g_Role_Level_1 || role == g_Role_Level_2 || role == g_Role_Level_3 || role == g_Role_Level_4)
        {
            
//My action
        

        else return 
DCC_SendChannelMessage(g_Discord_Admin_CMD"```ERROR: You're not an admin!```");
    }

I have 8 or more admin roles.. It would be too long if i do that (i guess). Or can i use switch or something like
PHP Code:
new g_Role[8]; 
?

But i have no idea how to make that. Can you give me an example? How to make this as simple as possible?
I have this
pawn Code:
new DCC_Role:g_Role_Level_1;
new DCC_Role:g_Role_Level_2;
new DCC_Role:g_Role_Level_3;
new DCC_Role:g_Role_Level_4;
new DCC_Role:g_Role_Level_5;
new DCC_Role:g_Role_Level_6;
new DCC_Role:g_Role_Level_7;
new DCC_Role:g_Role_Level_8;
And this under OnGameModeInit()

pawn Code:
g_Role_Level_1 = DCC_FindRoleById("myroleid");
g_Role_Level_2 = DCC_FindRoleById("myroleid");
g_Role_Level_3 = DCC_FindRoleById("myroleid");
g_Role_Level_4 = DCC_FindRoleById("myroleid");
g_Role_Level_5 = DCC_FindRoleById("myroleid");
g_Role_Level_6 = DCC_FindRoleById("myroleid");
g_Role_Level_7 = DCC_FindRoleById("myroleid");
g_Role_Level_8 = DCC_FindRoleById("myroleid");
Reply
#4

Nope.
Tip: Create a filterscript and create a similar code to test it if you wanna know something like this. Example:

pawn Code:
#include <a_samp>

enum
{
    Role1 = 1,
    Role2,
    Role3,
    Role4,
    Role5
};

public OnFilterScriptInit()
{
    new role = Role4;
    if (role == (Role1 || Role4))
        print("Role is Role1 or Role4!");
    return 1;
}
EDIT: Can't use switches either; they require constant values.

I think the best solution for you is to use macro's.
Reply
#5

1 more question..
How can i get the 'rolename'?
pawn Code:
forward DCC_OnMessageCreate(DCC_Message:message);
public DCC_OnMessageCreate(DCC_Message:message)
{
    new realMsg[100];
    DCC_GetMessageContent(message, realMsg, 100);
    new bool:IsBot;
    new DCC_Channel:channel;
    DCC_GetMessageChannel(message, channel);
    new DCC_User:author;
    DCC_GetMessageAuthor(message, author);
    //=================This is what i dont get==================================
    new DCC_Role:role, rolename[128];//<<<<<<<<<<<<<<<<<<<<
    DCC_GetRoleName(role, rolename, 128);//<<<<<<<<<<<<<<<<<<<<
    //==========================================================================
    DCC_IsUserBot(author, IsBot);
    if(IsBot) return 1;
    new discordstr[256];
    new command[32], params[128];
    DCC_GetMessageContent(message, discordstr);
    sscanf(discordstr, "s[32]s[128]", command, params);
    if(channel == g_Discord_Admin_CMD)
    {
        if(!strcmp(command, "!mycommand", true)) {
            if(rolename == g_Role_Level_1 || rolename == g_Role_Level_2 || rolename == g_Role_Level_3 || rolename == g_Role_Level_4) {//<<<<<<<<<<<<<<<<<<<<<<<<
                //My actions
            } else return DCC_SendChannelMessage(g_Discord_Admin_CMD, "```ERROR: You are not a high enough level to use this command```");
        }
    }
    return 1;
}
Code:
error 033: array must be indexed (variable "rolename")
I tried it some ways, and still getting errors.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)