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

Solved L4D2: When an SI ghost, using z_spawn steals the ghost, how to stop that?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NgBUCKWANGS
Senior Member
Join Date: Dec 2014
Old 12-20-2016 , 08:17   L4D2: When an SI ghost, using z_spawn steals the ghost, how to stop that?
Reply With Quote #1

Hello,

I'm using z_spawn_old to spawn specials but I can't do that while in ghost mode because that would put me into the body of the new special (not in ghost mode). How do I stop that? I'm trying to remain a ghost but use z_spawn to spawn in specials. Any help is appreciated here.

The code I am working with is located here https://forums.alliedmods.net/showthread.php?t=291562 and the main functions behind the logic is line 652 (AddInfected) and line 1202 (State_TransitionSig) if you're curious.

Thank you for your time

Last edited by NgBUCKWANGS; 12-21-2016 at 22:41. Reason: Solved
NgBUCKWANGS is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 12-20-2016 , 09:41   Re: L4D2: When an SI ghost, using z_spawn steals the ghost, how to stop that?
Reply With Quote #2

Does the task you wanted but may change your zombie class:
PHP Code:
public void OnPluginStart()
{
    
RegAdminCmd("sm_z_spawn"SpawnSIADMFLAG_ROOT"Spawns a special infected");
    
// Usage: !z_spawn <SI name> (i.e !z_spawn hunter)
}

public 
Action SpawnSI(int clientint args)
{
    if (
client == || !IsClientInGame(client) || GetClientTeam(client) != 3)
    {
        return 
Plugin_Handled;
    }
    
    
char givenSI[52];
    
GetCmdArgString(givenSIsizeof(givenSI));
    
    
ChangeClientTeam(client1); // avoid survivors team 'cause it unnecessarily spawns an infected survivor bot (invincible and invisible)
    
CommandExecuter(client"z_spawn_old"givenSI"auto");
    
ChangeClientTeam(client3); // go back to the infected team.
    
    
return Plugin_Handled;
}

stock void CommandExecuter(int clientchar[] commandchar[] argument1char[] argument2)
{
    
int flags GetCommandFlags(command);
    
SetCommandFlags(commandflags & ~FCVAR_CHEAT);
    
FakeClientCommand(client"%s %s %s"commandargument1argument2);
    
SetCommandFlags(commandflags|FCVAR_CHEAT);


Last edited by cravenge; 12-20-2016 at 09:44.
cravenge is offline
Timocop
AlliedModders Donor
Join Date: Mar 2013
Location: Germany
Old 12-20-2016 , 12:24   Re: L4D2: When an SI ghost, using z_spawn steals the ghost, how to stop that?
Reply With Quote #3

Changed cravenge's code a bit. Just disable ghost-mode before you spawn special infected and activate after spawn.

PHP Code:
public void OnPluginStart()
{
    
RegAdminCmd("sm_z_spawn_ghost"SpawnSIADMFLAG_ROOT"Spawns a special infected");
    
// Usage: !z_spawn_ghost <SI name> (i.e !z_spawn hunter)
}

public 
Action SpawnSI(int clientint args)
{
    if (
client 1
        
|| !IsClientInGame(client
        || 
GetClientTeam(client) != 
        
|| GetEntProp(clientProp_Send"m_isGhost"1) < 1)
    {
        return 
Plugin_Handled;
    }
    
    
char givenSI[52];
    
GetCmdArgString(givenSIsizeof(givenSI));
    
    
SetEntProp(clientProp_Send"m_isGhost"0);
    
CommandExecuter(client"z_spawn_old"givenSI"auto");
    
SetEntProp(clientProp_Send"m_isGhost"1);
    
    return 
Plugin_Handled;
}

stock void CommandExecuter(int clientchar[] commandchar[] argument1char[] argument2)
{
    
int flags GetCommandFlags(command);
    
SetCommandFlags(commandflags & ~FCVAR_CHEAT);
    
FakeClientCommand(client"%s %s %s"commandargument1argument2);
    
SetCommandFlags(commandflags|FCVAR_CHEAT);

Timocop is offline
NgBUCKWANGS
Senior Member
Join Date: Dec 2014
Old 12-20-2016 , 18:42   Re: L4D2: When an SI ghost, using z_spawn steals the ghost, how to stop that?
Reply With Quote #4

Using the ChangeClientTeam did in fact change my special infected every time a new one spawned in but using the SetEntProp(client, Prop_Send, "m_isGhost", ...) protected it. This was one of those problems I played with every solution I could come up with and come up wrong every time. Damn, I love you guys! Thank you cravenge, thank you Timocop!

You guys rock!
NgBUCKWANGS 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 22:01.


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