AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [TF2] return function; (new syntax) (https://forums.alliedmods.net/showthread.php?t=281757)

StormishJustice 04-19-2016 19:13

[TF2] return function; (new syntax)
 
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.

ddhoward 04-19-2016 19:15

Re: [TF2] return function; (new syntax)
 
We're going to need to see some code to tell you what's wrong with it.

Phil25 04-20-2016 01:26

Re: [TF2] return function; (new syntax)
 
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.

StormishJustice 04-20-2016 06:47

Re: [TF2] return function; (new syntax)
 
Quote:

Originally Posted by Phil25 (Post 2412548)
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. :nono:

Phil25 04-20-2016 07:12

Re: [TF2] return function; (new syntax)
 
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.

Benoist3012 04-20-2016 07:44

Re: [TF2] return function; (new syntax)
 
Quote:

Originally Posted by Phil25 (Post 2412586)
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.

StormishJustice 04-20-2016 08:58

Re: [TF2] return function; (new syntax)
 
Quote:

Originally Posted by Benoist3012 (Post 2412588)
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! :up:

Phil25 04-20-2016 09:33

Re: [TF2] return function; (new syntax)
 
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.

Naydef 04-20-2016 11:32

Re: [TF2] return function; (new syntax)
 
Quote:

Originally Posted by Phil25 (Post 2412617)
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); 


StormishJustice 04-21-2016 17:50

Re: [TF2] return function; (new syntax)
 
Quote:

Originally Posted by Naydef (Post 2412645)
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)


All times are GMT -4. The time now is 05:15.

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