Raised This Month: $51 Target: $400
 12% 

Solved [NEWDECLS] Tag mismatch, not sure how to proceed.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
404UserNotFound
BANNED
Join Date: Dec 2011
Old 05-26-2016 , 18:53   [NEWDECLS] Tag mismatch, not sure how to proceed.
Reply With Quote #1

So I was converting the Pyro's Hadouken plugin to newdecls, and here's what I've got thus far:

Spoiler


Specifically, the lines that are triggering the two tag mismatch errors are the two "returns" within the RocketsGameFired function;

Spoiler


What do.

(thank god the compiler tells you if you screwed up and used "void" where you should've used "Action" for example, that's a big help for me)

Last edited by 404UserNotFound; 08-20-2016 at 18:34.
404UserNotFound is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 05-26-2016 , 19:14   Re: [NEWDECLS] Tag mismatch, not sure how to proceed.
Reply With Quote #2

RocketsGameFired should be int, not Action. And why are you returning -0?
Phil25 is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 05-26-2016 , 20:35   Re: [NEWDECLS] Tag mismatch, not sure how to proceed.
Reply With Quote #3

here's a little something to help you out:
PHP Code:
DoSomething() {} 
is the same as:
PHP Code:
int DoSomething() {} 
just with the compiler possibly complaining about no value being returned.

Also:
PHP Code:
Action:DoSomething() { return Plugin_Continue; } 
is the same as:
PHP Code:
Action DoSomething() { return Plugin_Continue; } 
WildCard65 is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 05-26-2016 , 20:40   Re: [NEWDECLS] Tag mismatch, not sure how to proceed.
Reply With Quote #4

there's no negative zero in modern int representations, just return -1
Miu is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 05-26-2016 , 21:44   Re: [NEWDECLS] Tag mismatch, not sure how to proceed.
Reply With Quote #5

The prototype in the documentation specifies Action. void also works.
https://sm.alliedmods.net/new-api/events/EventHook
__________________

Last edited by ddhoward; 05-26-2016 at 21:44.
ddhoward is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 05-26-2016 , 23:27   Re: [NEWDECLS] Tag mismatch, not sure how to proceed.
Reply With Quote #6

It was contained within the includes, which is what the api pages were/are automagically generated from.

https://sm.alliedmods.net/api/index....e&id=38&file=&

PHP Code:
funcenum EventHook
{
    
/**
     * Called when a game event is fired.
     *
     * @param event            Handle to event. This could be INVALID_HANDLE if every plugin hooking 
     *                        this event has set the hook mode EventHookMode_PostNoCopy.
     * @param name            String containing the name of the event.
     * @param dontBroadcast    True if event was not broadcast to clients, false otherwise.
     * @return                Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
     */
    
Action:public(Handle:event, const String:name[], bool:dontBroadcast),
    
/**
     * Called when a game event is fired.
     *
     * @param event            Handle to event. This could be INVALID_HANDLE if every plugin hooking 
     *                        this event has set the hook mode EventHookMode_PostNoCopy.
     * @param name            String containing the name of the event.
     * @param dontBroadcast    True if event was not broadcast to clients, false otherwise.
     * @noreturn
     */
    
public(Handle:event, const String:name[], bool:dontBroadcast),
}; 
aaand the new syntax equivalent:
https://sm.alliedmods.net/new-api/events/__raw

PHP Code:
typeset EventHook
{
    
// Called when a game event is fired.
    //
    // @param event            Handle to event. This could be INVALID_HANDLE if every plugin hooking 
    //                        this event has set the hook mode EventHookMode_PostNoCopy.
    // @param name            String containing the name of the event.
    // @param dontBroadcast    True if event was not broadcast to clients, false otherwise.
    // @return                Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
    ///
    
function Action (Event event, const char[] namebool dontBroadcast);
    
//
    // Called when a game event is fired.
    //
    // @param event            Handle to event. This could be INVALID_HANDLE if every plugin hooking 
    //                        this event has set the hook mode EventHookMode_PostNoCopy.
    // @param name            String containing the name of the event.
    // @param dontBroadcast    True if event was not broadcast to clients, false otherwise.
    // @noreturn
    ///
    
function void (Event event, const char[] namebool dontBroadcast);
}; 
__________________

Last edited by ddhoward; 05-26-2016 at 23:29.
ddhoward is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 05-27-2016 , 14:48   Re: [NEWDECLS] Tag mismatch, not sure how to proceed.
Reply With Quote #7

Quote:
Originally Posted by abrandnewday View Post
Got another question;

PHP Code:
public Action Event_PlayerSpawn(Handle hEvent, const char[] strNamebool bDontBroadcast)
{
    
int iClient GetClientOfUserId(hEvent.GetInt("userid")); 
That above code gives me a method error; "error 105: cannot find method or property Handle.GetInt"

If I switch "Handle hEvent" to "Event hEvent", it compiles properly.

Why? If I'm converting from old syntax to new, do I need to switch events from "Handle hEvent" to "Event hEvent"?

EDIT: Just now realizing that I'm using a horrible mishmash of old and new syntax. New syntax should be "Event hEvent".
Yes, these are the methods for the Event class: https://sm.alliedmods.net/new-api/events/Event

Take a look at the methods for the Handle class: https://sm.alliedmods.net/new-api/handles/Handle

As you can see, there isn't a Handle.GetInt in the Handle class but a Event.GetInt in the Event class.

Edit: Just realized you made an edit
__________________

Last edited by Chaosxk; 05-27-2016 at 14:50.
Chaosxk is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 05-27-2016 , 14:57   Re: [NEWDECLS] Tag mismatch, not sure how to proceed.
Reply With Quote #8

Quote:
Originally Posted by abrandnewday View Post
EDIT: Just now realizing that I'm using a horrible mishmash of old and new syntax. New syntax should be "Event hEvent".
Technically, it's not a mismatch of old and new syntax, this is:
PHP Code:
int g// New
Handle:x// Old (Because of the semicolon) 
the following is above but without the mismatch:
PHP Code:
int g;
Handle x 
WildCard65 is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 05-27-2016 , 16:33   Re: [NEWDECLS] Tag mismatch, not sure how to proceed.
Reply With Quote #9

Quote:
Originally Posted by abrandnewday View Post
(I said mishmash, not mismatch )

And yeah, I see that it works if you keep "Handle", but then you can't do the new syntax "hEvent.GetEventInt" stuff, because it won't compile with "Handle"
view_as<Event>(hHandle).GetInt() is valid
WildCard65 is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 05-27-2016 , 18:44   Re: [NEWDECLS] Tag mismatch, not sure how to proceed.
Reply With Quote #10

Sometimes it's better to keep using handles. I base that "sometimes" off that dynamic arrays work properly all the way when you have them as handles but will bug in some methods when you use ArrayList.
Phil25 is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 07:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode