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

[HELP] OnGameFrame problem


Post New Thread Reply   
 
Thread Tools Display Modes
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 09-05-2011 , 16:57   Re: [HELP] OnGameFrame problem
Reply With Quote #11

See mjmfighter's post 2 above yours!
__________________
Peace-Maker is offline
zakt4n
Member
Join Date: Jul 2011
Old 09-06-2011 , 12:45   Re: [HELP] OnGameFrame problem
Reply With Quote #12

someone?
zakt4n is offline
BrianGriffin
Senior Member
Join Date: Oct 2008
Old 09-06-2011 , 13:54   Re: [HELP] OnGameFrame problem
Reply With Quote #13

Quote:
Originally Posted by mjmfighter View Post
maybe its because you are not checking to see if that client is in the game or not.

PHP Code:
            team GetClientTeam(i);
            for (new 
x=1;x<=MaxClients;x++)
            {
                if (
IsClientConnected(x) && IsClientInGame(x) && GetClientTeam(x) == team)
                {
                    
pCount++;
                    
toSend[pCount] = x;
                }
            } 
also, you might need to declare pCount = 0; or whatever value u need it to be.
BrianGriffin is offline
zakt4n
Member
Join Date: Jul 2011
Old 09-07-2011 , 12:13   Re: [HELP] OnGameFrame problem
Reply With Quote #14

man, please see the code, i'm checking
Code:
public OnGameFrame()
{
    for (new i=1;i<=MaxClients;i++)
    {
        decl color[4];
        decl toSend[MaxClients];
        decl pCount;
        pCount = 0;
        decl team;
        decl health;
        if (IsClientInGame(i) && IsPlayerAlive(i))
        {
            team = GetClientTeam(i);
            for (new x=1;x<=MaxClients;x++)
            {
                if (GetClientTeam(x) == team)
                {
                    pCount++;
                    toSend[pCount] = x;
                }
            }
            color[3] = 255;
            health = GetClientHealth(i);
            if (health > 99){color[0] = 95;color[1] = 251;color[2] = 0;}
            else if (health < 99 && health > 70){color[0] = 249;color[1] = 149;color[2] = 0;}
            else if (health < 69 && health > 50){color[0] = 228;color[1] = 116;color[2] = 3;}
            else if (health < 49 && health > 20){color[0] = 235;color[1] = 75;color[2] = 0;}
            else if (health < 19 && health > 0){color[0] = 255;color[1] = 0;color[2] = 0;}
            decl Float:origin[3];
            origin[2] += 60;
            GetClientAbsOrigin(i, origin);
            TE_Start("BeamRingPoint");TE_WriteVector("m_vecCenter", origin);TE_WriteFloat("m_flStartRadius", 40.0);TE_WriteFloat("m_flEndRadius", 45.0);TE_WriteNum("m_nModelIndex", lgtning);TE_WriteNum("m_nHaloIndex", lgtning);TE_WriteNum("m_nStartFrame", 0);TE_WriteNum("m_nFrameRate", 100);TE_WriteFloat("m_fLife", 3.0);TE_WriteFloat("m_fWidth", 45.0);TE_WriteFloat("m_fEndWidth", 45.0);TE_WriteFloat("m_fAmplitude", 0.0);TE_WriteNum("r", color[0]);TE_WriteNum("g", color[1]);TE_WriteNum("b", color[2]);TE_WriteNum("a", color[3]);TE_WriteNum("m_nSpeed", 5);TE_WriteNum("m_nFlags",    0);TE_WriteNum("m_nFadeLength", 100);TE_Send(toSend, pCount);
        }
    }
}
zakt4n is offline
BrianGriffin
Senior Member
Join Date: Oct 2008
Old 09-07-2011 , 15:00   Re: [HELP] OnGameFrame problem
Reply With Quote #15

I could just quote my quote of a post again and it would still be correct.

You are not validating x. Read the quote again
BrianGriffin is offline
mjmfighter
Member
Join Date: Jun 2010
Old 09-08-2011 , 00:37   Re: [HELP] OnGameFrame problem
Reply With Quote #16

you need to have the IsClientConnected(x) && IsClientInGame(x) in the if statement. If you dont, and the client isnt connect, it will return an error when you try to check what team he is on.
mjmfighter is offline
zakt4n
Member
Join Date: Jul 2011
Old 09-09-2011 , 14:07   Re: [HELP] OnGameFrame problem
Reply With Quote #17

