SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/10/2017, 08:21 AM   #1
UberEverywhere
Big Clucker
 
UberEverywhere's Avatar
 
Join Date: Aug 2016
Location: United Arab Emirates
Posts: 59
Reputation: 14
Default Discord plugin help

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?
UberEverywhere is offline   Reply With Quote
Old 27/10/2017, 08:32 AM   #2
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,244
Reputation: 525
Default Re: Discord plugin help

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...
Sew_Sumi is offline   Reply With Quote
Old 27/10/2017, 08:42 AM   #3
UberEverywhere
Big Clucker
 
UberEverywhere's Avatar
 
Join Date: Aug 2016
Location: United Arab Emirates
Posts: 59
Reputation: 14
Default Re: Discord plugin help

I already showed it lol:
PHP Code:
if(sscanf(message"s[128]"test)) 
UberEverywhere is offline   Reply With Quote
Old 27/10/2017, 09:53 AM   #4
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,244
Reputation: 525
Default Re: Discord plugin help

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


"lol"....
Sew_Sumi is offline   Reply With Quote
Old 27/10/2017, 11:58 AM   #5
UberEverywhere
Big Clucker
 
UberEverywhere's Avatar
 
Join Date: Aug 2016
Location: United Arab Emirates
Posts: 59
Reputation: 14
Default Re: Discord plugin help

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)) 
UberEverywhere is offline   Reply With Quote
Old 27/10/2017, 02:29 PM   #6
Quantella
Little Clucker
 
Join Date: Jun 2017
Posts: 27
Reputation: 6
Default Re: Discord plugin help

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.
Quantella is offline   Reply With Quote
Old 27/10/2017, 02:40 PM   #7
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,244
Reputation: 525
Default Re: Discord plugin help

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.

Last edited by Sew_Sumi; 27/10/2017 at 04:17 PM.
Sew_Sumi is offline   Reply With Quote
Old 27/10/2017, 03:37 PM   #8
zMason
Little Clucker
 
zMason's Avatar
 
Join Date: Sep 2017
Posts: 36
Reputation: 10
Default Re: Discord plugin help

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?
zMason is offline   Reply With Quote
Old 27/10/2017, 03:50 PM   #9
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,244
Reputation: 525
Default Re: Discord plugin help

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.
Sew_Sumi is offline   Reply With Quote
Old 27/10/2017, 06:36 PM   #10
zMason
Little Clucker
 
zMason's Avatar
 
Join Date: Sep 2017
Posts: 36
Reputation: 10
Default Re: Discord plugin help

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.
zMason is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Discord Help baki Scripting Help 4 09/08/2017 10:28 PM
Discord for SA-MP? Lorenc_ Plugin Development 83 05/02/2017 07:01 PM


All times are GMT. The time now is 10:19 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.