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

Using invisible for spawn protection.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Austin
Senior Member
Join Date: Oct 2005
Old 07-28-2021 , 17:54   Using invisible for spawn protection.
Reply With Quote #1

I am working on a spawn protection plugin that makes the player invisible for the protection period.
This seems like a much better way to handle it instead of letting the player take damage but then ignore the damage.

I found this plugin in and with just a few lines it hides all players from a single player and it works great but, I need to do the opposite, hide a single player from all players.
https://forums.alliedmods.net/showthread.php?t=236806

Does anyone have a suggestion on how to modify it to work this way?
Austin is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 07-30-2021 , 05:54   Re: Using invisible for spawn protection.
Reply With Quote #2

PHP Code:

public void OnClientPutInServer(int client)
{
    
SDKHook(clientSDKHook_SetTransmitSDK_OnSetTransmit);
}

public 
Action SDK_OnSetTransmit(int entityint client
{
    if (
client != entity 
        
&& IsEntityClient(entity
        && 
IsClientInGame(entity
        && 
IsPlayerAlive(entity)
        && 
HasSpawnProtection(entity))
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;
}

bool HasSpawnProtection(int client)
{


Players can still hear sounds made by hidden players.
__________________
Ilusion9 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 07-30-2021 , 06:28   Re: Using invisible for spawn protection.
Reply With Quote #3

What is this function?
IsEntityClient(entity)

Here is what I have and it doesn't work.
I am on an all bot server and trying to hide from bots as testing.
Does this work for hiding from bots?
Thanks!

PHP Code:
#include <cstrike>
#include <sdkhooks>

new bool:b_Hide[MAXPLAYERS+1]; 

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_hide"Z_Hide); 
    for(
int i 1<= MAXPLAYERSi++)
        
b_Hide[i] = false;
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_SetTransmitSDK_OnSetTransmit); 
}

public 
Action SDK_OnSetTransmit(int entityint client
{
    if (
client != entity
        
&&  (entity <= MaxClients)  
        && 
IsClientInGame(entity
        && 
IsPlayerAlive(entity)
        && 
HasSpawnProtection(entity))
    {
        
PrintToChatAll(" \x04* \x12%d"entity);        
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;
}   

bool HasSpawnProtection(int client)
{
    return 
b_Hide[client]
}

public 
Action:Z_Hide(clientargs)
{
    if (!
b_Hide[client])
    {
        
b_Hide[client] = true;
        
PrintToChatAll(" \x04* \x07Hide On \x12%d"client);
    }
    else
    {
        
b_Hide[client] = false;
        
PrintToChatAll(" \x04* \x07Hide Off \x12%d"client);
    }
    return 
Plugin_Handled;


Last edited by Austin; 07-30-2021 at 07:53.
Austin is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 07-30-2021 , 07:04   Re: Using invisible for spawn protection.
Reply With Quote #4

To check, is it player index, look entity indexs range 1 to MaxClients.
0 is console or error.
Entity index > MaxClients are rest things.

After confirm it is valid player index, to check, is player using player index: IsClientInGame(index)
__________________
Do not Private Message @me
Bacardi is offline
Austin
Senior Member
Join Date: Oct 2005
Old 07-30-2021 , 07:47   Re: Using invisible for spawn protection.
Reply With Quote #5

Bacardi,
Right!
Got it!
Thanks.

I modified my plugin (and my example above) by adding this
(0 < entity <= MaxClients)

But still no joy.
When I spawn into my bot server I don't move or buy anthing so I make no noise, I turn on the portection but the bots still see me.

I know the if statment is working.
Since I am the first player on the server I get client index of 1 and my logging is showing after I turn on protection it starts printing * 1s

Maybe this method doesn't work with bots?

Last edited by Austin; 07-30-2021 at 07:56.
Austin is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 07-30-2021 , 07:59   Re: Using invisible for spawn protection.
Reply With Quote #6

SetTransmit only prevents the model to be drawn to the client, collision and AI still works on the hidden client.
__________________
Marttt is offline
Austin
Senior Member
Join Date: Oct 2005
Old 07-30-2021 , 16:58   Re: Using invisible for spawn protection.
Reply With Quote #7

Marttt
thanks for the info,
that explains it.
this method can't be used to hide from bots......

Last edited by Austin; 07-30-2021 at 18:59.
Austin is offline
Austin
Senior Member
Join Date: Oct 2005
Old 07-31-2021 , 05:02   Re: Using invisible for spawn protection.
Reply With Quote #8

I am running bot servers so I am really only interested in hiding players for a short time from bots after spawning into a random location.

I have been thinking about this and would really like to get “invisible” spawn protection going since it is far better than ignoring damage taken and just realized players are “invisible” to bots in two situations.
1) When they are flashed
2) When the player is covered in smoke.

What functionality in the Source engine provides these features and can we hack them into getting something at least close to what we want?

It would be cool if we could trick the bots into thinking we are covered in smoke when we are not!
And again since this is spawn protection it only has to work for a shot time around a player not moving.

A really cheap way to do it would be to ignite smoke around the player 2-3 times to last the duration of the protection but I would prefer to avoid the smoke effect and just have the bot go by ignoring the human player thinking there is smoke there or whatever effect we can use to get this done.

The smoke effect seems to be the perfect choice since it is about the right size around the player and lasts for only a short while.

Invisible smoke is what we need!

Any advanced codes have any ideas?

Last edited by Austin; 07-31-2021 at 05:06.
Austin 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 14:10.


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