AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with a simple team switch blocker (https://forums.alliedmods.net/showthread.php?t=172719)

sauron_pk 11-25-2011 02:02

Help with a simple team switch blocker
 
Hi i want to make a team switch blocker for TFC(hl1 mod).

Basically i made this code:
Code:

#include <amxmodx>

public plugin_init()
{
    register_plugin("TSBlock", "1.0", "TSBlock");
    register_clcmd("jointeam", "cmdjointeam");
}

public cmdjointeam(id)
{
    client_print(id, print_chat, "[AMXX] Team switch isn't allowed.");
   
    return PLUGIN_HANDLED;
}

The problem is that when anyone enter the game they can't choose any team and i don't want to use the auto team assign...

So i need to basically "validate" that if the user isn't in a team(or in spect) they can choose a team, and if the user is in a team (red blue green yellow, 1, 2, 3, 4) they can't use the jointeam command....


Anyone can help me?

THanks!!

gamer99 11-25-2011 05:51

Re: Help with a simple team switch blocker
 
Code:

#include <amxmodx>

public plugin_init()
{
    register_plugin("TSBlock", "1.0", "TSBlock");
    register_clcmd("jointeam", "cmdjointeam");
}

public cmdjointeam(id)
{
  if (get_user_team(id) == 0 || get_user_team(id) == 3)
      return PLUGIN_CONTINUE
 
 client_print(id, print_chat, "[AMXX] Team switch isn't allowed.");   
 return PLUGIN_HANDLED;
}

Untested ..please test it by urself

sauron_pk 11-25-2011 14:22

Re: Help with a simple team switch blocker
 
Hey thanks

it worked but with a little problem..

when i choose a team and i am in red blue or green i can't change the teams, so it's ok

but when i am in the yellow team the plugin don't work so i can change the team.

(jointeam 1 = blue, jointeam 2 = red, jointeam 3 = yellow, jointeam = 4 green)



and another little question,

if i want to make a similar plugin that instead of blocking Team switch i allow to team switch but adding a 5 seconds penalty to respawn, is it possible ?

thanks!!

Devil259 11-26-2011 04:27

Re: Help with a simple team switch blocker
 
Quote:

Originally Posted by sauron_pk (Post 1602506)
if i want to make a similar plugin that instead of blocking Team switch i allow to team switch but adding a 5 seconds penalty to respawn, is it possible ?

Yes.

sauron_pk 11-27-2011 11:28

Re: Help with a simple team switch blocker
 
can you tell me what function should i use or whatever to do this?

and if you know how to fix the bug that the yellow team can change and the others no, i think something is wrong in the if structure

thanks a lot :)

Devil259 11-27-2011 11:55

Re: Help with a simple team switch blocker
 
If you don't know how to do, you can freeze the player who changed team with this stocks :

Code:
Freeze( id ) {     if( is_user_alive(id) )     {         new iFlags = pev(id, pev_flags)         if( ~iFlags & FL_FROZEN )         {             set_pev(id, pev_flags, iFlags | FL_FROZEN)         }     } } UnFreeze( id ) {     if( is_user_alive(id) )     {         new iFlags = pev(id, pev_flags)         if( iFlags & FL_FROZEN )         {             set_pev(id, pev_flags, iFlags & ~FL_FROZEN)         }     } }


All times are GMT -4. The time now is 08:23.

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