Raised This Month: $32 Target: $400
 8% 

SourceMod::INativeInvoker with variable arguments


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Chrisber
AlliedModders Donor
Join Date: Jul 2007
Location: localhost
Old 01-11-2014 , 18:37   SourceMod::INativeInvoker with variable arguments
Reply With Quote #1

Hello,

how can I use variable argument functions with the SourceMod::INativeInvoker interface?
The following works:
PHP Code:
invoker->Start(context"PrintToServer");
invoker->PushString("Testline");
cell_t result;
invoker->Invoke(&result); 
The following gives me an access violation with 0xBAADF00D error code.
PHP Code:
invoker->Start(context"PrintToServer");
invoker->PushString("Testline: %0.2f");
invoker->PushFloat(gpGlobals->curtime);
cell_t result;
invoker->Invoke(&result); 
I also tried to push the float first, but it didn't work either.
Ideas? Thanks!
Chrisber is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 01-11-2014 , 21:29   Re: SourceMod::INativeInvoker with variable arguments
Reply With Quote #2

I think you need to push the number of arguments where the vararg param is. So: "Testline: %0.2f", 1, gpGlobals->curtime
__________________
asherkin is offline
Chrisber
AlliedModders Donor
Join Date: Jul 2007
Location: localhost
Old 01-12-2014 , 06:08   Re: SourceMod::INativeInvoker with variable arguments
Reply With Quote #3

This doesn't work either :/
Chrisber is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 01-12-2014 , 08:37   Re: SourceMod::INativeInvoker with variable arguments
Reply With Quote #4

Quote:
Originally Posted by Chrisber View Post
This doesn't work either :/
Aha, "Same as '...' in plugins, anything can be pushed, but it will always be byref".

You need to use the *ByRef versions of the Push functions.
__________________
asherkin is offline
Chrisber
AlliedModders Donor
Join Date: Jul 2007
Location: localhost
Old 01-12-2014 , 17:40   Re: SourceMod::INativeInvoker with variable arguments
Reply With Quote #5

My bad. I already tried that... I had the debug print in the GameFrame function and started the server, and it always printed "1.00". I thought this is because of misinterpreted/random memory values. But it was because the server fall into hibernating mode when there are no players on the server... The value of gpGlobals->curtime only increases when someone is on the server. I read about that in a changelog several [weeks|months|years] ago but didn't remembered.

Thanks ;-)

Last edited by Chrisber; 01-12-2014 at 17:44.
Chrisber 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 04:06.


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