AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   FM_AddToFullPack player invisible (and SOLID) for certain player (https://forums.alliedmods.net/showthread.php?t=335647)

joseph9 12-21-2021 05:19

FM_AddToFullPack player invisible (and SOLID) for certain player
 
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 :D

@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!

Natsheh 12-21-2021 11:07

Re: FM_AddToFullPack player invisible for certain player
 
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

CrazY. 12-21-2021 12:23

Re: FM_AddToFullPack player invisible for certain player
 
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.

joseph9 12-26-2021 13:24

Re: FM_AddToFullPack player invisible for certain player
 
Quote:

Originally Posted by Natsheh (Post 2766624)
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. (Post 2766628)
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 :stupid:

So I've stuck here.

CrazY. 12-26-2021 16:00

Re: FM_AddToFullPack player invisible (and SOLID) for certain player
 
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() }

Natsheh 12-26-2021 16:08

Re: FM_AddToFullPack player invisible (and SOLID) for certain player
 
Quote:

Originally Posted by joseph9 (Post 2766974)

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) ];



joseph9 01-02-2022 05:21

Re: FM_AddToFullPack player invisible (and SOLID) for certain player
 
Much thanks to you guys but how exacly can I achieve SOLID_SLIDEBOX for each pair so they are SOLID_NOT for other pairs?

CrazY. 01-02-2022 07:32

Re: FM_AddToFullPack player invisible (and SOLID) for certain player
 
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


All times are GMT -4. The time now is 11:29.

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