Raised This Month: $ Target: $400
 0% 

[TF2] return function; (new syntax)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StormishJustice
Member
Join Date: May 2015
Location: In a mysterious place.
Old 04-19-2016 , 19:13   [TF2] return function; (new syntax)
Reply With Quote #1

Hi there, so i was converting (red2robot) to the new syntax and i decided to add #pragma newdecl required; in

problem is, i always keep getting warnings on stuff like "return X;", and i have no idea why, i just added return; on createparticle but for getclassmaxhealth? i just made it return; without anything after it and now it tells me that X (which is health) as symbol that is never used, i might not know more about the new syntax, tho that's what's bugging me, any help can be appreciated as long it's correct.
__________________
StormishJustice is offline
Send a message via AIM to StormishJustice Send a message via Yahoo to StormishJustice Send a message via Skype™ to StormishJustice
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 04-19-2016 , 19:15   Re: [TF2] return function; (new syntax)
Reply With Quote #2

We're going to need to see some code to tell you what's wrong with it.
__________________

Last edited by ddhoward; 04-19-2016 at 19:15.
ddhoward is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 04-20-2016 , 01:26   Re: [TF2] return function; (new syntax)
Reply With Quote #3

I'm not certain but I think not putting a type before the function will make it an int type. If you don't need to return anything, set it as void. But like ddhoward said, you should post your code.
Phil25 is offline
StormishJustice
Member
Join Date: May 2015
Location: In a mysterious place.
Old 04-20-2016 , 06:47   Re: [TF2] return function; (new syntax)
Reply With Quote #4

Quote:
Originally Posted by Phil25 View Post
I'm not certain but I think not putting a type before the function will make it an int type. If you don't need to return anything, set it as void. But like ddhoward said, you should post your code.
Code:
void GetClassMaxHealth(int client)
{
    TFClassType class = TF2_GetPlayerClass(client);
    int Health;
    switch(class)
    {
        case TFClass_Scout: Health = 125;
        case TFClass_Soldier: Health = 200;
        case TFClass_Pyro: Health = 175;
        case TFClass_DemoMan: Health = 175;
        case TFClass_Heavy: Health = 300;
        case TFClass_Engineer: Health = 125;
        case TFClass_Medic: Health = 150;
        case TFClass_Sniper: Health = 125;
        case TFClass_Spy: Health = 125;
    }
    return Health;
}
This is just added into the new syntax (1.7), so don't try to use anything from the old syntax.
__________________
StormishJustice is offline
Send a message via AIM to StormishJustice Send a message via Yahoo to StormishJustice Send a message via Skype™ to StormishJustice
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 04-20-2016 , 07:12   Re: [TF2] return function; (new syntax)
Reply With Quote #5

For this to work you should change "void" to "int". But what you're trying to achieve could be done with reading the max health netprop of the player entity. I advise you to do that as max health could change depending on the loadout.

Last edited by Phil25; 04-20-2016 at 07:13.
Phil25 is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 04-20-2016 , 07:44   Re: [TF2] return function; (new syntax)
Reply With Quote #6

Quote:
Originally Posted by Phil25 View Post
For this to work you should change "void" to "int". But what you're trying to achieve could be done with reading the max health netprop of the player entity. I advise you to do that as max health could change depending on the loadout.
Totaly agree with Phil, if you add void to your function it makes it return nothing, so it's useless, you are actually trying to return a integrer so replace void with the right thing.
__________________
Benoist3012 is offline
StormishJustice
Member
Join Date: May 2015
Location: In a mysterious place.
Old 04-20-2016 , 08:58   Re: [TF2] return function; (new syntax)
Reply With Quote #7

Quote:
Originally Posted by Benoist3012 View Post
Totaly agree with Phil, if you add void to your function it makes it return nothing, so it's useless, you are actually trying to return a integrer so replace void with the right thing.
Oh, then that's why it told me there's a warning..

well thanks anyway, that actually helped!
__________________
StormishJustice is offline
Send a message via AIM to StormishJustice Send a message via Yahoo to StormishJustice Send a message via Skype™ to StormishJustice
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 04-20-2016 , 09:33   Re: [TF2] return function; (new syntax)
Reply With Quote #8

Just a follow up on what I've said before:
PHP Code:
GetEntProp(clientProp_Data"m_iMaxHealth"); 
This returns the true value of client's max health. It respects classes and applied attributes.
Phil25 is offline
Naydef
Senior Member
Join Date: Dec 2015
Location: Doom Town, Nevada
Old 04-20-2016 , 11:32   Re: [TF2] return function; (new syntax)
Reply With Quote #9

Quote:
Originally Posted by Phil25 View Post
Just a follow up on what I've said before:
PHP Code:
GetEntProp(clientProp_Data"m_iMaxHealth"); 
This returns the true value of client's max health. It respects classes and applied attributes.
Incorrect. This doesn't count attributes. Use this(got from FF2):
PHP Code:
GetEntProp(GetPlayerResourceEntity(), Prop_Send"m_iMaxHealth"_client); 
__________________
My plugins:
*None for now*


Steam:
naydef
Naydef is offline
StormishJustice
Member
Join Date: May 2015
Location: In a mysterious place.
Old 04-21-2016 , 17:50   Re: [TF2] return function; (new syntax)
Reply With Quote #10

Quote:
Originally Posted by Naydef View Post
Incorrect. This doesn't count attributes. Use this(got from FF2):
PHP Code:
GetEntProp(GetPlayerResourceEntity(), Prop_Send"m_iMaxHealth"_client); 
Are you sure? because i used that for the giant robot health and it kinda resets when respawning (even the normal m_iMaxHealth getentprop did the same thing)

Edit: i just realized that resets the health to the actual health the player had (damnit)
__________________

Last edited by StormishJustice; 04-21-2016 at 18:29.
StormishJustice is offline
Send a message via AIM to StormishJustice Send a message via Yahoo to StormishJustice Send a message via Skype™ to StormishJustice
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 16:14.


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