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

[Orpheu] Getting structmember value?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Simo123
Junior Member
Join Date: Feb 2009
Old 10-03-2014 , 22:36   [Orpheu] Getting structmember value?
Reply With Quote #1

Hello, I'm trying to get a value of a structmember in Orpheu, I don't wanna set it. Following code sets the value, which works completely fine: OrpheuSetStructMember(ppmove, "fuser2", 0.0)

I wanna get the value with: new fuser3 = OrpheuGetStructMember(ppmove, "fuser2") /*0.0*/
which doesn't work, and print it to client_print(0, print_chat, "fuser2: %d", fuser3)

Errors I get are: [ORPHEU] Invalid structure provided [AMXX] Run time error 10: native error (native "OrpheuGetStructMember")

In the documentation it says:

PHP Code:
/**
 * Sets the value of a member of a struct given a struct handler and the member name
 * 
 * @param struct         A handler to the struct
 * @param memberName     The name of the member of the struct we want to deal with
 * @param any             The new value
 */
native OrpheuSetStructMember(OrpheuStruct:struct,const memberName[],any:...)

/**
 * Retrieves the value of a member of a struct given a struct handler and the member name
 * 
 * @param struct         A handler to the struct
 * @param memberName     The name of the member of the struct we want to deal with
 * @param any             In case the value is multi cell (string or vector), an holder to receive them by ref
 * 
 * @return                In case the value is uni cell, the value itself
 */
native OrpheuGetStructMember(OrpheuStruct:struct,const memberName[],any:...) 
Hopefully you understood me, thanks in advance.
Simo123 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 10-03-2014 , 23:49   Re: [Orpheu] Getting structmember value?
Reply With Quote #2

Putting aside the fact that you've formatted your string incorrectly, you shouldn't be getting an error assuming that the rest of your code is correct. Post your code.
Also, to me, this sounds like a bit of an XY Problem - chances are you don't need to be using Orpheu to do this ( especially if its related to fall damage ), so you should also explain what your actually trying to achieve.
hornet is offline
Simo123
Junior Member
Join Date: Feb 2009
Old 10-04-2014 , 02:21   Re: [Orpheu] Getting structmember value?
Reply With Quote #3

As you want, https://forums.alliedmods.net/attach...4&d=1286304664 It's a public plugin. Mr. Connor didn't add a cvar or similiar to toggle it on/off, this can probably be done by resetting the values to default from what the plugin changes or use Orpheu supercede return.

