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

Orpheu strange invalid param count error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-24-2015 , 11:40   Orpheu strange invalid param count error
Reply With Quote #1

My signature file:
Code:
{
    "name"        : "Spawn",
    "class"       : "CWeaponBox",
    "library"     : "mod",
    "identifiers" :
    [
        {
            "os"    : "windows",
            "mod"   : "cstrike",
            "value" : [0x56,0x8B,0xF1,0x8B,0x06,0xFF,0x50,0x04,0x8B,0x4E,0x04,"*","*","*","*","*","*","*","*","*","*",0xC7,0x81,0x08,0x01,0x00,0x00,0x06,0x00,0x00,0x00,0x8B]
        },
        {
            "os"    : "linux",
            "mod"   : "cstrike",
            "value" : "Spawn__10CWeaponBox"
        }
    ]
}
The log:
Code:
Parsing file "Spawn" started
	Function is updated
Parsing file "Spawn" ended
The call:
PHP Code:
WeaponBox OrpheuCall(CWeaponBox_Spawn
The error:
Code:
L 01/24/2015 - 08:33:54: [ORPHEU] Invalid parameters count. Expected [2]. Got [1]
L 01/24/2015 - 08:33:54: [AMXX] Displaying debug trace (plugin "test2.amxx")
L 01/24/2015 - 08:33:54: [AMXX] Run time error 10: native error (native "OrpheuCall")
L 01/24/2015 - 08:33:54: [AMXX]    [0] Untitled.sma::create (line 48)
Registering the func:
PHP Code:
CWeaponBox_Spawn OrpheuGetFunction("Spawn""CWeaponBox")
//OrpheuRegisterHook(CWeaponBox_Spawn,"CWeaponBoxSpawn",OrpheuHookPre) 
Why it says that the native expect two params ? I the signature the arguments field is empty since the function has void into the header.

I'm thinking that OrpheuCall need at least one argument(one arg + function index = two params), but:

PHP Code:
unsigned int paramsCount params[0] / sizeof(cell);

    Function* function = Global::
FunctionManagerObj->getFunction(params[1]);

    if (function)
    {
        
unsigned int expectedParamsCount + function->getArgumentsCount() + function->getIfReturnByRefParamsCount();

        if (
paramsCount == expectedParamsCount)
        {
            function->
blockHooks();
            return function->
call(amx, &params[2]);
        }
        else
        {
            
MF_LogError(amxAMX_ERR_NATIVE"Invalid parameters count. Expected [%d]. Got [%d]"expectedParamsCountparamsCount);
        }
    }
    else
    {
        
MF_LogError(amxAMX_ERR_NATIVE"Invalid function [%d]"params[1]);
    }

    return 
0
I see that here it does some calculation to determinate the needed param count, maybe there is something wrong ?

Any ideeas why this error apper when the function has no arguments ?
__________________

Last edited by HamletEagle; 01-24-2015 at 11:42.
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-24-2015 , 13:09   Re: Orpheu strange invalid param count error
Reply With Quote #2

Because the current instance of CWeaponBox class is not passed, meaning the hidden object "this", which from pawn context refers to an entity index. In others words, when you create a "weaponbox" entity, the returned value is an instance of CWeaponBox class, and from that, it allows you to access to functions which are included in this class, here Spawn.

Spawn is a virtual function. To call CWeaponBox::Spawn, you need to create a "weaponbox" entity, and just calling Ham_Spawn with it.
__________________

Last edited by Arkshine; 01-24-2015 at 13:09.
Arkshine is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-24-2015 , 13:49   Re: Orpheu strange invalid param count error
Reply With Quote #3

I was doing that only to know if we can manipulate weaponboxes only with game functions, without doing manually things like creating, spawning, adding weapons, removing and so on.
In the decompiled windows code I saw int __thiscall sub_100CFD70(void *this) which confused me a bit because void mean nothing, now I understood what was with it.

Thanks!
__________________
HamletEagle is offline
Old 01-24-2015, 13:51
HamletEagle
This message has been deleted by HamletEagle.
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-24-2015 , 14:02   Re: Orpheu strange invalid param count error
Reply With Quote #4

You just need to pass a valid object, whatever retrieved from a new weaponbox or existing entity.
__________________
Arkshine 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 22:11.


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