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

How to respawn a dead FakeClient?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
UeberDaniel
AlliedModders Donor
Join Date: Dec 2009
Location: Germany
Old 01-03-2020 , 19:59   How to respawn a dead FakeClient?
Reply With Quote #1

Hi, im working on a Plugin for a Deathmatch mode for the game contagion.
To block the round from ending @ low playercount i will use Bots(i will use Hunted as gammode = last man Standing).

Now i got them joining but when they die, they are not respawning on the map. The Event gets triggered because all Players will respawn as Spectator or Zombie. In the respawnSurvivorInit(), the client Team is set to survivors, and the Client get some weapons. After this the Players are respawning on the map, the bot not.

So i kicked the bots and added them again.

Here is my Code for the Playerspawn Event:

PHP Code:
public Event_PlayerSpawnHandle:event, const String:szEventName[], bool:bDontBroadcast ) {
    
//Players
    
new client GetClientOfUserId(GetEventInt(event"userid"));
    if ((
client <= MaxClients ) && !IsFakeClient(client)) {
        
respawnSurvivorInit(client);

        
cleanAmmo();
        }
        
//BOT
    
if ((client <= MaxClients ) && IsFakeClient(client) && (GetClientTeam(client) != PLAYER_SURVIVOR_ID)) {
        
KickClient(client);
        
RemoveEntity(client);
        
int client2 CreateFakeClient("Dont let me Win");
        
respawnSurvivorInit(client2);
        
DispatchSpawn(client2);
        
SetEntityModel(client2"models/player/cockroach.mdl");
        
SetEntData(client2FindDataMapInfo(client2"m_iHealth"), 400004true);
        }


Is there a more elegant way to respawn the bot?

Greetings
__________________


Last edited by UeberDaniel; 01-03-2020 at 20:10.
UeberDaniel is offline
Send a message via MSN to UeberDaniel
UeberDaniel
AlliedModders Donor
Join Date: Dec 2009
Location: Germany
Old 01-04-2020 , 07:56   Re: How to respawn a dead FakeClient?
Reply With Quote #2

Got it working now:
PHP Code:
public Event_PlayerSpawnHandle:event, const String:szEventName[], bool:bDontBroadcast ) {
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
//Spawn dead Players as Survivors
    
if ((client <= MaxClients ) && !IsFakeClient(client)) {
        
respawnSurvivorInit(client);

        
cleanAmmo();
        }

    if (
botCount != 1){ //First bot spawns with first player:
        
botCount++;
        
int bot CreateFakeClient("Dont let me Win");
        
DispatchSpawn(bot);
        
ChangeClientTeam(botPLAYER_SURVIVOR_ID);
        
SetEntData(botFindDataMapInfo(bot"m_iHealth"), 1004true);
        
SetEntityModel(bot"models/player/cockroach.mdl");
    }
        
//respawn dead Bot
    
if ((client <= MaxClients ) && IsFakeClient(client) && (GetClientTeam(client) != PLAYER_SURVIVOR_ID)) {
        
ChangeClientTeam(clientPLAYER_SURVIVOR_ID);
        
SetEntityModel(client"models/player/cockroach.mdl");
        
SetEntData(clientFindDataMapInfo(client"m_iHealth"), 1004true);
        }

__________________

UeberDaniel is offline
Send a message via MSN to UeberDaniel
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 18:29.


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