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

Check if player can see respawn / buying zone


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sebxx4
Senior Member
Join Date: Feb 2013
Old 12-29-2022 , 02:35   Check if player can see respawn / buying zone
Reply With Quote #1

Hello, I have a problem. I need to check if player can see other team's respawn zone. Not if he's currently looking in this direction, but if there's some obstacle (wall, box, anything) on the way from his position to opponents team's respawn (or buying zone, imo it's the same). Any ideas, please?

Last edited by sebxx4; 12-29-2022 at 02:35.
sebxx4 is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 12-30-2022 , 17:06   Re: Check if player can see respawn / buying zone
Reply With Quote #2

Possibly if you could elaborate as to how this happened please.
__________________
DJEarthQuake is offline
sebxx4
Senior Member
Join Date: Feb 2013
Old 12-30-2022 , 23:38   Re: Check if player can see respawn / buying zone
Reply With Quote #3

What do you mean?
sebxx4 is offline
sebxx4
Senior Member
Join Date: Feb 2013
Old 01-03-2023 , 01:08   Re: Check if player can see respawn / buying zone
Reply With Quote #4

Anybody?
sebxx4 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-03-2023 , 16:48   Re: Check if player can see respawn / buying zone
Reply With Quote #5

there's no such thing called a respawn zone, you need to rethink of something else to achieve what you want...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
sebxx4
Senior Member
Join Date: Feb 2013
Old 01-03-2023 , 17:06   Re: Check if player can see respawn / buying zone
Reply With Quote #6

Well, I can get positions of players when they're respawned. Or maybe position of buying zone? In many maps it's equal to respawn zone.
sebxx4 is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-03-2023 , 18:40   Re: Check if player can see respawn / buying zone
Reply With Quote #7

Quote:
Originally Posted by sebxx4 View Post
Well, I can get positions of players when they're respawned. Or maybe position of buying zone? In many maps it's equal to respawn zone.
as i thought most of the time there's no buyzone while its been checked like that.

PHP Code:
void OLD_CheckBuyZone(CBasePlayer *pPlayer)
{
    const 
char *pszSpawnClass nullptr;

#ifdef REGAMEDLL_FIXES
    
if (!CSGameRules()->CanPlayerBuy(pPlayer))
    {
        return;
    }
#endif

    
if (pPlayer->m_iTeam == TERRORIST)
    {
        
pszSpawnClass "info_player_deathmatch";
    }
    else if (
pPlayer->m_iTeam == CT)
    {
        
pszSpawnClass "info_player_start";
    }

    if (
pszSpawnClass)
    {
        
CBaseEntity *pSpot nullptr;
        while ((
pSpot UTIL_FindEntityByClassname(pSpotpszSpawnClass)))
        {
            if ((
pSpot->pev->origin pPlayer->pev->origin).Length() < 200.0f)
            {
                
pPlayer->m_signals.Signal(SIGNAL_BUY);
#ifdef REGAMEDLL_FIXES
                
break;
#endif
            
}
        }
    }

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

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-03-2023 , 22:42   Re: Check if player can see respawn / buying zone
Reply With Quote #8

Hook player spawn and store the first spawned players origin. You can then do a traceline from player to this location to look for obstacles.
__________________
Bugsy is offline
sebxx4
Senior Member
Join Date: Feb 2013
Old 01-04-2023 , 04:47   Re: Check if player can see respawn / buying zone
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
Hook player spawn and store the first spawned players origin. You can then do a traceline from player to this location to look for obstacles.
Yes, that's what I was thinking about. But don't know how to do this.
sebxx4 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-04-2023 , 12:39   Re: Check if player can see respawn / buying zone
Reply With Quote #10

Here's something you can start with. Only gap is for the first player(s) spawned on one team when server started/map changed as the enemy teams spawn location will be unknown. Another option that can be used is using buyzone locations.

See below example

Spawn order:
1. T player (CT origin unknown, unable to check line of sight)
2. T player (CT origin unknown, unable to check line of sight)
3. CT player (good)
4. CT player (good)
5. T player (good)

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>

new const Version[] = "0.1";

new 
Float:g_fTeamOriginCsTeams ][ ];

public 
plugin_init() 
{
    
register_plugin"Check for Path" Version "bugsy" );
    
    
RegisterHamHam_Spawn "player" "HamSpawnPlayer_Post" true );
}

public 
HamSpawnPlayer_PostiPlayer )
{
    if ( 
is_user_aliveiPlayer ) )
    {
        new 
tlTrace Float:fFraction CsTeams:csTeam cs_get_user_teamiPlayer ) , CsTeams:csEnemyTeam;
        
        
//Store origin for players team if not yet recorded
        
if ( !g_fTeamOrigincsTeam ][ ] )
            
peviPlayer pev_origin g_fTeamOrigincsTeam ] );
            
        
//Determine enemies team
        
csEnemyTeam = ( csTeam == CS_TEAM_T ) ? CS_TEAM_CT CS_TEAM_T;
        
        
//If an origin was record for enemies team
        
if ( g_fTeamOrigincsEnemyTeam ][ ] )
        {
            
//Send traceline from players team spawn location to enemy teams spawn location
            
engfuncEngFunc_TraceLine g_fTeamOrigincsTeam ] , g_fTeamOrigincsEnemyTeam ] , IGNORE_MONSTERS tlTrace );
            
get_tr2tlTrace TR_flFraction fFraction );
            
            
//Trace ran into something so there is not a clear path
            
if ( fFraction != 1.0 )
            {
                
client_printiPlayer print_chat "Something is in the way" );
            }
            else
            {
                
client_printiPlayer print_chat "There's a clear path to the enemy's spawn location" );    
            }
        }
    }

__________________

Last edited by Bugsy; 01-04-2023 at 12:46.
Bugsy 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 05:59.


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