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

Assign to an entity a team.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-03-2017 , 05:57   Assign to an entity a team.
Reply With Quote #1

I'm trying to assing a entity to a team, the goal is the next: in my heart heart entity when you kill somebody a red heart enttiy is spawned, if you touch it you get+1 lifes, i want to make to only users from the same team with the 'victim' can touch the heart.

Example if i'm a tero and i die, only terrorists can take that heart. also to render the entity based on the team .. rendering is working fine bun i can't assing to a entity a team, idk why , here's the code:

Declaration:
PHP Code:
// i will ad in g_pdData[] but for the moment leave it separatly until somebody figure out why is not working 
// i use 33 the size because anyway can exist in a round as much entites as much players die  . so i think is enough 33
new EntTeamIdMax_Players ]; 
Assigning the value of the victim team ( i try in a looooot of ways, is just simple not working ):
PHP Code:
    switch( EntTeamIdiEnt ] = get_user_teamiV ) )
    {
        case 
1:
        {
            
set_renderingiEntkRenderFxGlowShell25500kRenderTransAlpha20 );
        }
        case 
2:
        {
            
set_renderingiEntkRenderFxGlowShell00255kRenderTransAlpha20 );
        }

        default:
        {
            
set_renderingiEntkRenderFxGlowShell02550kRenderTransAlpha20 );
        }
    } 
I try also like that but is not working:
PHP Code:
    switch( get_user_teamiV ) )
    {
        case 
1:
        {
            
EntTeamIdiEnt ] = 1;
            
set_renderingiEntkRenderFxGlowShell25500kRenderTransAlpha20 );
        }
        case 
2:
        {
            
EntTeamIdiEnt ] = 2;
            
set_renderingiEntkRenderFxGlowShell00255kRenderTransAlpha20 );
        }

        default:
        {
            
EntTeamIdiEnt ] = 0;
            
set_renderingiEntkRenderFxGlowShell02550kRenderTransAlpha20 );
        }
    } 
And also the comparation in touch event:
PHP Code:
if( equalszClassnamegHealthEntity) && get_user_teamid ) == EntTeamIdiEnt ] )
        {
            
g_pdDataid ] [ iLives ]++;
        
        
set_hudmessage(20810200.090.7506.02.0);
        
show_hudmessageid"+1 lives" );
    
            
engfuncEngFunc_RemoveEntityiEnt );

    } 
The whole code:
Spoiler
__________________
Project: Among Us

Last edited by Craxor; 01-03-2017 at 06:01.
Craxor is offline
Send a message via ICQ to Craxor
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-03-2017 , 06:31   Re: Assign to an entity a team.
Reply With Quote #2

What i would try:

1) When the victim drops the heart, assign the victim to a an array something like
PHP Code:
 new player[33]; player[id] = id 
2) If a player wants to pick up the heart, check if get_user_team(player[id]) == get_user_team(playerpickingupheart[id]) and handle on this outcome?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-03-2017 , 06:48   Re: Assign to an entity a team.
Reply With Quote #3

won't work, just if i want to pickup my own entity, the problem itself is with assignment, why is not working i don't understand ..
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-03-2017 , 07:39   Re: Assign to an entity a team.
Reply With Quote #4

Just set pev_team on that entity and check it when a player touches it.
klippy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-03-2017 , 08:28   Re: Assign to an entity a team.
Reply With Quote #5

Quote:
Originally Posted by KliPPy View Post
Just set pev_team on that entity and check it when a player touches it.
It has no effect.

In death msg:
PHP Code:
    new cTeam peviV pev_team );
    
set_peviEnt pev_team cTeam ); 
In touch_forward:
PHP Code:
        if( equalszClassnamegHealthEntity) && pevidpev_team ) == peviEntpev_team ) ) 
__________________
Project: Among Us

Last edited by Craxor; 01-03-2017 at 08:58.
Craxor is offline
Send a message via ICQ to Craxor
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-03-2017 , 09:03   Re: Assign to an entity a team.
Reply With Quote #6

It does. If you set entity's pev_team to some value it will remain that way unless some other code changes it (like the game itself, which is unlikely for info_target entities). Just as for any other pev_ value. Even Lasermine plugin uses it to determine lasermine entity's team if I remember correctly.
klippy is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-03-2017 , 09:08   Re: Assign to an entity a team.
Reply With Quote #7

Quote:
Originally Posted by KliPPy View Post
It does. If you set entity's pev_team to some value it will remain that way unless some other code changes it (like the game itself, which is unlikely for info_target entities). Just as for any other pev_ value. Even Lasermine plugin uses it to determine lasermine entity's team if I remember correctly.
So what i done wrong above ?
However i'm also curious 'why' my first code wasn't working ?
__________________
Project: Among Us

Last edited by Craxor; 01-03-2017 at 09:10.
Craxor is offline
Send a message via ICQ to Craxor
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-03-2017 , 09:31   Re: Assign to an entity a team.
Reply With Quote #8

I don't know, I don't like that entity array either way. Try with pev_team and post your code if you can't get it working.
klippy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-03-2017 , 10:02   Re: Assign to an entity a team.
Reply With Quote #9

Quote:
However i'm also curious 'why' my first code wasn't working ?
Just because you can make such arrays for players, does not mean you can make it for other entities too.

Let me explain:
PHP Code:
new EntTeamIdMax_Players ]; 
This array has valid indexes from 0 to 32(however, for players you will only use the 1 - 32 indexes). You should know by now that the first 32 indexes are always reserved for players. In other words, from 1 to maxplayers there are always players. After MAX_PLAYERS, the other entities indexes start. Given that your "iEnt" is a custom entity it's guaranteed that it's index will be bigger than 32, so there is no way to do EntTeamId[iEnt].
Check your error logs, this code will produce an index out of bounds.

What Klippy said is correct and should work. Anyway, you can use other unused fields like pev_iuser1.
__________________

Last edited by HamletEagle; 01-03-2017 at 10:03.
HamletEagle is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-03-2017 , 13:15   Re: Assign to an entity a team.
Reply With Quote #10

klippy in the example i show i removed the EntTeam array, i just use set_pev as directly with the entity and no effect.

Hamlet, thanks, i didn't know, looks resoursfull
__________________
Project: Among Us
Craxor is offline
Send a message via ICQ to Craxor
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 20:21.


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