Code:
public OnGameFrame()
{
    for (new i=1;i<=MaxClients;i++)
    {
        decl color[4];
        decl toSendT[MaxClients];
        decl pCountT;
        pCountT = 0;
        decl toSendCT[MaxClients];
        decl pCountCT;
        pCountCT = 0;
        decl team;
        decl health;
        if (IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i))
        {
            team = GetClientTeam(i);
            if (team == 2)
            {
                pCountT++;
                toSendT[pCountT] = i;
            }
            else if (team == 3)
            {
                pCountCT++;
                toSendCT[pCountCT] = i;
            }
            color[3] = 255;
            health = GetClientHealth(i);
            if (health > 99){color[0] = 95;color[1] = 251;color[2] = 0;}
            else if (health < 99 && health > 70){color[0] = 249;color[1] = 149;color[2] = 0;}
            else if (health < 69 && health > 50){color[0] = 228;color[1] = 116;color[2] = 3;}
            else if (health < 49 && health > 20){color[0] = 235;color[1] = 75;color[2] = 0;}
            else if (health < 19 && health > 0){color[0] = 255;color[1] = 0;color[2] = 0;}
            decl Float:origin[3];
            origin[2] += 60;
            GetClientAbsOrigin(i, origin);
            TE_Start("BeamRingPoint");TE_WriteVector("m_vecCenter", origin);TE_WriteFloat("m_flStartRadius", 40.0);TE_WriteFloat("m_flEndRadius", 45.0);TE_WriteNum("m_nModelIndex", lgtning);TE_WriteNum("m_nHaloIndex", lgtning);TE_WriteNum("m_nStartFrame", 0);TE_WriteNum("m_nFrameRate", 100);TE_WriteFloat("m_fLife", 3.0);TE_WriteFloat("m_fWidth", 45.0);TE_WriteFloat("m_fEndWidth", 45.0);TE_WriteFloat("m_fAmplitude", 0.0);TE_WriteNum("r", color[0]);TE_WriteNum("g", color[1]);TE_WriteNum("b", color[2]);TE_WriteNum("a", color[3]);TE_WriteNum("m_nSpeed", 5);TE_WriteNum("m_nFlags",    0);TE_WriteNum("m_nFadeLength", 100);TE_Send(toSendCT, pCountCT);
            TE_Start("BeamRingPoint");TE_WriteVector("m_vecCenter", origin);TE_WriteFloat("m_flStartRadius", 40.0);TE_WriteFloat("m_flEndRadius", 45.0);TE_WriteNum("m_nModelIndex", lgtning);TE_WriteNum("m_nHaloIndex", lgtning);TE_WriteNum("m_nStartFrame", 0);TE_WriteNum("m_nFrameRate", 100);TE_WriteFloat("m_fLife", 3.0);TE_WriteFloat("m_fWidth", 45.0);TE_WriteFloat("m_fEndWidth", 45.0);TE_WriteFloat("m_fAmplitude", 0.0);TE_WriteNum("r", color[0]);TE_WriteNum("g", color[1]);TE_WriteNum("b", color[2]);TE_WriteNum("a", color[3]);TE_WriteNum("m_nSpeed", 5);TE_WriteNum("m_nFlags",    0);TE_WriteNum("m_nFadeLength", 100);TE_Send(toSendT, pCountT);
        }
    }
}
is giving that error:
Code:
L 09/09/2011 - 15:06:21: [SM] Displaying call stack trace for plugin "rdmpower.smx":
L 09/09/2011 - 15:06:21: [SM]   [0]  Line 225, rdmpower.sp::OnGameFrame()
L 09/09/2011 - 15:06:21: [SM] Native "TE_Send" reported: Client 4 is not connected
zakt4n is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 09-09-2011 , 14:51   Re: [HELP] OnGameFrame problem
Reply With Quote #18

there are so many errors in your code.
there is no point using decl for anything other than arrays.
for the latest error you set pCountT and pCountCT to 0 at the beginning of each loop which means when it comes to storing the players index in toSendT or toSendCT you always store it in the 2nd element since you increment pCountT or pCountCT and leave the 1st one full of garbage since you used decl. then you tell TE_Send that your array contains 1 element even though you used 2 elements.
why use an array for sending the tempent when you send it for each iteration of the loop, either declare the array before the loop then send the tempent after the loop or just use TE_SendToClient and send it to player "i" since which team the player is on makes no difference as you send to same tempent to both team arrays which wouldn't work anyway as you only ever modify 1 array aswell as the issue mentioned earlier.

what exactly are you trying to do?

Last edited by blodia; 09-09-2011 at 14:54.
blodia is offline
zakt4n
Member
Join Date: Jul 2011
Old 09-09-2011 , 15:49   Re: [HELP] OnGameFrame problem
Reply With Quote #19

i'm trying to make a circle effect that shows the friend's "intensity" of life

Example:
I'm in terrorist team, and have another player with me, in his head i can see a green circle cause he have an greate amount of life.

Can u fix the errors for me?
zakt4n is offline
blodia
Veteran Member
Join Date: Sep 2009
Location: UK
Old 09-09-2011 , 16:04   Re: [HELP] OnGameFrame problem
Reply With Quote #20

by friend do you mean team mate?
blodia 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 04:37.


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