Raised This Month: $ Target: $400
 0% 

FM_AddToFullPack player invisible (and SOLID) for certain player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joseph9
Junior Member
Join Date: Nov 2016
Location: Poland
Old 12-21-2021 , 05:19   FM_AddToFullPack player invisible (and SOLID) for certain player
Reply With Quote #1

Hello, I need some help with it (if it's even possible)

Lets say I have 16 players per team. I would like each pair (taken by index) to see themselfes.

PHP Code:
new teamOne[16], teamTwo[16]

public 
plugin_init() {
  
RegisterHam(Ham_Spawn"player""Ham_PlayerSpawn"1)
  
register_forward(FM_AddToFullPack"client_AddToFullPack_P"1)
}

public 
Ham_PlayerSpawn(id) {
  if(
is_user_alive(id)) {
    
set_user_rendering(idkRenderFxNone000kRenderTransAlpha0)
  }
}

public 
client_AddToFullPack_P(eseentidhostflagsplayerpSet) {
  if(
player && id != ent && is_user_alive(id)) {
    if(
teamOne[ent] && teamTwo[id]) {
      
set_es(esES_RenderModekRenderNormal)
      
set_es(esES_RenderAmt1.0)
    }
    return 
FMRES_IGNORED;
  }
  return 
FMRES_IGNORED;

Much thanks for any help because I'm confused about this function

@EDIT

Ok. I've made some changes to this code and added for loop inside (i think it's overkill for AddToFullPack, lol) and it's checking if teamOne is equal to id and teamTwo is equal to ent and vice-versa. If you have better ideas, please let me know!

Last edited by joseph9; 12-26-2021 at 14:25. Reason: I've made little progress..
joseph9 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-21-2021 , 11:07   Re: FM_AddToFullPack player invisible for certain player
Reply With Quote #2

So you want to show people who are in the same team to each other?


You can create a global players variable that holds player team id
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-21-2021 at 11:15.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
joseph9
Junior Member
Join Date: Nov 2016
Location: Poland
Old 12-26-2021 , 13:24   Re: FM_AddToFullPack player invisible for certain player
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
So you want to show people who are in the same team to each other?
You can create a global players variable that holds player team id
Yes, I store players in teamOne and teamTwo that are sorted by frags and then I use it to make a pair.

Quote:
Originally Posted by CrazY. View Post
What is wrong with the code you provided?
You shouldn't do any loop or anything expensive in addToFullPack.
My goal is to make each player got his own opponent and the rest is non-solid; transparent for them.

I use SOLID_NOT to prevent colliding and set render mode to make them transparent then I use SOLID_SLIDEBOX to activate collision for that pair but it applies to everyone not for the pair like in render mode so everyone is stuck and able to kill everyone

So I've stuck here.
joseph9 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-21-2021 , 12:23   Re: FM_AddToFullPack player invisible for certain player
Reply With Quote #4

What is wrong with the code you provided?

Quote:
Ok. I've made some changes to this code and added for loop inside (i think it's overkill for AddToFullPack, lol)
You shouldn't do any loop or anything expensive in addToFullPack.
__________________









Last edited by CrazY.; 12-21-2021 at 12:24.
CrazY. is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 12-26-2021 , 16:00   Re: FM_AddToFullPack player invisible (and SOLID) for certain player
Reply With Quote #5

Use an array of bits to determine which player one can see.

Code:
#define SetPlayerBit(%1,%2)     (%1 |= (1<<(%2&31))) #define ClearPlayerBit(%1,%2)   (%1 &= ~(1 <<(%2&31))) #define CheckPlayerBit(%1,%2)   (%1 & (1<<(%2&31))) new g_visiblePlayers[33] // Return whether target is set as visible to player IsPlayerVisible(player, target) {     return CheckPlayerBit(g_visiblePlayers[player], target) ? true : false } // Make target visible to player MakePlayerVisible(player, target) {     SetPlayerBit(g_visiblePlayers[player], target); } // Make target invisible to player MakePlayerInvisible(player, target) {     ClearPlayerBit(g_visiblePlayers[player], target); }

Your would do something like this

Code:
public client_AddToFullPack_P(es, e, ent, id, hostflags, player, pSet)
{
	if (player && (1 <= ent <= MaxClients) && !IsPlayerVisible(id, ent))
	{
		set_es(es, ES_Effects, EF_NODRAW)
	}
}
MaxClients may be replaced with a global variable holding the number of max players

Code:
new g_maxPlayers public plugin_init() {     g_maxPlayers = get_maxplayers() }
__________________








CrazY. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 12-26-2021 , 16:08   Re: FM_AddToFullPack player invisible (and SOLID) for certain player
Reply With Quote #6

Quote:
Originally Posted by joseph9 View Post

My goal is to make each player got his own opponent and the rest is non-solid; transparent for them.


So I've stuck here.

what if you have an odd number of players ?


You could create a player variable holds each player opponent for example

PHP Code:

new g_user_opponent[MAX_PLAYERS+1]

assign_opponent(id)
{
   new 
players[32], pnum;
   
get_players(players"he"get_user_team(id) == TEAM_CT "TERRORIST":"CT");

   for(new 
ipnumi++)
   {
       if(
g_user_opponentplayers] ]) playersi-- ] = players [ --pnum ];
    }
    
// There're no available opponents or no enemies.
   
if(!pnum) return;

   
g_user_opponentid ] = players random(pnum) ];

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 12-26-2021 at 16:14.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
joseph9
Junior Member
Join Date: Nov 2016
Location: Poland
Old 01-02-2022 , 05:21   Re: FM_AddToFullPack player invisible (and SOLID) for certain player
Reply With Quote #7

Much thanks to you guys but how exacly can I achieve SOLID_SLIDEBOX for each pair so they are SOLID_NOT for other pairs?
joseph9 is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-02-2022 , 07:32   Re: FM_AddToFullPack player invisible (and SOLID) for certain player
Reply With Quote #8

Just like you do with semiclip, but instead of checking people team, you'll check if the player is visible.

https://forums.alliedmods.net/showthread.php?t=69728
__________________








CrazY. 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 11:29.


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