SA-MP Forums Archive
Why is this giving me a tag mismatch, when they are forwarded ints? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Why is this giving me a tag mismatch, when they are forwarded ints? (/showthread.php?tid=632022)



Why is this giving me a tag mismatch, when they are forwarded ints? - denNorske - 08.04.2017

Hello, quick question.

Why would the code giving me a tag mismatch, even when the forwarded variable is originally defined in an enum, then forwarded from OnDialogResponse to a function called "TogglePCPSettings" ? I can't seem to understand the compiler here. The case under "OnDialogResponse" throws no warnings. (switch(dialogid)).

PHP код:
enum dialogids
{
    ...,
    ...,
    
pcpSettings,
    ...,
    ...
};
TogglePCPSettings(playeriddialogidlistitem)
{
    if(
dialogid == pcpSettings)  //Giving a tag mismatch.
    
{
        if(
listitem == 1)
        {
            ..
        }
    ..
}
//OnDialogResponse:
case pcpSettings:
{
    if(!
response)
        
ShowPCPMenu(playerid);
    else
    {
        
TogglePCPSettings(playeriddialogidlistitem);
    }
    return 
1;




Re: Why is this giving me a tag mismatch, when they are forwarded ints? - Michael@Belgium - 08.04.2017

Just do
Код:
enum { ... }
No need to give it a name. Else u need to make a new variable like
Код:
new Dialogs[dialogids]
and use that in the if statement


Re: Why is this giving me a tag mismatch, when they are forwarded ints? - SyS - 08.04.2017

remove the alias of enumerator
Edit: i hate this forum


Re: Why is this giving me a tag mismatch, when they are forwarded ints? - denNorske - 08.04.2017

Thanks, I'll try that, didn't realise it had an impact.

Edit: Solution was to remove the enum name. Thanks Sreyas.
Any explanation to what happens to the enum? does it become

Код:
dialogids:pcpSettings
?


Re: Why is this giving me a tag mismatch, when they are forwarded ints? - Michael@Belgium - 08.04.2017

Thats the kind of enum i mean u have to make. Without a name. You have
Код:
enum dialogids { }
while it better be
Код:
enum { }



Re: Why is this giving me a tag mismatch, when they are forwarded ints? - NaS - 08.04.2017

Quote:
Originally Posted by denNorske
Посмотреть сообщение
Thanks, I'll try that, didn't realise it had an impact.

Edit: Solution was to remove the enum name. Thanks Sreyas.
Any explanation to what happens to the enum? does it become

Код:
dialogids:pcpSettings
?
Yea, they are pretty much like tags internally.

You can still keep the name of the enum, but you will have to do:

Код:
if(dialogid == _:pcpSettings)
Which is just unneccessary in most cases.

But this can also be very useful if you want to make toggleable dialogs.

You'd just have to create an array with that enum and could do

Код:
DialogEnabled[pcpSettings] = 1;
and in OnDialogResponse

Код:
if(!DialogEnabled[dialogids:dialogid]) return 1;
or similar.

After all it would probably be easier to do it without the enum name, but it's possible. Dialogs are also a bad example here.


Re: Why is this giving me a tag mismatch, when they are forwarded ints? - denNorske - 08.04.2017

Quote:
Originally Posted by NaS
Посмотреть сообщение
Yea, they are pretty much like tags internally.

You can still keep the name of the enum, but you will have to do:

Код:
if(dialogid == _:pcpSettings)
Which is just unneccessary in most cases.

But this can also be very useful if you want to make toggleable dialogs.

You'd just have to create an array with that enum and could do

Код:
DialogEnabled[pcpSettings] = 1;
and in OnDialogResponse

Код:
if(!DialogEnabled[dialogids:dialogid]) return 1;
or similar.

After all it would probably be easier to do it without the enum name, but it's possible. Dialogs are also a bad example here.
Got it now, thank you.

I have been using enums that way for a private vehicle system, and it's pretty useful to know when you're looping through an enum to see if the car-slots are used or not.

Thanks for the explanation and effort you put into it