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

[TF2] Why'd this stop working?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
404UserNotFound
BANNED
Join Date: Dec 2011
Old 12-23-2014 , 15:53   [TF2] Why'd this stop working?
Reply With Quote #1

This was working fine before the Smissmas update, not sure what all changed to make it not work. Basically, when a player is jailed and respawns/changes class, they get respawned in the jail position. Right now, they respawn in their normal spawn for some reason which should not be the case.

The positions used are part of the map I run on my server, "trade_masscc_c4_1", it puts players into a jail cell that is part of the map. There's two cells on the map so I separated RED and BLU into their own cells.

This is a private plugin that I didn't intend on releasing because of the hardcoded teleport position, but now that it's out there, you guys may as well use it and modify the positions. I used a co-ordinate finding position to get the co-ords.

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <tf2>
#include <morecolors>

#pragma semicolon 1

public Plugin:myinfo =
{
    
name "[TF2] Jail Player",
    
author "404: User Not Found",
    
description "Jails a player",
    
version "0.2",
    
url "www.unfgaming.net"
};

new 
bool:g_bIsJailed[MAXPLAYERS 1] = false;
new 
Float:g_pos[3];

public 
OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerChanged);
    
HookEvent("player_changeclass"Event_PlayerChanged);
    
    
RegAdminCmd("sm_jail"Command_JailADMFLAG_GENERIC"Usage: sm_jail <player>");
    
RegAdminCmd("sm_unjail"Command_UnJailADMFLAG_GENERIC"Usage: sm_unjail <player>");
}

public 
OnClientDisconnect(client)
{
    for(new 
i=1<= MaxClientsi++)
    {
        
g_bIsJailed[i] = false;
    }
}

public 
OnClientPutInServer(client)
{
    for(new 
i=1<= MaxClientsi++)
    {
        
g_bIsJailed[i] = false;
    }
}

public 
Action:Command_Jail(clientargs)
{
    
decl String:target[32];
    
decl String:target_name[MAX_NAME_LENGTH];
    
decl target_list[MAXPLAYERS];
    
decl target_count;
    
decl bool:tn_is_ml;
    
    
//validate args
    
if (args 1)
    {
        
CReplyToCommand(client"{community}[ADMIN]{default} Usage: sm_jail <#userid|name>.");
        return 
Plugin_Handled;
    }
    
    
//get argument
    
GetCmdArg(1targetsizeof(target));        
    
    
//get target(s)
    
if ((target_count ProcessTargetString(
            
target,
            
client,
            
target_list,
            
MAXPLAYERS,
            
COMMAND_FILTER_ALIVE,
            
target_name,
            
sizeof(target_name),
            
tn_is_ml)) <= 0)
    {
        
ReplyToTargetError(clienttarget_count);
        return 
Plugin_Handled;
    }
    
    for (new 
0target_counti++)
    {
    
//    PerformBring(client, target_list[i], g_pos);
        
g_bIsJailed[target_list[i]] = true;
        if(
IsPlayerAlive(target_list[i]))
        {
            
JailPlayer(target_list[i], g_pos);
            
CReplyToCommand(target_list[i], "{green}[SM]{default} You have been jailed!");
        }
    }
    
CReplyToCommand(client"{community}[ADMIN]{default} Jailed %s."target_name);
    
    return 
Plugin_Handled;    
}

public 
Action:Command_UnJail(clientargs)
{
    
decl String:target[32];
    
decl String:target_name[MAX_NAME_LENGTH];
    
decl target_list[MAXPLAYERS];
    
decl target_count;
    
decl bool:tn_is_ml;
    
    
//validate args
    
if (args 1)
    {
        
CReplyToCommand(client"{community}[ADMIN]{default} Usage: sm_jail <#userid|name>.");
        return 
Plugin_Handled;
    }
    
    
//get argument
    
GetCmdArg(1targetsizeof(target));        
    
    
//get target(s)
    
if ((target_count ProcessTargetString(
            
target,
            
client,
            
target_list,
            
MAXPLAYERS,
            
COMMAND_FILTER_ALIVE,
            
target_name,
            
sizeof(target_name),
            
tn_is_ml)) <= 0)
    {
        
ReplyToTargetError(clienttarget_count);
        return 
Plugin_Handled;
    }
    
    for (new 
0target_counti++)
    {
    
//    PerformBring(client, target_list[i], g_pos);
        
g_bIsJailed[target_list[i]] = false;
        if(
IsPlayerAlive(target_list[i]))
        {
            
TF2_RespawnPlayer(target_list[i]);
            
CReplyToCommand(target_list[i], "{green}[SM]{default} You have been un-jailed!");
        }
    }
    
CReplyToCommand(client"{community}[ADMIN]{default} Un-jailed %s."target_name);
    
    return 
Plugin_Handled;    
}


public 
Action:Event_PlayerChanged(Handle:event, const String:name[], bool:dontbroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(
g_bIsJailed[client] == true)
    {
        
JailPlayer(clientg_pos);
    }
    return 
Plugin_Continue;
}

JailPlayer(targetFloat:pos[3])
{
    if (
GetClientTeam(target) == _:TFTeam_Red)
    {
        
pos[0] = -67.792053;
        
pos[1] = -6020.118652;
        
pos[2] = -797.968750;
    }
    if (
GetClientTeam(target) == _:TFTeam_Blue)
    {
        
pos[0] = -40.162773;
        
pos[1] = -5780.982910;
        
pos[2] = -797.968750;
    }
    
TeleportEntity(targetposNULL_VECTORNULL_VECTOR);


Last edited by 404UserNotFound; 12-23-2014 at 15:55.
404UserNotFound is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 12-23-2014 , 16:25   Re: [TF2] Why'd this stop working?
Reply With Quote #2

Try either delaying the player being moved by a frame or run a timer to do it a short time later (0.1 seconds should work fine).
bl4nk is offline
404UserNotFound
BANNED
Join Date: Dec 2011
Old 12-23-2014 , 17:14   Re: [TF2] Why'd this stop working?
Reply With Quote #3

Quote:
Originally Posted by bl4nk View Post
Try either delaying the player being moved by a frame or run a timer to do it a short time later (0.1 seconds should work fine).
Pelipoika messaged me this on Steam:

Quote:
Pelipoika: Dat jail code
Pelipoika: When a person dsiconnects
Pelipoika: everyone on the server
Pelipoika: is taken out of the jail bool
Pelipoika: wat
Pelipoika: JailPlayer doesnt need a pos passed to it
Pelipoika: you already know the coords of the jail
Pelipoika: just tp the player therew
I'm used to seeing bools having to be cleared when someone connects/disconnects, I guess I screwed it up by passing all clients through it. Whoops! That may be the cause of the issues.

Also, I'll try adding a timer to it.

Last edited by 404UserNotFound; 12-23-2014 at 17:14.
404UserNotFound 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 10:56.


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