Though when I tried to do Orpheu supercede/ignore (return supercede to cvar = 0) it gives me a tag mismatch error (probably because it doesn't work under that kind of function), so method 2 as what I'm doing right now is to get the default stats of fuser2 & maxspeed of what he replaced them with and then reset it back to default, when you're using the cvar since method 1 didn't work for me, example amx_axn_bhop 0/1. I simply wanna add a cvar, these are the 2 methods I know of, method 1 didn't work for me.
Simo123 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-04-2014 , 10:04   Re: [Orpheu] Getting structmember value?
Reply With Quote #4

"Though when I tried to do Orpheu supercede/ignore (return supercede to cvar = 0) it gives me a tag mismatch error (probably because it doesn't work under that kind of function),"

No, it's because you have to add OrpheuHookReturn like this: public OrpheuHookReturn: public_name
__________________
HamletEagle is offline
Simo123
Junior Member
Join Date: Feb 2009
Old 10-04-2014 , 10:45   Re: [Orpheu] Getting structmember value?
Reply With Quote #5

Quote:
Originally Posted by HamletEagle View Post
"Though when I tried to do Orpheu supercede/ignore (return supercede to cvar = 0) it gives me a tag mismatch error (probably because it doesn't work under that kind of function),"

No, it's because you have to add OrpheuHookReturn like this: public OrpheuHookReturn: public_name
Thanks, yea compiled fine now without the warning, so I will obviously use that. Still curious of what was wrong with the 1st code I posted. Thanks again.
Simo123 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-04-2014 , 12:06   Re: [Orpheu] Getting structmember value?
Reply With Quote #6

This is supposed to be a float value (f for float), and you don't retrieve value as a float.

About your error, no idea, you better show all your code as it is, so we can understand better what you're doing.
__________________

Last edited by Arkshine; 10-04-2014 at 12:08.
Arkshine is offline
Simo123
Junior Member
Join Date: Feb 2009
Old 10-05-2014 , 00:01   Re: [Orpheu] Getting structmember value?
Reply With Quote #7

Quote:
Originally Posted by Arkshine View Post
This is supposed to be a float value (f for float), and you don't retrieve value as a float.

About your error, no idea, you better show all your code as it is, so we can understand better what you're doing.
PHP Code:
#include <amxmodx>
#include <orpheu>
#include <hlsdk_const>

#define VERSION "1.7.2"

new Float:oldMaxSpeed
new OrpheuStruct:ppmove

public plugin_init()
{
    
register_plugin("axn bhop"VERSION"aportner & ConnorMcLeod")
    new 
szVersion[12]
    
formatex(szVersioncharsmax(szVersion), "%s_Orpheu"VERSION)
    
register_cvar("axn_version"szVersionFCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)

    
OrpheuRegisterHook(OrpheuGetFunction("PM_Move"), "onPMMovePre"OrpheuHookPre)
    
OrpheuRegisterHook(OrpheuGetFunction("PM_Jump"), "onPMJumpPre"OrpheuHookPre)
    
OrpheuRegisterHook(OrpheuGetFunction("PM_Jump"), "onPMJumpPost"OrpheuHookPost)
    
//    OrpheuRegisterHook(OrpheuGetFunction("PM_PlayerMove"), "onPMPlayerMovePre", OrpheuHookPre)
    
OrpheuRegisterHook(OrpheuGetFunction("PM_Duck"), "onPMDuckPost"OrpheuHookPost)
}

public 
onPMMovePre(OrpheuStruct:pmove,server)
{
    
ppmove pmove
}

public 
onPMJumpPre()
{
    
// bhop acceleration
    
oldMaxSpeed Float:OrpheuGetStructMember(ppmove"maxspeed")
    
OrpheuSetStructMember(ppmove"maxspeed"0.0)
}

public 
onPMJumpPost()
{
    
/* Here's my code */
    
new Float:fuser3[3]
    
OrpheuGetStructMember(ppmove"fuser2"fuser3)

    
client_print(0print_chat"fuser2: %f"fuser3[2]) // example

    /* Here's my code */

    // remove fuser2 slowdown
    
OrpheuSetStructMember(ppmove"fuser2"0.0)

    
// restore maxspeed from acceleration
    
OrpheuSetStructMember(ppmove"maxspeed"oldMaxSpeed)
}

/*public onPMPlayerMovePre()
{
    
}*/

public onPMDuckPost()
{
    if(    
OrpheuGetStructMember(ppmove"onground") != -1
    
&&    OrpheuGetStructMember(OrpheuStruct:OrpheuGetStructMemberppmove"cmd" ), "buttons" ) & IN_USE    )
    {
        new 
Float:fVecVelocity[3]
        
OrpheuGetStructMember(ppmove"velocity"fVecVelocity)
        
fVecVelocity[0] *= 0.3
        fVecVelocity
[1] *= 0.3
        fVecVelocity
[2] *= 0.3
        OrpheuSetStructMember
(ppmove"velocity"fVecVelocity)
    }

That gives me a Invalid structure error, on a sidenote I think the "onPMDuckPost()" function is not working, and he does the exactly same under there
PHP Code:
new Float:fVecVelocity[3]
OrpheuGetStructMember(ppmove"velocity"fVecVelocity
I just wanna grab the value of fuser2 and print it out.
And here's the PM_Duck file which I'm using (since it's not included when you download Orpheu): https://forums.alliedmods.net/showthread.php?t=118476
Taken from joaquims PM_Pack.

Last edited by Simo123; 10-05-2014 at 00:05.
Simo123 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 10-05-2014 , 00:39   Re: [Orpheu] Getting structmember value?
Reply With Quote #8

The only thing that should be causing an error is your Jump Post hook because your trying to retrieve a vector from a float key.
Code:
OrpheuGetStructMember(ppmove, "fuser2", fuser3)
hornet is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-05-2014 , 03:40   Re: [Orpheu] Getting structmember value?
Reply With Quote #9

Hornet is right, fuser is not a vector.

And seriously, what the point to give an error associated with the wrong code in your first post? Talk about wasting people's time. -_-
__________________

Last edited by Arkshine; 10-05-2014 at 03:41.
Arkshine is offline
Simo123
Junior Member
Join Date: Feb 2009
Old 10-05-2014 , 10:20   Re: [Orpheu] Getting structmember value?
Reply With Quote #10

Quote:
Originally Posted by Arkshine View Post
Hornet is right, fuser is not a vector.

And seriously, what the point to give an error associated with the wrong code in your first post? Talk about wasting people's time. -_-
I changed/corrected the code accordingly to the comments by time that's why the code was different.

Solved it by assigning it to a float instead, thanks for the help. On the sidenote.. I just wondered how do you get the playerid in Orpheu? I'm new to Orpheu, so it's all questions I have for now, guess I gotta post it in the Orpheu main thread? Since it's not related to the main title of this thread. See you there if someone wanna answer me there, thanks again.
Simo123 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 12:09.


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