AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help add team check (FreeRound) (https://forums.alliedmods.net/showthread.php?t=183948)

PandaDnB 04-28-2012 17:59

Help add team check (FreeRound)
 
Hello, I need to add a check if a terrorist or a counter terrost has triggered a trap here:
Code:

  if(g_use_button){
      client_print(0,print_chat, "[Deathrun[4]Fun] You Used A Trap, FreeRound Is Not Possble!");
      return PLUGIN_HANDLED
  }

Because on some maps CT's have to push a button to open the door and the plugin counts it as a trap and T's cant give a free round. Here is the whole code
Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta_util>

#define PLUGIN "FreeRun"
#define VERSION "1.0"
#define AUTHOR "PomanoB"

new g_free
new g_cvar_t_only
new g_free_time
new bool:g_bFree
new bool:g_use_button

public plugin_init() {
  register_plugin(PLUGIN, VERSION, AUTHOR)
 
  g_cvar_t_only = register_cvar("free_run_t_only", "1")
 
  register_clcmd("say free", "cmdFree")
  register_clcmd("say /free", "cmdFree")

  register_event("HLTV", "eventRoundStart", "a", "1=0", "2=0")
  RegisterHam(Ham_Spawn, "player", "player_spawn",1)
 
  RegisterHam(Ham_Touch, "armoury_entity", "fwdTouch")
  RegisterHam(Ham_Touch, "weaponbox", "fwdTouch")
  RegisterHam(Ham_Use, "func_button", "fwdUse")
}
public player_spawn(id){
 
  if(g_bFree){
      set_task(5.0, "strip_weapons", id)
  }
}
public strip_weapons(id){
 
  fm_strip_user_weapons(id)
  fm_give_item(id, "weapon_knife")
 
}
public eventRoundStart() {
  g_free = false
  g_bFree = false
  g_free_time = true
  g_use_button = false
 
  set_task(20.0,"timer")
}
public timer(){
  g_free_time = false
 
}
public cmdFree(id) {

  if (get_pcvar_num(g_cvar_t_only) && get_user_team(id) != 1) {
      client_print(0,print_chat, "[Deathrun[4]Fun] Only T's Can Give FreeRound!");
      return PLUGIN_HANDLED
  }

  if(g_use_button){
      client_print(0,print_chat, "[Deathrun[4]Fun] You Used A Trap, FreeRound Is Not Possble!");
      return PLUGIN_HANDLED
  }
 
  if(g_free_time){
      new players[32], plNum
      get_players(players, plNum, "ace", "TERRORIST")
     
      g_free = true
      g_bFree = true
     
      set_hudmessage(0, 255, 255, 0.02, -1.0)
      show_hudmessage(0, "FreeRound!")
           
      new i
      get_players(players, plNum, "ah")
      for (i = 0; i < plNum; i++) {
        fm_strip_user_weapons(players[i])
        fm_give_item(players[i], "weapon_knife")
      }
  }else{
      set_hudmessage(0, 255, 255, 0.02, -1.0)
      show_hudmessage(id, "Only In the first 20 sec.!")
  }
  return PLUGIN_HANDLED
 
}

public fwdTouch(ent, id) {
  if (is_user_alive(id) && g_free)
      return HAM_SUPERCEDE
 
  return HAM_IGNORED


public fwdUse(ent, idcaller, idactivator, use_type, Float:value) {
  g_use_button = true
  if (is_user_alive(idactivator) && g_free && get_user_team(idactivator) == 1) {
    client_print(0,print_chat, "[Deathrun[4]Fun] It's FreeRound, You Cannot Use Traps!");
      return HAM_SUPERCEDE 
  }
 
  return HAM_IGNORED
}


Devil259 04-29-2012 08:47

Re: Help add team check (FreeRound)
 
I've created a FreeRound plugin too, I give you my code then you can see how I did.

Code:
#include < amxmodx > #include < fakemeta > #include < hamsandwich > #include < colorchat > #define GetTeam(%1)     get_pdata_int(%1,114,5) #define Print(%1,%2)    client_print_color(%1,DontChange,%2) new const Plugin[ ] = "Deathrun - Free Round"; new const Version[ ] = "0.0.2"; const m_ToggleState = 41; new bool:g_bFreeRound = false; new bool:g_bUsedTrap = false; public plugin_init( ) {     register_plugin( Plugin , Version , "Devil" );         register_clcmd( "say /free" , "ClientCommand_FreeRound" );         RegisterHam( Ham_Use   , "func_rot_button" , "fwHamUseTrap" );     RegisterHam( Ham_Use   , "func_button"     , "fwHamUseTrap" );     RegisterHam( Ham_Use   , "button_target"   , "fwHamUseTrap" );     RegisterHam( Ham_Spawn , "player"          , "fwHamSpawnPost" , true );         register_event( "CurWeapon", "evCurWeapon" , "be" , "1=1" , "2!29" );     register_event( "HLTV" , "StopFreeRound" , "a" , "1=0" , "2=0" );     register_event( "TextMsg" , "StopFreeRound" , "a" , "2&#Game_C" , "2&#Game_w" );         register_logevent( "StopFreeRound" , 2 , "1=Round_End" ); } public ClientCommand_FreeRound( id ) {     if( is_user_alive( id ) )     {         if( GetTeam( id ) == 1 )         {             if( g_bUsedTrap )                 Print( id , "^3You have already actived a trap, you can't start a free round." );                     else if( !g_bFreeRound )                 StartFreeRound( id );         }                 else         {             Print( id , "^3You have to be terrorist to start a free round." );             return PLUGIN_HANDLED;         }     }         else     {         Print( id , "^3You have to be alive to start a free round." );         return PLUGIN_HANDLED;     }         return PLUGIN_HANDLED; } public fwHamUseTrap( iEntity , id , iActivator , iUseType , Float:flValue ) {     if( is_user_alive( id ) && GetTeam( id ) == 1 )     {         if( g_bFreeRound )         {             if( iUseType == 2 && flValue == 1.0 && get_pdata_int( iEntity , m_ToggleState , 4 ) == 1 )             {                 return HAM_SUPERCEDE;             }         }                 else         {             if( !g_bUsedTrap )                 g_bUsedTrap = true;         }     }             return HAM_IGNORED; } public fwHamSpawnPost( id ) {     if( is_user_alive( id ) && GetTeam( id ) == 1 )         set_task( 0.2 , "SayCanFree" , id ); } public SayCanFree( id ) {     Print( id , "Type^3 /free ^1to start a ^3free round^1." ); } public evCurWeapon( id ) {     if( g_bFreeRound )         engclient_cmd( id , "weapon_knife" ); } StartFreeRound( id ) {     new szName[ 32 ];     get_user_name( id , szName , charsmax( szName ) );         Print( 0 , "^3%s ^1 start a ^4free round^1. ^3No weapons^1, ^3no traps^1." , szName );         g_bFreeRound = true; } public StopFreeRound( ) {     g_bFreeRound = false;     g_bUsedTrap = false; }

PandaDnB 04-29-2012 09:27

Re: Help add team check (FreeRound)
 
It wont compile? I get 4 errors.

Devil259 04-29-2012 10:11

Re: Help add team check (FreeRound)
 
1 Attachment(s)
It compiles, you just need colorchat include.

But you don't need to compile it, you just need to look the code and see how I did.


All times are GMT -4. The time now is 07:52.

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