Raised This Month: $ Target: $400
 0% 

player_team controlling teams - CSS


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Demorac
Junior Member
Join Date: Apr 2009
Old 05-09-2009 , 15:29   player_team controlling teams - CSS
Reply With Quote #1

I've been trying to hook the player_team event and change the players team to a different one, if what they are changing to is not what I want.

To experiment, I've been using the event to disable team changing by automatically switching the player back to their original team if they do switch, granted they are not switching to spec or disconnecting, and if they are just joining a team I automatically place them on CT.


I have this code, which should work, but for some reason it doesn't want to. Anybody know how to make this happen?

PHP Code:
new Handle:SwitchTimers[25]

public 
OnPluginStart()
{
    
HookEvent("player_team"evPlayerTeamEventHookMode_Post)
    
RegAdminCmd("sm_teamit",TeamItADMFLAG_BAN)
}

public 
evPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"))
    new 
oldteam GetEventInt(event"oldteam")
    
    new 
Handle:pack
    WritePackCell
(packclient)
    
WritePackCell(packoldteam)
    
    
SwitchTimers[client] = CreateTimer(0.1SwitchPlayerpack)
}

public 
Action:SwitchPlayer(Handle:timerHandle:pack)
{
    new 
clientoldteam
    
    ResetPack
(pack)
    
client ReadPackCell(pack)
    
oldteam ReadPackCell(pack)
    
    if (
oldteam == || oldteam == 1
    {
        
oldteam 3
    
}
    
    
CS_SwitchTeam(clientoldteam)
    
CS_RespawnPlayer(client)
    
    
PrintToChat(client"[SM] Sorry, team changing is disabled!")
    
SwitchTimers[client] = INVALID_HANDLE

Demorac is offline
antihacker
Member
Join Date: Feb 2009
Old 05-09-2009 , 15:47   Re: player_team controlling teams - CSS
Reply With Quote #2

Cant you just rewrite the player_team event?
antihacker is offline
Demorac
Junior Member
Join Date: Apr 2009
Old 05-09-2009 , 16:14   Re: player_team controlling teams - CSS
Reply With Quote #3

No, that doesn't change the player's team, only the message that gets displayed.
Demorac is offline
antihacker
Member
Join Date: Feb 2009
Old 05-09-2009 , 16:18   Re: player_team controlling teams - CSS
Reply With Quote #4

I think you forgot, CreateDataPack.
antihacker is offline
Demorac
Junior Member
Join Date: Apr 2009
Old 05-09-2009 , 16:30   Re: player_team controlling teams - CSS
Reply With Quote #5

Wow... I did too....
Demorac is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 05-09-2009 , 16:56   Re: player_team controlling teams - CSS
Reply With Quote #6

I think it is much better and easier to hook "jointeam" command.
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
Demorac
Junior Member
Join Date: Apr 2009
Old 05-09-2009 , 16:57   Re: player_team controlling teams - CSS
Reply With Quote #7

It might be, I'll give it a try.
Demorac 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 17:23.


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