Discord plugin help
#1

NOTE: i posted this in Discord Plugin thread but didn't get the help i needed.
Someone told me to remove 'const' from
PHP Code:
const message[] 
but i get this error
Code:
error 025: function heading differs from prototype
[Below is what i posted in the Discord plugin thread]

Hey..

PHP Code:
public DCC_OnChannelMessage(DCC_Channel:channelDCC_User:author, const message[])
{
    new 
channel_name[32], test[128], str[128];
    
DCC_GetChannelName(channelchannel_name);
    new 
user_name[32 1];
    
DCC_GetUserName(authoruser_name);
    if(!
DCC_GetChannelName(channelchannel_name))
    {
        if(!
strcmp(message"!say"false2))
        {
            if(
sscanf(message"s[128]"test))
                return 
0;
                
            
format(strsizeof(str), "%s"test);
            
DCC_SendChannelMessage(Echo, str);
            return 
1;
        }
    }
    return 
1;

Code:
error 035: argument type mismatch (argument 1)
Line for error ^:

PHP Code:
if(sscanf(message"s[128]"test)) 
Tried my best to figure it, any help please?
Reply
#2

Shit, it'd be a good idea to highlight the line that the error occurs on rather than throwing up the error code, and having people to have to guess where the error is happening...
Reply
#3

I already showed it lol:
PHP Code:
if(sscanf(message"s[128]"test)) 
Reply
#4

Quote:
Originally Posted by UberEverywhere
View Post
I already showed it lol:
You've showed one, yet you've showed 2 error messages...


"lol"....
Reply
#5

looks like you didn't understand.
I posted this as a reply in Discord Plugin seeking for help but didn't get enough helpful replies, 1 said "remove `const` from *const message[]*" and i did, but that gave me another error which is this:
Code:
error 025: function heading differs from prototype
Now let's ignore this one for now ^

and focus on
Code:
error 035: argument type mismatch (argument 1)
which is coming from
PHP Code:
if(sscanf(message"s[128]"test)) 
Reply
#6

UberEverywhere, Sew_Sumi means that a error is most times caused by multiple lines or hard to find by a single line.
Open the code in pawn press f5, than go to the line of the error, looks like (4322). Show than the pawno error shown in that f5 tab, and the line with the error in the script included 5 lines below and above it.
Reply
#7

Partly this, but what it is is that it's expecting something in that line, and it's getting something else... Such as it's expecting a float, when it needs and integer.

Also you can't just ignore an error, as if it's an error regarding the same thing, chances are it's related, and causing the issue that you face.
Reply
#8

Quote:
Originally Posted by Sew_Sumi
View Post
The stupidest part about this is that you're using s[128], when you should actually be using str[128]... Stop copy pasting, and learn to code.
What is your claim based on? The format is s[length]

OT:

Isn't it better to use isnull in this case?
Reply
#9

Quote:
Originally Posted by zMason
View Post
What is your claim based on? The format is s[length]
It was indeed an error, but thing is the limited amount of information from the OP, along with the 'ignore this error' mentality, is simply enough to mention that he should learn how to code rather than ignoring the other errors as they don't seem to them, to have effect on the error they're trying to rush to solve.

After all, he's posted it on the discord connector page, hasn't got any fruitful response, and decides to post a thread, with limited information.


Even including the other error, which is referring to another problem in their script.


OT is also meaning Off Topic, just so you are aware.
Reply
#10

Quote:
Originally Posted by Sew_Sumi
View Post
It was indeed an error, but thing is the limited amount of information from the OP, along with the 'ignore this error' mentality, is simply enough to mention that he should learn how to code rather than ignoring the other errors as they don't seem to them, to have effect on the error they're trying to rush to solve.

After all, he's posted it on the discord connector page, hasn't got any fruitful response, and decides to post a thread, with limited information.


Even including the other error, which is referring to another problem in their script.
It's because the error he got after removing the constant was irrelevent to his original problem, someone suggested that he removes the constant which resulted in this error:
Code:
error 025: function heading differs from prototype
I assume that he was aware of this and that is why he ignored it. I think the information is pretty clear, and he is trying to learn by asking for help but this negativity won't help much.

Quote:
Originally Posted by Sew_Sumi
View Post
OT is also meaning Off Topic, just so you are aware.
I know it has 2 meanings, it's not hard to know which of the 2 is intended.

Just out of curiousity, why are you taking the extra step with sscanf and storing it in a seperate string? Why not have a more direct approach like this:

pawn Code:
public DCC_OnChannelMessage(DCC_Channel:channel, DCC_User:author, const message[])
{
    new channel_name[32];
    DCC_GetChannelName(channel, channel_name);
    new user_name[32 + 1];
    DCC_GetUserName(author, user_name);
    if(!DCC_GetChannelName(channel, channel_name))
    {
        if(!strcmp(message, "!say", false, 2))
        {
            DCC_SendChannelMessage(Echo, message);
            return 1;
        }
    }
    return 1;
}
In programming it's key that you do not repeat yourself. In your case you repeat yourself by having 2 seperate string variables and storing the message in both, which is basicly a waste of storage and time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)