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

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
Miu
Veteran Member
Join Date: Nov 2013
Old 01-23-2016 , 03:29   Re: New API and Syntax
Reply With Quote #681

I assume it needs to be static, if there is such a thing
Miu is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 01-23-2016 , 12:39   Re: New API and Syntax
Reply With Quote #682

Quote:
Originally Posted by Miu View Post
I assume it needs to be static, if there is such a thing
There is! Gotta do it like this...

PHP Code:
    public static Action dotimerz(Handle Timerany data)
    {
        
//code;
        
return Plugin_Continue;
    } 
Strange this is though, it's giving me a syntax error...

( template.sp(62) : error 001: expected token: "(", but found "," )

which is this code.

CreateTimer(120.0, MethMap.dotimerz, objectx.userid);

How do I get a function pointer from a methodmap function?
__________________

Last edited by nergal; 01-23-2016 at 12:39.
nergal is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 01-23-2016 , 14:46   Re: New API and Syntax
Reply With Quote #683

I suppose it's expecting you to call it. Looks like a bug.
Miu is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 01-23-2016 , 15:51   Re: New API and Syntax
Reply With Quote #684

Quote:
Originally Posted by Miu View Post
I suppose it's expecting you to call it. Looks like a bug.
yea it is lmao. It needs a func pointer but idk how to get a func pointer from a methodmap.
__________________
nergal is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 01-23-2016 , 16:13   Re: New API and Syntax
Reply With Quote #685

I don't think it's expected to be supported - the current methods of passing functions are being phased out in favour of the machinery for anonymous function support.
__________________
asherkin is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 01-23-2016 , 16:45   Re: New API and Syntax
Reply With Quote #686

Quote:
Originally Posted by asherkin View Post
I don't think it's expected to be supported - the current methods of passing functions are being phased out in favour of the machinery for anonymous function support.
ahhh I c, what are the (so far) future methods of passing function pointers?
__________________
nergal is offline
BAILOPAN
Join Date: Jan 2004
Old 01-25-2016 , 14:42   Re: New API and Syntax
Reply With Quote #687

For all the limitations we have with functions, passing a static function around should be workable. Please file a bug and I'll fix.
__________________
egg
BAILOPAN is offline
Disowned
Member
Join Date: Oct 2015
Old 01-27-2016 , 01:23   Re: New API and Syntax
Reply With Quote #688

What exactly is the & operator for in the old syntax and how can it be used in the new syntax?
Compiles:
native bool somefunction(&Float:value);

Doesn't compile
native bool somefunction2(&float value);
Disowned is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 01-27-2016 , 01:33   Re: New API and Syntax
Reply With Quote #689

Search for "reference operator" or "pass by reference" to find out what the & does in this context.

Try
PHP Code:
native bool somefunction2(float &value); 
to fix the compilation error.
__________________

Last edited by Impact123; 01-27-2016 at 01:34.
Impact123 is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 01-27-2016 , 01:33   Re: New API and Syntax
Reply With Quote #690

float &value
__________________
ddhoward 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 03:35.


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