AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   Using invisible for spawn protection. (https://forums.alliedmods.net/showthread.php?t=333680)

Austin 07-28-2021 17:54

Using invisible for spawn protection.
 
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?

Ilusion9 07-30-2021 05:54

Re: Using invisible for spawn protection.
 
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.

Austin 07-30-2021 06:28

Re: Using invisible for spawn protection.
 
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;



Bacardi 07-30-2021 07:04

Re: Using invisible for spawn protection.
 
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)

Austin 07-30-2021 07:47

Re: Using invisible for spawn protection.
 
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?

Marttt 07-30-2021 07:59

Re: Using invisible for spawn protection.
 
SetTransmit only prevents the model to be drawn to the client, collision and AI still works on the hidden client.

Austin 07-30-2021 16:58

Re: Using invisible for spawn protection.
 
Marttt
thanks for the info,
that explains it.
this method can't be used to hide from bots......

Austin 07-31-2021 05:02

Re: Using invisible for spawn protection.
 
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?


All times are GMT -4. The time now is 17:56.

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