Raised This Month: $32 Target: $400
 8% 

Block player respawn in CS:S


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 03-28-2009 , 05:03   Block player respawn in CS:S
Reply With Quote #1

Hello, sorry for my bad english
In a while ago I found a way of how to block player respawn. It can be done by using a CS_SwitchTeam function on a spectator. To give player ability to respawn back CS_RespawnPlayer is only needed. I wrote a little test code that will block respawn when client is just joined a team and will spawn him on next round:

PHP Code:
new player_team[MAXPLAYERS 1];
new 
bool:need_respawn[MAXPLAYERS 1];
new 
just_swaped[MAXPLAYERS 1];

public 
OnPluginStart()
{
    
HookEvent("player_team"Event_PlayerTeamEventHookMode_Post);
    
HookEvent("round_start"Event_NewRoundEventHookMode_Post);
}

public 
Action:Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
    
// player_team will fire three times in a row and we must ignor two of them    
    
if (just_swaped[client] < 2)
    {
        
just_swaped[client]++;
        return 
Plugin_Continue;
    }
    
    
    new 
team GetEventInt(event"team");
    
    if (
client == || team == || IsFakeClient(client) || !IsClientInGame(client))
    {
        return 
Plugin_Continue;
    }
    
    
PrintToChatAll("Step 1!");
    
    
player_team[client] = team;
     
// We dont wanna get a server crash so timer is needed before team change
    
CreateTimer(0.01EnforceTeamSpecany:client);    
    
    return 
Plugin_Continue;
}

public 
Action:EnforceTeamSpec(Handle:timerany:client)
{
    if (!
IsClientInGame(client))
    {
        return;
    }
    
    
PrintToChatAll("Step 2!");
    
    
just_swaped[client] = 0;
    
// Move player to spectators for a milisecond
    
ChangeClientTeam(client1);
    
CreateTimer(0.1EnforceTeamany:client);    
}

public 
Action:EnforceTeam(Handle:timerany:client)
{
    if (!
IsClientInGame(client))
    {
        return;
    }
    
    
PrintToChatAll("Step 3!");
    
    
// Now move player back to team where he tried to join, he will never respawn by himself now
    
CS_SwitchTeam(clientplayer_team[client]);
    
need_respawn[client] = true;
}

public 
Action:Event_NewRound(Handle:event, const String:name[], bool:dontBroadcast)
{
    
// Now lets spawn poor player :)
    
for (new client 1client <= MaxClientsclient++)
    {
        if (!
IsClientInGame(client))
        {
            continue;
        }

        if (
need_respawn[client] == true)
        {
            
CS_RespawnPlayer(client);
            
need_respawn[client] = false;
        }
    }
        
    return 
Plugin_Continue;
}

public 
OnClientPutInServer(client)
{
    
need_respawn[client] = false;
    
just_swaped[client] = 2;

I do not like this way because script will fire two fictive events and will print two chat messages about swapping client. I also could just use RegConsoleCmd("jointeam", CommandJoinTeam) but in that way I must check many of other situations based on does client have permission to join team or not. If anybody have a suggestions about how to modify this test script in a better way please post replies.
__________________
For admins: My plugins

For developers: Colors library

Last edited by exvel; 04-05-2009 at 03:58.
exvel is offline
Send a message via ICQ to exvel
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 04-06-2009 , 16:00   Re: Block player respawn in CS:S
Reply With Quote #2

Yes, I found it!
The answer was so simple.
To block player respawn we can simply Hook "joinclass" command. Player will not spawn if he didn't select a class.
Added it to antirejoin plugin.
__________________
For admins: My plugins

For developers: Colors library

Last edited by exvel; 04-07-2009 at 03:11.
exvel is offline
Send a message via ICQ to exvel
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-06-2009 , 16:07   Re: Block player respawn in CS:S
Reply With Quote #3

There's a "joinclass" command in CS:S?
bl4nk is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 04-06-2009 , 20:23   Re: Block player respawn in CS:S
Reply With Quote #4

Quote:
Originally Posted by bl4nk View Post
There's a "joinclass" command in CS:S?
I believe so. It's just like jointeam except it changes your player class, which is basically just your model.
__________________
Greyscale is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 04-07-2009 , 03:11   Re: Block player respawn in CS:S
Reply With Quote #5

Quote:
Originally Posted by bl4nk View Post
There's a "joinclass" command in CS:S?
Yeap, this is a player's skin.

p.s. If player already choosed the class we can set it back to 0 by changing m_iClass to 0 and he will not spawn next round.
__________________
For admins: My plugins

For developers: Colors library

Last edited by exvel; 04-07-2009 at 03:21.
exvel is offline
Send a message via ICQ to exvel
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-07-2009 , 05:41   Re: Block player respawn in CS:S
Reply With Quote #6

Typing "joinclass" into my console says it's an Unknown Command.
bl4nk is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 04-07-2009 , 13:30   Re: Block player respawn in CS:S
Reply With Quote #7

Quote:
Originally Posted by bl4nk View Post
Typing "joinclass" into my console says it's an Unknown Command.
Because it is a server side command, client console doesn't know about it and it works only on the server.
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-07-2009 , 15:36   Re: Block player respawn in CS:S
Reply With Quote #8



Are you sure you're testing it on CS:S?
bl4nk is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 04-07-2009 , 15:52   Re: Block player respawn in CS:S
Reply With Quote #9

Yes, I do. This is a command like "drop" or "jointeam" (or any radio command) that are actually a player's actions so only client can send them when he are playing on the server.
p.s. when I wrote about "server side command" I mean that client can send it only when he on the server
__________________
For admins: My plugins

For developers: Colors library

Last edited by exvel; 04-07-2009 at 16:32.
exvel is offline
Send a message via ICQ to exvel
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 04-07-2009 , 16:25   Re: Block player respawn in CS:S
Reply With Quote #10

Quote:
Originally Posted by bl4nk View Post


Are you sure you're testing it on CS:S?
joinclass is a client command.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
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 17:20.


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