Raised This Month: $99 Target: $400
 24% 

[TF2attributes] Grab attributs of a player ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 01-10-2014 , 07:53   [TF2attributes] Grab attributs of a player ?
Reply With Quote #1

Just wondering if there is anyway to grab a attribut of a player ?

I have done this :
PHP Code:
new hClientWeapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon");
new 
Address:attr TF2Attrib_GetByName(hClientWeapon"damage bonus");
new 
result _:TF2Attrib_GetValue(attr); 
but it seems to crash my server...

And after I correctly grab the value of attribute in 'result' can I use it to like this ?

PHP Code:
TF2Attrib_SetByName(client"damage bonus"result); 
__________________
Want to show support ?
Want to check my plugins ?
Total donation count : 310,98 ChF.- (in 3+ years)

Last edited by Arkarr; 01-10-2014 at 07:55. Reason: Edited title.
Arkarr is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-10-2014 , 09:48   Re: [TF2attributes] Grab attributs of a player ?
Reply With Quote #2

you need to validate the return values...
also, if it doesn't matter what the value is, you can just set it, and it will overwrite the existing one.
Likewise, you can call remove and it will safely remove it even if it's not there.
__________________
Profile - Steam Group - Plugins - Blog - Donate
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-10-2014 , 09:55   Re: [TF2attributes] Grab attributs of a player ?
Reply With Quote #3

Is this on a Windows or Linux server?

It could be that the gamedata in TF2Attributes broke in a recent update (like yesterday's update).

Quote:
Originally Posted by Arkarr View Post
PHP Code:
new result _:TF2Attrib_GetValue(attr); 
Incidentally, that's not how you convert a Float value to an int value... you need RoundFloat or one of the other Round functions for that.
__________________
Am I back? Well, we'll see.

Last edited by Powerlord; 01-10-2014 at 09:59.
Powerlord is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-10-2014 , 10:47   Re: [TF2attributes] Grab attributs of a player ?
Reply With Quote #4

Yeah, doing that will get you an int of something like 91829382193 or something, when you wanted 2

int > float do float(val)
float > int use RoundFloat, RoundToNearest, RoundToCeil, or RoundToFloor
convert anything to boolean just do bool:val
__________________
Profile - Steam Group - Plugins - Blog - Donate
Add me on steam if you are seeking sp/map/model commissions.

Last edited by friagram; 01-10-2014 at 10:48.
friagram is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 01-10-2014 , 11:07   Re: [TF2attributes] Grab attributs of a player ?
Reply With Quote #5

Windows server, I'm trying to save the old to apply it later. I don't know how to validate the value. Fonction for this ?
Exemple :
1) Original "damage bonus" = 10%, I save it somewhere
2) I set to 50% using TF2Attrib_SetByName(client, "damage bonus", 0.50); and start a timer.
3) When timer end, I apply back the original value. (10%) using TF2Attrib_SetByName(client, "damage bonus", OLD_VALUE);

So the correct to do this should be this ?
PHP Code:
//Save old attrbiut value into result, wich is Float
new hClientWeapon GetEntPropEnt(clientProp_Send"m_hActiveWeapon"); 
new 
Address:attr TF2Attrib_GetByName(hClientWeapon"damage bonus"); 
new 
Float:result _:TF2Attrib_GetValue(attr);

//I change the value to 50%:
TF2Attrib_SetByName(client"damage bonus"0.50);

//Timer end, I apply back the original 10% :
TF2Attrib_SetByName(client"damage bonus"result); 
__________________
Want to show support ?
Want to check my plugins ?
Total donation count : 310,98 ChF.- (in 3+ years)

Last edited by Arkarr; 01-10-2014 at 11:08.
Arkarr is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-10-2014 , 11:15   Re: [TF2attributes] Grab attributs of a player ?
Reply With Quote #6

PHP Code:
new Float:result _:TF2Attrib_GetValue(attr); 
Close, but it really should be

PHP Code:
new Float:result TF2Attrib_GetValue(attr); 
__________________
Am I back? Well, we'll see.

Last edited by Powerlord; 01-10-2014 at 11:16.
Powerlord is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 01-10-2014 , 11:18   Re: [TF2attributes] Grab attributs of a player ?
Reply With Quote #7

Thanks, gonna test. And what with this validation of value ?
__________________
Want to show support ?
Want to check my plugins ?
Total donation count : 310,98 ChF.- (in 3+ years)

Last edited by Arkarr; 01-10-2014 at 11:19.
Arkarr is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 01-10-2014 , 11:22   Re: [TF2attributes] Grab attributs of a player ?
Reply With Quote #8

It should be noted that you will not always be able to get "old values" or even stock values from items, as they are not accessable at the moment, and will return as if the item doesn't have them at all (when in fact they do).

You'll always be able to read them however, if they were applied with tf2attributes, or if they are MVM upgrades.
__________________
Profile - Steam Group - Plugins - Blog - Donate
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline
Arkarr
Veteran Member
Join Date: Sep 2012
Location: Just behind my PC screen
Old 01-10-2014 , 11:27   Re: [TF2attributes] Grab attributs of a player ?
Reply With Quote #9

Well, that's why my server crash ? Because when I run the plugin, server immediatly crash, without warnings.

EDIT : Well, you can't grab atttribut on weapon but only on player! That's why my server crash.

So the correct code is :
PHP Code:
//Save old attrbiut value into result, wich is Float
//new hClientWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"); 
new Address:attr TF2Attrib_GetByName(client"damage bonus"); 
new 
Float:result TF2Attrib_GetValue(attr);

//I change the value to 50%:
TF2Attrib_SetByName(client"damage bonus"0.50);

//Timer end, I apply back the original 10% :
TF2Attrib_SetByName(client"damage bonus"result); 
__________________
Want to show support ?
Want to check my plugins ?
Total donation count : 310,98 ChF.- (in 3+ years)

Last edited by Arkarr; 01-11-2014 at 04:15. Reason: fixed.
Arkarr 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 20:27.


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