Raised This Month: $18 Target: $400
 4% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
BAILOPAN
Join Date: Jan 2004
Old 12-19-2016 , 11:23   Re: New API and Syntax
Reply With Quote #831

Functions are not first-class.
__________________
egg
BAILOPAN is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 12-24-2016 , 15:47   Re: New API and Syntax
Reply With Quote #832

Not sure if this is an issue with menus but I made a forward with only one parameter which is a pass-by-reference Menu handle.

I made the forward just like every other forward but for some reason, it's not firing nor modifying the Menu handle.

Here's the typeset for it => "function void (Menu& menu);"

EDIT: I even retested the forward by passing the Menu handle by copy instead of reference but still no firing.

I tested this by having the menu add an additional item then printing a message to all available clients by console.
__________________

Last edited by nergal; 12-24-2016 at 15:48.
nergal is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-24-2016 , 17:04   Re: New API and Syntax
Reply With Quote #833

Quote:
Originally Posted by nergal View Post
Not sure if this is an issue with menus but I made a forward with only one parameter which is a pass-by-reference Menu handle.

I made the forward just like every other forward but for some reason, it's not firing nor modifying the Menu handle.

Here's the typeset for it => "function void (Menu& menu);"

EDIT: I even retested the forward by passing the Menu handle by copy instead of reference but still no firing.

I tested this by having the menu add an additional item then printing a message to all available clients by console.
Code of how your firing it/obtaining it?
__________________
WildCard65 is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 12-24-2016 , 17:08   Re: New API and Syntax
Reply With Quote #834

Quote:
Originally Posted by nergal View Post
Not sure if this is an issue with menus but I made a forward with only one parameter which is a pass-by-reference Menu handle.

I made the forward just like every other forward but for some reason, it's not firing nor modifying the Menu handle.

Here's the typeset for it => "function void (Menu& menu);"

EDIT: I even retested the forward by passing the Menu handle by copy instead of reference but still no firing.

I tested this by having the menu add an additional item then printing a message to all available clients by console.
Handles are already pass-by-reference, though. You shouldn't need the &, right?
headline is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-24-2016 , 18:02   Re: New API and Syntax
Reply With Quote #835

Quote:
Originally Posted by Headline View Post
Handles are already pass-by-reference, though. You shouldn't need the &, right?
Internal to SM, handles are references to memory, to SM plugins, they're 32 bit integers, but you are correct that the "&" is not needed to change something in the handle.
__________________
WildCard65 is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 12-24-2016 , 18:14   Re: New API and Syntax
Reply With Quote #836

Quote:
Originally Posted by WildCard65 View Post
Code of how your firing it/obtaining it?
I'm running it as a private forward.

here's the code associated with it.

typeset -> "function void (Menu menu);"

PHP Code:
// In OnPluginStart()
g_hForwards[OnMenu] = CreateForward(ET_IgnoreParam_Cell);

void Call_OnMenuFwd(Menu menu)
{
        
Call_StartForward(g_hForwards[OnMenu]);
        
Call_PushCell(menu); //Call_PushCellRef(menu);
        
Call_Finish();
}

// In menu command
        
Menu gamemenu = new Menu(MenuHandler_PickGame);
        
gamemenu.SetTitle("Gamemode Menu: ");
        
gamemenu.AddItem("-1""None (Random Gamemode)");
        
ManageMenugamemenu ); // in handler.sp
        
Call_OnBossMenu(gamemenu);
        
gamemenu.Display(clientMENU_TIME_FOREVER); 
__________________

Last edited by nergal; 12-24-2016 at 18:18.
nergal is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-24-2016 , 19:38   Re: New API and Syntax
Reply With Quote #837

And code responsible for adding function to forward?
__________________
WildCard65 is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 12-24-2016 , 20:05   Re: New API and Syntax
Reply With Quote #838

Quote:
Originally Posted by WildCard65 View Post
And code responsible for adding function to forward?
PHP Code:
CreateNative("Mode_HookEx"Native_HookEx);

public 
int Native_HookEx(Handle pluginint numParams)
{
    
int hookIndex GetNativeCell(1);
    
    Function 
Func GetNativeFunction(2);
    if (
g_hForwards[hookIndex] != null)
        return 
AddToForward(g_hForwards[hookIndex], pluginfunc);
    return 
0;
}

// in subplugin
public void fwdOnMenu(Menu menu)
{
    
menu.AddItem("6""Testing Forward");
    for (
int i=MaxClients ; --i)
        if ( 
IsClientInGame(i) )
            
PrintToConsole(i"fwdOnMenu:: ==> Called");

__________________
nergal is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 12-30-2016 , 00:42   Re: New API and Syntax
Reply With Quote #839

Is it possible to do static properties in methodmaps?

Eg:

Code:
static int s_CollectionSize = 0;

methodmap BaseCollection
{
	public BaseCollection()
	{
		return view_as<BaseCollection>(0);
	}

	static property int Size
	{
		public get()
		{
			return s_CollectionSize;
		}
		public set(int value)
		{
			s_CollectionSize = value;
		}
	}
}
I wish to be able to do the below without having to make an methodmap instance.

Code:
BaseCollection.Size = 666;
PrintToServer("BaseCollection.Size=%d", BaseCollection.Size);
__________________

Last edited by Neuro Toxin; 01-01-2017 at 20:39.
Neuro Toxin is offline
BAILOPAN
Join Date: Jan 2004
Old 01-01-2017 , 19:11   Re: New API and Syntax
Reply With Quote #840

Quote:
Originally Posted by Neuro Toxin View Post
Is it possible to do static properties in methodmaps?
Not yet, but it wouldn't be that hard I think. Want to file a bug? In the meantime, you can use static methods to return a constant.
__________________
egg
BAILOPAN is offline
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

Forum Jump


All times are GMT -4. The time now is 13:10.


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