AMX MOD X
Четверг, 28.03.2024, 13:34:16



Приветствую Вас Гость | RSS
[ Главная ] [ Kz Jump Plugin v0.08b + teamchange - AMX Mod X Форум ] [ Регистрация ] [ Вход ]
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]

Вниманию участников! Данный форум теперь является архивом и вскором времени здесь нельзя будет создавать новых тем! Просьба всем для общения и создания новых тем перейти на наш новый форум: http://amxmodx.su/

  • Страница 1 из 2
  • 1
  • 2
  • »
Модератор форума: slogic, AlMod  
AMX Mod X Форум » Скриптинг » Помощь по скриптингу » Kz Jump Plugin v0.08b + teamchange (корректировка кода)
Kz Jump Plugin v0.08b + teamchange
HafnerДата: Четверг, 30.07.2009, 11:37:18 | Сообщение # 1
Лейтенант
Группа: Пользователи
Сообщений: 46
Репутация: 0
Статус: Не в сети
Всех приветствую!
Понадобилось поднять kreedz сервер, поставил Kz Jump Plugin v0.08b, после просмотра возможностей встала необходимость добавления команды /spec для перехода игрока в спектаторы и соответственно команды /ct для возвращения обратно за CT. Нашел плагин, который выполняет эти функции, выдрал оттуда код и внёс в kz_main.sma В итоге столкнулся со следующими проблемами ака вопросами:

1) плагин только переносил игрока в спек и обратно при возвращении заного спавнил его, нужно же, чтоб при переходе в спек таймер останавливался и при возвращении он снова продолжался, а также игрок автоматом появлялся на той точке, где ушел в спек. Это я вроде организовал добавив в код выхода в спек сейв чекпоинта, а при возвращении чтоб телепортило назад, но как-то криво получилось... Сейв и ТП происходит, но появляются модели после сейва, которые не исчезают (см.скрин):
http://s59.radikal.ru/i166/0907/27/890e8b8db61d.jpg

2) также не могу понять почему не работает команда /reset в режиме спектатора? Эта функция заного спавнит игрока. Когда я за СТ, то норм робит, но в спеках не пашет, вернее после её прописания в спеках происходит скачок текстур, но игрок так и не респавнится, хотя в коде нет запрета на это...

Буду весьма благодарен хотя бы за намек, как решать эти вопросы, сам код kz_main.sma:

Code
#include <amxmodx>
#include <amxmisc>
#include <kz>
#include <respawn>
#include <time>
#include <fun>
#include <engine>

//#define DEBUG

#define MAX_CP 25
#define DISTANCE_FROM_BUTTON 95.0

// Check Point
new cpCount[33];
new cp_count[33] = {-1, ...};
new Float:cp_location[33][MAX_CP][3];

// Teleport Count
new gc_count[33];

// Is Player started?
new bool:Started[33];

// Timer
new Float:Timer[33];

// Pause Hold timer
new IsPaused[33];
new Float:PauseTime[33];

// Completed Climb?
new bool:completed_climb[33];

// Hold the entity id and origin of the start and end buttons
new start;
new Float:start_origin[3];

new end;
new Float:end_origin[3];

// Maximum numbers of slots
new maxplayers;

// Pointer Cvar
new kz_enabled;
new kz_CpPrice;
new mp_startmoney;

// Color chat
new SayText;
new RoundTime;

new bool:kz_died[33];

// Hud Stuff
new MsgSync;

// Forwards
new kz_fwd_init;
new kz_fwd_start;
new kz_fwd_finish;
new kz_fwd_reset;
new fwd_result;

new help_file[64];

// Map Exploits.
// One in kz_man_redrock. If they go into low gravity room then. Stop timer????
// What to do ? When they touch that trigger teleport disable the teleport and check points?

public plugin_init()
{
  register_plugin("KZ Main", KZ_VERSION, "teame06");

  // Forwards
  kz_fwd_init = CreateMultiForward("kz_Init", ET_IGNORE, FP_CELL);

  // Cvars
  register_cvar("kz_version", KZ_VERSION, FCVAR_SERVER|FCVAR_SPONLY);
  kz_enabled = register_cvar("kz_enabled", "1", FCVAR_SERVER|FCVAR_SPONLY);
  kz_CpPrice = register_cvar("kz_cp_price", "0");
  register_cvar("kz_boosttime", "45");
  register_cvar("kz_autojoin", "0");

  #if defined DEBUG
  register_clcmd("show_ent", "cmdEnt");
  #endif
}

public plugin_cfg()
{
  // Configs
  new config[64];
  get_configsdir(config, 63);

  server_cmd("exec %s/kz/kz.cfg", config);
  server_exec();

  set_task(6.5, "kz_start");
}

public kz_start()
{
     if(get_pcvar_num(kz_enabled))
     {
         find_buttons();
         ExecuteForward(kz_fwd_init, fwd_result, _ON);
     } else {
         set_cvar_num("kz_enabled", 0);
         ExecuteForward(kz_fwd_init, fwd_result, _OFF);
     }
}

public kz_Init(_state)
{
  if(!_state)
  {
   pause("a");
   return;
  }

  // Forwards
  kz_fwd_start = CreateMultiForward("kz_StartClimb", ET_IGNORE, FP_CELL);
  kz_fwd_finish = CreateMultiForward("kz_FinishClimb", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL);
  kz_fwd_reset = CreateMultiForward("kz_ResetClimb", ET_IGNORE, FP_CELL);

  // Make a checkpoint
  //new _check[] = "Makes
  register_saycmd("cp", "cmdCP", -1, "");
  register_saycmd("checkpoint", "cmdCP", -1, "");
  register_saycmd("check", "cmdCP", -1, "");

  // Teleport to checkpoint
  register_saycmd("tele", "cmdTele", -1, "");
  register_saycmd("gc", "cmdTele", -1, "");
  register_saycmd("gocheck", "cmdTele", -1, "");
  register_saycmd("tp", "cmdTele", -1, "");

  // Timer stuff
  register_saycmd("pause", "cmdPause", -1, "");
  register_saycmd("reset", "cmdReset", -1, "");
  register_saycmd("start", "cmdReset", -1, "");

  // Previous Check Point
  register_saycmd("stuck", "cmdStuck", -1, "");
  register_saycmd("unstuck", "cmdStuck", -1, "");

  // Misc
  register_saycmd("help", "cmdHelp", -1, "");

         // Spec
         register_saycmd("spec", "cmdSpec", -1, "");
  register_saycmd("ct", "cmdCT", -1, "");

  // Admin Commands
  register_clcmd("amx_teleport", "cmdTeleport", ADMIN_BAN, "- amx_teleport <#userid|name|steamid> <#userid|name|steamid>");

  // Forwards
  register_forward(FM_PlayerPreThink, "PreThink", 1);
  register_forward(FM_ClientKill, "fm_ClientKill");

  // Dictionary files
  register_dictionary("time.txt");

  maxplayers = get_maxplayers();
  MsgSync = CreateHudSyncObj();
  SayText = get_user_msgid("SayText"); // Color messages
  RoundTime = get_user_msgid("RoundTime"); // Climb Timer
  mp_startmoney = get_cvar_pointer("mp_startmoney");

  get_configsdir(help_file, 63);
  formatex(help_file, 63, "%s/kz/help.txt", help_file);

  set_task(0.5, "hudtime", _, _, _, "b");

  set_cvar_num("mp_limitteams", 0);
  set_cvar_num("mp_autoteambalance", 0);
  set_cvar_num("mp_freezetime", 0);
  set_cvar_num("sv_airaccelerate", 10);
  set_cvar_num("sv_restartround", 1);
  set_cvar_num("respawn_enabled", 1); // Enables the respawn plugin on run.
  server_exec();
}

// This function was created to detect which maps are KZ
// but to also cache some button information for speed.
find_buttons()
{
  new ent = engfunc(EngFunc_FindEntityByString, -1, "classname", "func_button");

  while(ent > 0)
  {
   new target[32];
   pev(ent, pev_target, target, 31);

   if(equal(target, "counter_start"))
    start = ent;
   else if(equal(target, "clockstartbutton"))
    start = ent;
   else if(equal(target, "firsttimerelay"))
    start = ent;

   if(equal(target, "clockstop"))
    end = ent;
   else if(equal(target, "counter_off"))
    end = ent;
   else if(equal(target, "clockstopbutton"))
    end = ent;

   ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_button");
  }

  if(start && end)
  {
   new map[32];
   get_mapname(map, 31);

   if(equali("surf_", map, 5))
    return 0;

   _get_brush_entity_origin(start, start_origin);
   _get_brush_entity_origin(end, end_origin);

   return 1;
  }
  return 0;
}

public plugin_natives()
{
  register_library("kz");
  register_native("IsPlayerStarted", "native_is_player_started");
  register_native("IsPlayerFinished", "native_is_player_finish");

  // This has to be style 1. It be to complicated if it was style 0;
  register_native("kz_ShowSyncHudMsg", "native_showhud", 1);
  register_native("kz_ColorChat", "native_color_print_chat", 1);
}

public native_color_print_chat(player, color_type, const message[], {Float,Sql,Result,_}:...)
{
  new nums = numargs();

  if(nums < 3)
   return log_error(AMX_ERR_NATIVE, "Bad native parameters");

  new i;
  for(i = 3; i <= nums; i++)
   param_convert(i);

  static msg[191];
  vformat(msg, 190, message, 4);

  if(player > 0 && player <= maxplayers)
   _color_chat(player, color_type, msg);
  else if(!player)
  {
   static players[32], nums, index;
   get_players(players, nums);

   for(new i = 0; i < nums; i++)
   {
    index = players[i];
    _color_chat(index, color_type, msg);
   }
  }
  return PLUGIN_CONTINUE;
}

public native_showhud(player, r, g, b, Float:x, Float:y, const message[], {Float,Sql,Result,_}:...)
{
  new nums = numargs();

  if(nums < 7)
   return log_error(AMX_ERR_NATIVE, "Bad native parameters");

  new i;
  for(i = 7; i <= nums; i++)
   param_convert(i);

  static msg[191];
  vformat(msg, 190, message, 8);
  kz_show_hud(player, r, g, b, x, y, msg);

  return PLUGIN_CONTINUE;
}

public native_is_player_started(id, nums)
{
  if(nums != 1)
   return log_error(AMX_ERR_NATIVE, "Bad native parameters");

  return Started[get_param(1)];
}

public native_is_player_finish(id, nums)
{
  if(nums != 1)
   return log_error(AMX_ERR_NATIVE, "Bad native parameters");

  return completed_climb[get_param(1)];
}

public client_putinserver(id)
{
  if(!get_pcvar_num(kz_enabled))
   return;

  set_task(10.0, "advert_help", id);
}

public client_connect(id)
{
  if(!get_pcvar_num(kz_enabled))
   return;

  Started[id] = false;
  completed_climb[id] = false;

  Timer[id] = 0.0;
  cp_count[id] = -1;
  PauseTime[id] = 0.0;

  kz_died[id] = false;
  gc_count[id] = 0;
  cpCount[id] = 0;
}

public advert_help(id)
{
  _color_chat(id, green, "[kz] For kz commands please type say /help");
}

public cmdPause(id)
{
  if(get_pcvar_num(kz_enabled))
  {
   if(Started[id])
   {
    new temp = IsPaused[id];
    if(!temp || temp == 2)
    {
     PauseTime[id] += (thetime() - Timer[id]);
     IsPaused[id] = 1;
     Timer[id] = 0.0;

     kz_show_hud(id, 128, 0, 128, 0.43, 0.89, "PAUSED");
     set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN);

     SetPlayerNotSolid(id);
     SetPlayerPause(id, 1);
    }
    else
    {
     IsPaused[id] = (IsPaused[id] == 1) ? 2 : 1;
     Timer[id] = thetime();

     kz_show_hud(id, 128, 0, 128, 0.44, 0.89, "UNPAUSED");
     set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN);

     SetPlayerSolid(id);
     SetPlayerPause(id);
    }
   }
   else
   {
    kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You must start the timer before you can pause.");
   }
   return PLUGIN_HANDLED;
  }
  return PLUGIN_CONTINUE;
}

public cmdReset(id)
{
  if(get_pcvar_num(kz_enabled))
  {
   Started[id] = false;
   reset_data(id);
   ExecuteForward(kz_fwd_reset, fwd_result, id);
   spawn_player(id);

   return PLUGIN_HANDLED;
  }
  return PLUGIN_CONTINUE;
}

public reset_data(id)
{
  Timer[id] = 0.0;
  PauseTime[id] = 0.0;
  cpCount[id] = 0;
  gc_count[id] = 0;
}

public cmdHelp(id)
{
  if(get_pcvar_num(kz_enabled))
  {
   show_motd(id, help_file);
   return PLUGIN_HANDLED;
  }
  return PLUGIN_CONTINUE;
}

public PreThink(id)
{
  if(!get_pcvar_num(kz_enabled) && !is_user_alive(id))
   return FMRES_IGNORED;

  if(pev(id, pev_button) & IN_USE)
  {
   static button, body;
   get_user_aiming(id, button, body);

   if(button > maxplayers)
   {
    if(pev_valid(button))
    {
     static Float:origin[3];
     pev(id, pev_origin, origin);

     if(!Started[id] && button == start)
     {
      if(vector_distance(origin, start_origin) <= DISTANCE_FROM_BUTTON)
      {
       start_climb(id, origin);
      }
     }
     else if(button == end)
     {
      if(vector_distance(origin, end_origin) <= DISTANCE_FROM_BUTTON)
      {
       finish_climb(id);
      }
     }
    }
   }
  }

  // Checks if a player is in noclip. Do not allow him to continue the timer.
  /*if(Started[id] && pev(id, pev_movetype) == MOVETYPE_NOCLIP)
  {
   reset_data(id);
   Started[id] = false;
   kz_ColorChat(id, green, "[kz] NoClip Detected, Timer Stopped.");
  }*/
  return FMRES_IGNORED;
}

is_not_alive(id)
{
  kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You must be alive to execute this command.");
}

start_climb(id, Float:origin[3])
{
  static Float:angle[3];
  pev(id, pev_angles, angle);

  Started[id] = true;
  spawn_player(id); // Remove any long jump, etc...

  set_pev(id, pev_angles, angle);
  set_pev(id, pev_origin, origin);
  delay_duck(id);

  dllfunc(DLLFunc_Use, start, id); // Make sure the map timer starts
  Timer[id] = thetime();

  kz_show_hud(id, 128, 0, 128, 0.38, 0.89, "Timer started. Go Go Go!!!");
  client_cmd(id, "spk scientist/c3a2_sci_portopen");

  if(get_pcvar_num(kz_CpPrice))
   cs_set_user_money(id, get_pcvar_num(mp_startmoney));

  cp_count[id] = -1;
  IsPaused[id] = 0;

  ExecuteForward(kz_fwd_start, fwd_result, id);

  cs_set_user_deaths(id, 0);
  set_pev(id, pev_frags, 0.0);
}

finish_climb(id)
{
  if(!is_user_alive(id))
  {
   is_not_alive(id);
   return;
  }

  if(!completed_climb[id] || Started[id])
  {
   completed_climb[id] = true;

   static time;

   if(Started[id])
   {
    dllfunc(DLLFunc_Use, end, id); // Make sure the map timer stops

    time = floatround((thetime() - Timer[id]) + PauseTime[id]);

    _convert_time(id, time);

    client_cmd(id, "spk woop");
    kz_show_hud(id, 128, 0, 128, 0.46, 0.89, "Finished.");
   }

   Started[id] = false;

   ExecuteForward(kz_fwd_finish, fwd_result, id, time, cpCount[id], gc_count[id]);
   reset_data(id);
  }
}

_convert_time(id, time)
{
  static TimeMsg[128];

  static name[32];
  get_user_name(id, name, 31);

  // Display to everyone with server language.
  get_time_length(0, time, timeunit_seconds, TimeMsg, 127);
  kz_ColorChat(0, team, "[kz] It took %s %s to complete the climb.", name, TimeMsg);
}

public cmdCP(id)
{
  if(get_pcvar_num(kz_enabled))
  {
   if(is_user_alive(id))
   {
    if(IsPaused[id] == 1)
    {
     paused(id);
     return PLUGIN_HANDLED;
    }

    if(get_pcvar_num(kz_CpPrice))
    {
     new money = cs_get_user_money(id);

     if(get_pcvar_num(kz_CpPrice) <= money)
      cs_set_user_money(id, money - get_pcvar_num(kz_CpPrice));
     else
     {
      kz_ShowSyncHudMsg(id, 128, 0, 128, 0.25, 0.89, "You don't have enough cash for more checkpoints. $%i", get_pcvar_num(kz_CpPrice));
      return PLUGIN_HANDLED;
     }
    }

    static vel[3];
    pev(id, pev_velocity, vel);

    if(vel[2] >= 0 && pev(id, pev_flags) & FL_ONGROUND)
    {
     cp_count[id]++;
     cpCount[id]++;

     if(cp_count[id] == MAX_CP)
      cp_count[id] = 0;

     pev(id, pev_origin, cp_location[id][cp_count[id]]);
     kz_ShowSyncHudMsg(id, 128, 0, 128, 0.41, 0.89, "Checkpoint saved. %i", cpCount[id]);
    }
    else
    {
     kz_show_hud(id, 128, 0, 128, 0.32, 0.89, "You can't make checkpoints while falling.");
    }
   }
   else
   {
    is_not_alive(id);
   }
   return PLUGIN_HANDLED;
  }
  return PLUGIN_CONTINUE;
}

paused(id)
{
  kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You can't execute this command while paused.");
}

public cmdTele(id)
{
  if(get_pcvar_num(kz_enabled))
  {
   if(!is_user_alive(id))
   {
    is_not_alive(id);
    return PLUGIN_HANDLED;
   }

   if(IsPaused[id] == 1)
   {
    paused(id);
    return PLUGIN_HANDLED;
   }

   if(cp_count[id] != -1)
   {
    static Float:origin[3], players[32], nums, person, i, Float:cp_origin[3];
    get_players(players, nums, "ac");
    SetPlayerNotSolid(id);

    cp_origin = cp_location[id][cp_count[id]];

    for(i = 0; i < nums; i++)
    {
     person = players[i];

     if(id == person)
      continue;

     pev(person, pev_origin, origin);

     if(vector_distance(origin, cp_origin) <= 74.0)
     {
      SetPlayerNotSolid(person);
      break;
     }
    }

    set_pev(id, pev_velocity, {0, 0, 0}); // Reset velocity
    set_pev(id, pev_origin, cp_origin);
    kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You have been teleported to your checkpoint.");
    delay_duck(id);

    gc_count[id]++;
   }

   return PLUGIN_HANDLED;
  }
  return PLUGIN_CONTINUE;
}

delay_duck(id)
{
  set_task(0.01, "force_duck", id);
  _fm_set_entity_flags(id, FL_DUCKING, 1);
}

public force_duck(id)
{
  _fm_set_entity_flags(id, FL_DUCKING, 1);
}

public cmdStuck(id)
{
  if(!get_pcvar_num(kz_enabled))
   return PLUGIN_CONTINUE;

  if(!is_user_alive(id))
  {
   is_not_alive(id);
   return PLUGIN_HANDLED;
  }

  if(IsPaused[id] == 1)
  {
   paused(id);
   return PLUGIN_HANDLED;
  }

  if(cp_count[id] == -1)
   return PLUGIN_HANDLED;

  if(cp_count[id] > 0)
   cp_count[id]--;

  set_pev(id, pev_velocity, {0, 0, 0}); // Reset velocity
  kz_show_hud(id, 128, 0, 128, 0.30, 0.89, "Your previous checkpoint has been restored.");
  set_pev(id, pev_origin, cp_location[id][cp_count[id]]);
  delay_duck(id);
  return PLUGIN_HANDLED;
}

#if defined DEBUG
public cmdEnt(id)
{
  new target_id, body;
  get_user_aiming(id, target_id, body);

  if(target_id > maxplayers)
  {
   new class[32];
   pev(target_id, pev_classname, class, 31);

   new target[32];
   pev(target_id, pev_target, target, 31);

   client_print(id, print_chat, "ent id: %i classname: %s target: %s", target_id, class, target);
  }
  return PLUGIN_HANDLED;
}
#endif

Float:thetime()
{
  new Float:engine_time;
  global_get(glb_time, engine_time);
  return engine_time;
}

_color_chat(id, color, message[])
{
  if(!id)
   return;

  if(is_user_connected(id))
  {
   static msg[192];

   switch(color)
   {
    case 1:
     msg = "^x03";
    case 2:
     msg = "^x04";
   }

   add(msg, 191, message);

   message_begin(MSG_ONE, SayText, {0, 0, 0}, id);
   write_byte(id);
   write_string(msg);
   message_end();
  }
}

_fm_set_entity_flags(index, flag, onoff) // Taken from fakemeta_util
{
  new flags = pev(index, pev_flags);

  if ((flags & flag) > 0)
   return onoff == 1 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags - flag);
  else
   return onoff == 0 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags + flag);

  return 0;
}

public cmdTeleport(id, level, cid)
{
  if(!get_pcvar_num(kz_enabled))
   return PLUGIN_CONTINUE;

  if(!cmd_access(id, level, cid, 1))
   return PLUGIN_HANDLED;

  new arg[32], arg1[32];
  read_argv(1, arg, 31);
  read_argv(2, arg1, 31);

  new person = cmd_target(id, arg, 12);
  new player = cmd_target(id, arg1, 12);

  if(!person || !player)
   return PLUGIN_HANDLED;

  new Float:Origin[3];

  pev(player, pev_origin, Origin);
  set_pev(person, pev_origin, Origin);
  SetPlayerNotSolid(player);
  SetPlayerNotSolid(person);
  delay_duck(person);

  new name[32];
  new name1[32];

  get_user_name(person, name, 31);
  get_user_name(person, name1, 31);

  console_print(id, "[kz] You teleport %s to player %s position.", name, name1);
  return PLUGIN_HANDLED;
}

public DeathMessage(killer, victim, headshot, weaponname[])
{
  if(get_pcvar_num(kz_enabled))
   kz_died[victim] = true;
}

public PostSpawn(id)
{
  if(!get_pcvar_num(kz_enabled))
   return;

  if(!is_user_alive(id))
   return;

  if(kz_died[id])
  {
   kz_died[id] = false;
   cmdTele(id);
  }
}

kz_show_hud(id, r, g, b, Float:x, Float:y, const msg[])
{
  if(is_user_connected(id)) // 128, 0, 128
  {
   set_hudmessage(r, g, b, x, y, 0, 0.0, 3.0, 0.0, 0.0, 4);
   ShowSyncHudMsg(id, MsgSync, "%s", msg);
  }
}

public fm_ClientKill(id)
{
  if(get_pcvar_num(kz_enabled))
   return FMRES_SUPERCEDE;

  return FMRES_IGNORED;
}

public hudtime()
{
  if(get_pcvar_num(kz_enabled))
  {
   static Players[32], count, i, index;
   get_players(Players, count, "ach");

   for(i = 0; i < count; i++)
   {
    index = Players[i];

    message_begin(MSG_ONE, RoundTime, {0, 0, 0}, index);
    write_short(func_29(index) + 1);
    message_end();
   }
  }
}

func_29(id)
{
  static Float:blah;
  blah = 0.0;

  switch(IsPaused[id])
  {
   case 0:
   {
    if(Timer[id])
     blah = thetime() - Timer[id];
   }
   case 1:
   {
    blah = PauseTime[id];
   }
   case 2: // Player continue after paused.
   {
    blah = PauseTime[id] + (thetime() - Timer[id]);
   }
  }
  return floatround(blah);
}

public cmdCT(id)
{
  if(get_pcvar_num(kz_enabled))
  {
                 new CsTeams:UserTeam = cs_get_user_team(id);
                 if (UserTeam != CS_TEAM_CT)  
                 {
                         cs_set_user_team(id,CS_TEAM_CT,CS_DONTCHANGE);
                         spawn_player(id);
                         give_item(id,"weapon_knife");
                         give_item(id,"weapon_usp");  
                         cmdTele(id);
                 }
   return PLUGIN_HANDLED;
  }
  return PLUGIN_CONTINUE;
}

public cmdSpec(id)
{
  if(get_pcvar_num(kz_enabled))
  {
                 new CsTeams:UserTeam=cs_get_user_team(id);
                 if (UserTeam != CS_TEAM_SPECTATOR)  
                 {
                         cmdCP(id);
                         entity_set_int(id,EV_INT_deadflag,DEAD_DISCARDBODY);
                         cs_set_user_team(id,CS_TEAM_SPECTATOR,CS_DONTCHANGE);
                 }
   return PLUGIN_HANDLED;
  }
  return PLUGIN_CONTINUE;
}

Из добавленного только 2 функции в самом низу cmdSpec и cmdCT

 
defaultNick8433Дата: Четверг, 30.07.2009, 20:43:40 | Сообщение # 2
Генерал-полковник
Группа: Скриптеры
Сообщений: 806
Репутация: 19
Статус: Не в сети
Попробуй вместо этого
Code
entity_set_int(id,EV_INT_deadflag,DEAD_DISCARDBODY)

Добавить вот это
Code
set_pev(id, pev_deadflag, DEAD_DISCARDBODY)


Раскручиваю сайты,ставлю трекера на хостинг.Всё бесплатно.Если заинтересовало,то моя аська 400538001
 
HafnerДата: Четверг, 30.07.2009, 22:37:37 | Сообщение # 3
Лейтенант
Группа: Пользователи
Сообщений: 46
Репутация: 0
Статус: Не в сети
Тоже самое =/
 
defaultNick8433Дата: Пятница, 31.07.2009, 09:57:09 | Сообщение # 4
Генерал-полковник
Группа: Скриптеры
Сообщений: 806
Репутация: 19
Статус: Не в сети
Попробуй мой код:
Code
#include <amxmodx>
#include <amxmisc>
#include <kz>
#include <respawn>
#include <time>
#include <fun>
#include <engine>

//#define DEBUG

#define MAX_CP 25
#define DISTANCE_FROM_BUTTON 95.0

// Check Point
new cpCount[33];
new cp_count[33] = {-1, ...};
new Float:cp_location[33][MAX_CP][3];

// Teleport Count
new gc_count[33];

// Is Player started?
new bool:Started[33];

// Timer
new Float:Timer[33];

// Pause Hold timer
new IsPaused[33];
new Float:PauseTime[33];

// Completed Climb?
new bool:completed_climb[33];

// Hold the entity id and origin of the start and end buttons
new start;
new Float:start_origin[3];

new end;
new Float:end_origin[3];

// Maximum numbers of slots
new maxplayers;

// Pointer Cvar
new kz_enabled;
new kz_CpPrice;
new mp_startmoney;

// Color chat
new SayText;
new RoundTime;

new bool:kz_died[33];

// Hud Stuff
new MsgSync;

// Forwards
new kz_fwd_init;
new kz_fwd_start;
new kz_fwd_finish;
new kz_fwd_reset;
new fwd_result;

new help_file[64];

// Map Exploits.
// One in kz_man_redrock. If they go into low gravity room then. Stop timer????
// What to do ? When they touch that trigger teleport disable the teleport and check points?

public plugin_init()
{
register_plugin("KZ Main", KZ_VERSION, "teame06");
register_clcmd("say /spec","spec")
register_clcmd("say /ct","ct")

// Forwards
kz_fwd_init = CreateMultiForward("kz_Init", ET_IGNORE, FP_CELL);

// Cvars
register_cvar("kz_version", KZ_VERSION, FCVAR_SERVER|FCVAR_SPONLY);
kz_enabled = register_cvar("kz_enabled", "1", FCVAR_SERVER|FCVAR_SPONLY);
kz_CpPrice = register_cvar("kz_cp_price", "0");
register_cvar("kz_boosttime", "45");
register_cvar("kz_autojoin", "0");

#if defined DEBUG
register_clcmd("show_ent", "cmdEnt");
#endif
}

public plugin_cfg()
{
// Configs
new config[64];
get_configsdir(config, 63);

server_cmd("exec %s/kz/kz.cfg", config);
server_exec();

set_task(6.5, "kz_start");
}

public kz_start()
{
if(get_pcvar_num(kz_enabled))
{
find_buttons();
ExecuteForward(kz_fwd_init, fwd_result, _ON);
} else {
set_cvar_num("kz_enabled", 0);
ExecuteForward(kz_fwd_init, fwd_result, _OFF);
}
}

public kz_Init(_state)
{
if(!_state)
{
pause("a");
return;
}

// Forwards
kz_fwd_start = CreateMultiForward("kz_StartClimb", ET_IGNORE, FP_CELL);
kz_fwd_finish = CreateMultiForward("kz_FinishClimb", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL);
kz_fwd_reset = CreateMultiForward("kz_ResetClimb", ET_IGNORE, FP_CELL);

// Make a checkpoint
//new _check[] = "Makes
register_saycmd("cp", "cmdCP", -1, "");
register_saycmd("checkpoint", "cmdCP", -1, "");
register_saycmd("check", "cmdCP", -1, "");

// Teleport to checkpoint
register_saycmd("tele", "cmdTele", -1, "");
register_saycmd("gc", "cmdTele", -1, "");
register_saycmd("gocheck", "cmdTele", -1, "");
register_saycmd("tp", "cmdTele", -1, "");

// Timer stuff
register_saycmd("pause", "cmdPause", -1, "");
register_saycmd("reset", "cmdReset", -1, "");
register_saycmd("start", "cmdReset", -1, "");

// Previous Check Point
register_saycmd("stuck", "cmdStuck", -1, "");
register_saycmd("unstuck", "cmdStuck", -1, "");

// Misc
register_saycmd("help", "cmdHelp", -1, "");

// Spec
register_saycmd("spec", "cmdSpec", -1, "");
register_saycmd("ct", "cmdCT", -1, "");

// Admin Commands
register_clcmd("amx_teleport", "cmdTeleport", ADMIN_BAN, "- amx_teleport <#userid|name|steamid> <#userid|name|steamid>");

// Forwards
register_forward(FM_PlayerPreThink, "PreThink", 1);
register_forward(FM_ClientKill, "fm_ClientKill");

// Dictionary files
register_dictionary("time.txt");

maxplayers = get_maxplayers();
MsgSync = CreateHudSyncObj();
SayText = get_user_msgid("SayText"); // Color messages
RoundTime = get_user_msgid("RoundTime"); // Climb Timer
mp_startmoney = get_cvar_pointer("mp_startmoney");

get_configsdir(help_file, 63);
formatex(help_file, 63, "%s/kz/help.txt", help_file);

set_task(0.5, "hudtime", _, _, _, "b");

set_cvar_num("mp_limitteams", 0);
set_cvar_num("mp_autoteambalance", 0);
set_cvar_num("mp_freezetime", 0);
set_cvar_num("sv_airaccelerate", 10);
set_cvar_num("sv_restartround", 1);
set_cvar_num("respawn_enabled", 1); // Enables the respawn plugin on run.
server_exec();
}

// This function was created to detect which maps are KZ
// but to also cache some button information for speed.
find_buttons()
{
new ent = engfunc(EngFunc_FindEntityByString, -1, "classname", "func_button");

while(ent > 0)
{
new target[32];
pev(ent, pev_target, target, 31);

if(equal(target, "counter_start"))
start = ent;
else if(equal(target, "clockstartbutton"))
start = ent;
else if(equal(target, "firsttimerelay"))
start = ent;

if(equal(target, "clockstop"))
end = ent;
else if(equal(target, "counter_off"))
end = ent;
else if(equal(target, "clockstopbutton"))
end = ent;

ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_button");
}

if(start && end)
{
new map[32];
get_mapname(map, 31);

if(equali("surf_", map, 5))
return 0;

_get_brush_entity_origin(start, start_origin);
_get_brush_entity_origin(end, end_origin);

return 1;
}
return 0;
}

public plugin_natives()
{
register_library("kz");
register_native("IsPlayerStarted", "native_is_player_started");
register_native("IsPlayerFinished", "native_is_player_finish");

// This has to be style 1. It be to complicated if it was style 0;
register_native("kz_ShowSyncHudMsg", "native_showhud", 1);
register_native("kz_ColorChat", "native_color_print_chat", 1);
}

public native_color_print_chat(player, color_type, const message[], {Float,Sql,Result,_}:...)
{
new nums = numargs();

if(nums < 3)
return log_error(AMX_ERR_NATIVE, "Bad native parameters");

new i;
for(i = 3; i <= nums; i++)
param_convert(i);

static msg[191];
vformat(msg, 190, message, 4);

if(player > 0 && player <= maxplayers)
_color_chat(player, color_type, msg);
else if(!player)
{
static players[32], nums, index;
get_players(players, nums);

for(new i = 0; i < nums; i++)
{
index = players[i];
_color_chat(index, color_type, msg);
}
}
return PLUGIN_CONTINUE;
}

public native_showhud(player, r, g, b, Float:x, Float:y, const message[], {Float,Sql,Result,_}:...)
{
new nums = numargs();

if(nums < 7)
return log_error(AMX_ERR_NATIVE, "Bad native parameters");

new i;
for(i = 7; i <= nums; i++)
param_convert(i);

static msg[191];
vformat(msg, 190, message, 8);
kz_show_hud(player, r, g, b, x, y, msg);

return PLUGIN_CONTINUE;
}

public native_is_player_started(id, nums)
{
if(nums != 1)
return log_error(AMX_ERR_NATIVE, "Bad native parameters");

return Started[get_param(1)];
}

public native_is_player_finish(id, nums)
{
if(nums != 1)
return log_error(AMX_ERR_NATIVE, "Bad native parameters");

return completed_climb[get_param(1)];
}

public client_putinserver(id)
{
if(!get_pcvar_num(kz_enabled))
return;

set_task(10.0, "advert_help", id);
}

public client_connect(id)
{
if(!get_pcvar_num(kz_enabled))
return;

Started[id] = false;
completed_climb[id] = false;

Timer[id] = 0.0;
cp_count[id] = -1;
PauseTime[id] = 0.0;

kz_died[id] = false;
gc_count[id] = 0;
cpCount[id] = 0;
}

public advert_help(id)
{
_color_chat(id, green, "[kz] For kz commands please type say /help");
}

public cmdPause(id)
{
if(get_pcvar_num(kz_enabled))
{
if(Started[id])
{
new temp = IsPaused[id];
if(!temp || temp == 2)
{
PauseTime[id] += (thetime() - Timer[id]);
IsPaused[id] = 1;
Timer[id] = 0.0;

kz_show_hud(id, 128, 0, 128, 0.43, 0.89, "PAUSED");
set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN);

SetPlayerNotSolid(id);
SetPlayerPause(id, 1);
}
else
{
IsPaused[id] = (IsPaused[id] == 1) ? 2 : 1;
Timer[id] = thetime();

kz_show_hud(id, 128, 0, 128, 0.44, 0.89, "UNPAUSED");
set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN);

SetPlayerSolid(id);
SetPlayerPause(id);
}
}
else
{
kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You must start the timer before you can pause.");
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}

public cmdReset(id)
{
if(get_pcvar_num(kz_enabled))
{
Started[id] = false;
reset_data(id);
ExecuteForward(kz_fwd_reset, fwd_result, id);
spawn_player(id);

return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}

public reset_data(id)
{
Timer[id] = 0.0;
PauseTime[id] = 0.0;
cpCount[id] = 0;
gc_count[id] = 0;
}

public cmdHelp(id)
{
if(get_pcvar_num(kz_enabled))
{
show_motd(id, help_file);
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}

public PreThink(id)
{
if(!get_pcvar_num(kz_enabled) && !is_user_alive(id))
return FMRES_IGNORED;

if(pev(id, pev_button) & IN_USE)
{
static button, body;
get_user_aiming(id, button, body);

if(button > maxplayers)
{
if(pev_valid(button))
{
static Float:origin[3];
pev(id, pev_origin, origin);

if(!Started[id] && button == start)
{
if(vector_distance(origin, start_origin) <= DISTANCE_FROM_BUTTON)
{
start_climb(id, origin);
}
}
else if(button == end)
{
if(vector_distance(origin, end_origin) <= DISTANCE_FROM_BUTTON)
{
finish_climb(id);
}
}
}
}
}

// Checks if a player is in noclip. Do not allow him to continue the timer.
/*if(Started[id] && pev(id, pev_movetype) == MOVETYPE_NOCLIP)
{
reset_data(id);
Started[id] = false;
kz_ColorChat(id, green, "[kz] NoClip Detected, Timer Stopped.");
}*/
return FMRES_IGNORED;
}

is_not_alive(id)
{
kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You must be alive to execute this command.");
}

start_climb(id, Float:origin[3])
{
static Float:angle[3];
pev(id, pev_angles, angle);

Started[id] = true;
spawn_player(id); // Remove any long jump, etc...

set_pev(id, pev_angles, angle);
set_pev(id, pev_origin, origin);
delay_duck(id);

dllfunc(DLLFunc_Use, start, id); // Make sure the map timer starts
Timer[id] = thetime();

kz_show_hud(id, 128, 0, 128, 0.38, 0.89, "Timer started. Go Go Go!!!");
client_cmd(id, "spk scientist/c3a2_sci_portopen");

if(get_pcvar_num(kz_CpPrice))
cs_set_user_money(id, get_pcvar_num(mp_startmoney));

cp_count[id] = -1;
IsPaused[id] = 0;

ExecuteForward(kz_fwd_start, fwd_result, id);

cs_set_user_deaths(id, 0);
set_pev(id, pev_frags, 0.0);
}

finish_climb(id)
{
if(!is_user_alive(id))
{
is_not_alive(id);
return;
}

if(!completed_climb[id] || Started[id])
{
completed_climb[id] = true;

static time;

if(Started[id])
{
dllfunc(DLLFunc_Use, end, id); // Make sure the map timer stops

time = floatround((thetime() - Timer[id]) + PauseTime[id]);

_convert_time(id, time);

client_cmd(id, "spk woop");
kz_show_hud(id, 128, 0, 128, 0.46, 0.89, "Finished.");
}

Started[id] = false;

ExecuteForward(kz_fwd_finish, fwd_result, id, time, cpCount[id], gc_count[id]);
reset_data(id);
}
}

_convert_time(id, time)
{
static TimeMsg[128];

static name[32];
get_user_name(id, name, 31);

// Display to everyone with server language.
get_time_length(0, time, timeunit_seconds, TimeMsg, 127);
kz_ColorChat(0, team, "[kz] It took %s %s to complete the climb.", name, TimeMsg);
}

public cmdCP(id)
{
if(get_pcvar_num(kz_enabled))
{
if(is_user_alive(id))
{
if(IsPaused[id] == 1)
{
paused(id);
return PLUGIN_HANDLED;
}

if(get_pcvar_num(kz_CpPrice))
{
new money = cs_get_user_money(id);

if(get_pcvar_num(kz_CpPrice) <= money)
cs_set_user_money(id, money - get_pcvar_num(kz_CpPrice));
else
{
kz_ShowSyncHudMsg(id, 128, 0, 128, 0.25, 0.89, "You don't have enough cash for more checkpoints. $%i", get_pcvar_num(kz_CpPrice));
return PLUGIN_HANDLED;
}
}

static vel[3];
pev(id, pev_velocity, vel);

if(vel[2] >= 0 && pev(id, pev_flags) & FL_ONGROUND)
{
cp_count[id]++;
cpCount[id]++;

if(cp_count[id] == MAX_CP)
cp_count[id] = 0;

pev(id, pev_origin, cp_location[id][cp_count[id]]);
kz_ShowSyncHudMsg(id, 128, 0, 128, 0.41, 0.89, "Checkpoint saved. %i", cpCount[id]);
}
else
{
kz_show_hud(id, 128, 0, 128, 0.32, 0.89, "You can't make checkpoints while falling.");
}
}
else
{
is_not_alive(id);
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}

paused(id)
{
kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You can't execute this command while paused.");
}

public cmdTele(id)
{
if(get_pcvar_num(kz_enabled))
{
if(!is_user_alive(id))
{
is_not_alive(id);
return PLUGIN_HANDLED;
}

if(IsPaused[id] == 1)
{
paused(id);
return PLUGIN_HANDLED;
}

if(cp_count[id] != -1)
{
static Float:origin[3], players[32], nums, person, i, Float:cp_origin[3];
get_players(players, nums, "ac");
SetPlayerNotSolid(id);

cp_origin = cp_location[id][cp_count[id]];

for(i = 0; i < nums; i++)
{
person = players[i];

if(id == person)
continue;

pev(person, pev_origin, origin);

if(vector_distance(origin, cp_origin) <= 74.0)
{
SetPlayerNotSolid(person);
break;
}
}

set_pev(id, pev_velocity, {0, 0, 0}); // Reset velocity
set_pev(id, pev_origin, cp_origin);
kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You have been teleported to your checkpoint.");
delay_duck(id);

gc_count[id]++;
}

return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}

delay_duck(id)
{
set_task(0.01, "force_duck", id);
_fm_set_entity_flags(id, FL_DUCKING, 1);
}

public force_duck(id)
{
_fm_set_entity_flags(id, FL_DUCKING, 1);
}

public cmdStuck(id)
{
if(!get_pcvar_num(kz_enabled))
return PLUGIN_CONTINUE;

if(!is_user_alive(id))
{
is_not_alive(id);
return PLUGIN_HANDLED;
}

if(IsPaused[id] == 1)
{
paused(id);
return PLUGIN_HANDLED;
}

if(cp_count[id] == -1)
return PLUGIN_HANDLED;

if(cp_count[id] > 0)
cp_count[id]--;

set_pev(id, pev_velocity, {0, 0, 0}); // Reset velocity
kz_show_hud(id, 128, 0, 128, 0.30, 0.89, "Your previous checkpoint has been restored.");
set_pev(id, pev_origin, cp_location[id][cp_count[id]]);
delay_duck(id);
return PLUGIN_HANDLED;
}

#if defined DEBUG
public cmdEnt(id)
{
new target_id, body;
get_user_aiming(id, target_id, body);

if(target_id > maxplayers)
{
new class[32];
pev(target_id, pev_classname, class, 31);

new target[32];
pev(target_id, pev_target, target, 31);

client_print(id, print_chat, "ent id: %i classname: %s target: %s", target_id, class, target);
}
return PLUGIN_HANDLED;
}
#endif

Float:thetime()
{
new Float:engine_time;
global_get(glb_time, engine_time);
return engine_time;
}

_color_chat(id, color, message[])
{
if(!id)
return;

if(is_user_connected(id))
{
static msg[192];

switch(color)
{
case 1:
msg = "^x03";
case 2:
msg = "^x04";
}

add(msg, 191, message);

message_begin(MSG_ONE, SayText, {0, 0, 0}, id);
write_byte(id);
write_string(msg);
message_end();
}
}

_fm_set_entity_flags(index, flag, onoff) // Taken from fakemeta_util
{
new flags = pev(index, pev_flags);

if ((flags & flag) > 0)
return onoff == 1 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags - flag);
else
return onoff == 0 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags + flag);

return 0;
}

public cmdTeleport(id, level, cid)
{
if(!get_pcvar_num(kz_enabled))
return PLUGIN_CONTINUE;

if(!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED;

new arg[32], arg1[32];
read_argv(1, arg, 31);
read_argv(2, arg1, 31);

new person = cmd_target(id, arg, 12);
new player = cmd_target(id, arg1, 12);

if(!person || !player)
return PLUGIN_HANDLED;

new Float:Origin[3];

pev(player, pev_origin, Origin);
set_pev(person, pev_origin, Origin);
SetPlayerNotSolid(player);
SetPlayerNotSolid(person);
delay_duck(person);

new name[32];
new name1[32];

get_user_name(person, name, 31);
get_user_name(person, name1, 31);

console_print(id, "[kz] You teleport %s to player %s position.", name, name1);
return PLUGIN_HANDLED;
}

public DeathMessage(killer, victim, headshot, weaponname[])
{
if(get_pcvar_num(kz_enabled))
kz_died[victim] = true;
}

public PostSpawn(id)
{
if(!get_pcvar_num(kz_enabled))
return;

if(!is_user_alive(id))
return;

if(kz_died[id])
{
kz_died[id] = false;
cmdTele(id);
}
}

kz_show_hud(id, r, g, b, Float:x, Float:y, const msg[])
{
if(is_user_connected(id)) // 128, 0, 128
{
set_hudmessage(r, g, b, x, y, 0, 0.0, 3.0, 0.0, 0.0, 4);
ShowSyncHudMsg(id, MsgSync, "%s", msg);
}
}

public fm_ClientKill(id)
{
if(get_pcvar_num(kz_enabled))
return FMRES_SUPERCEDE;

return FMRES_IGNORED;
}

public hudtime()
{
if(get_pcvar_num(kz_enabled))
{
static Players[32], count, i, index;
get_players(Players, count, "ach");

for(i = 0; i < count; i++)
{
index = Players[i];

message_begin(MSG_ONE, RoundTime, {0, 0, 0}, index);
write_short(func_29(index) + 1);
message_end();
}
}
}

func_29(id)
{
static Float:blah;
blah = 0.0;

switch(IsPaused[id])
{
case 0:
{
if(Timer[id])
blah = thetime() - Timer[id];
}
case 1:
{
blah = PauseTime[id];
}
case 2: // Player continue after paused.
{
blah = PauseTime[id] + (thetime() - Timer[id]);
}
}
return floatround(blah);
}

public ct(id)
{
if(cs_get_user_team(id)==CS_TEAM_SPECTATOR)
{
new text[100]
cs_set_user_team(id,CS_TEAM_CT)
format(text,99,"^x04[kz]You were carried for command ct")
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)
write_byte(id)
write_string(text)
message_end()
}
}

pub lic spec(id)
{
if(cs_get_user_team(id)!=CS_TEAM_SPECTATOR)
{
new text[100]
cs_set_user_team(id,CS_TEAM_SPECTATOR)
set_pev(id,pev_deadflag,DEAD_DISCARDBODY)
format(text,99,"^x04[kz]You were carried for command spectators")
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)
write_byte(id)
write_string(text)
message_end()
}
}


Раскручиваю сайты,ставлю трекера на хостинг.Всё бесплатно.Если заинтересовало,то моя аська 400538001


Сообщение отредактировал defaultNick8433 - Пятница, 31.07.2009, 09:58:42
 
HafnerДата: Пятница, 31.07.2009, 13:01:17 | Сообщение # 5
Лейтенант
Группа: Пользователи
Сообщений: 46
Репутация: 0
Статус: Не в сети
Не робит, модели не исчезают, бред какой-то...

А есть ещё варианты перевода игрока в спектаторы?

 
defaultNick8433Дата: Пятница, 31.07.2009, 13:22:29 | Сообщение # 6
Генерал-полковник
Группа: Скриптеры
Сообщений: 806
Репутация: 19
Статус: Не в сети
Может сам kz mod не позволяет этого сделать,перехода,потому что там ведь,если сидишь какое-то время в спектах,тебя этот мод автоматом переносит за кт.Может в этом моменте и несостыковычка получается.

Добавлено (2009-07-31, 1:22 Pm)
---------------------------------------------

Code
#include <amxmodx>  
#include <amxmisc>  
#include <kz>  
#include <respawn>  
#include <time>  
#include <fun>  
#include <engine>  

//#define DEBUG  

#define MAX_CP 25  
#define DISTANCE_FROM_BUTTON 95.0  

// Check Point  
new cpCount[33];  
new cp_count[33] = {-1, ...};  
new Float:cp_location[33][MAX_CP][3];  

new healths

// Teleport Count  
new gc_count[33];  

// Is Player started?  
new bool:Started[33];  

// Timer  
new Float:Timer[33];  

// Pause Hold timer  
new IsPaused[33];  
new Float:PauseTime[33];  

// Completed Climb?  
new bool:completed_climb[33];  

// Hold the entity id and origin of the start and end buttons  
new start;  
new Float:start_origin[3];  

new end;  
new Float:end_origin[3];  

// Maximum numbers of slots  
new maxplayers;  

// Pointer Cvar  
new kz_enabled;  
new kz_CpPrice;  
new mp_startmoney;  

// Color chat  
new SayText;  
new RoundTime;  

new bool:kz_died[33];  

// Hud Stuff  
new MsgSync;  

// Forwards  
new kz_fwd_init;  
new kz_fwd_start;  
new kz_fwd_finish;  
new kz_fwd_reset;  
new fwd_result;  

new help_file[64];  

// Map Exploits.  
// One in kz_man_redrock. If they go into low gravity room then. Stop timer????  
// What to do ? When they touch that trigger teleport disable the teleport and check points?  

public plugin_init()  
{  
register_plugin("KZ Main", KZ_VERSION, "teame06");  
register_clcmd("say /spec","spec")  
register_clcmd("say /ct","ct")  
healths=register_cvar("hl_user","1")

// Forwards  
kz_fwd_init = CreateMultiForward("kz_Init", ET_IGNORE, FP_CELL);  

// Cvars  
register_cvar("kz_version", KZ_VERSION, FCVAR_SERVER|FCVAR_SPONLY);  
kz_enabled = register_cvar("kz_enabled", "1", FCVAR_SERVER|FCVAR_SPONLY);  
kz_CpPrice = register_cvar("kz_cp_price", "0");  
register_cvar("kz_boosttime", "45");  
register_cvar("kz_autojoin", "0");  

#if defined DEBUG  
register_clcmd("show_ent", "cmdEnt");  
#endif  
}  

public plugin_cfg()  
{  
// Configs  
new config[64];  
get_configsdir(config, 63);  

server_cmd("exec %s/kz/kz.cfg", config);  
server_exec();  

set_task(6.5, "kz_start");  
}  

public kz_start()  
{  
if(get_pcvar_num(kz_enabled))  
{  
find_buttons();  
ExecuteForward(kz_fwd_init, fwd_result, _ON);  
} else {  
set_cvar_num("kz_enabled", 0);  
ExecuteForward(kz_fwd_init, fwd_result, _OFF);  
}  
}  

public kz_Init(_state)  
{  
if(!_state)  
{  
pause("a");  
return;  
}  

// Forwards  
kz_fwd_start = CreateMultiForward("kz_StartClimb", ET_IGNORE, FP_CELL);  
kz_fwd_finish = CreateMultiForward("kz_FinishClimb", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL);  
kz_fwd_reset = CreateMultiForward("kz_ResetClimb", ET_IGNORE, FP_CELL);  

// Make a checkpoint  
//new _check[] = "Makes  
register_saycmd("cp", "cmdCP", -1, "");  
register_saycmd("checkpoint", "cmdCP", -1, "");  
register_saycmd("check", "cmdCP", -1, "");  

// Teleport to checkpoint  
register_saycmd("tele", "cmdTele", -1, "");  
register_saycmd("gc", "cmdTele", -1, "");  
register_saycmd("gocheck", "cmdTele", -1, "");  
register_saycmd("tp", "cmdTele", -1, "");  

// Timer stuff  
register_saycmd("pause", "cmdPause", -1, "");  
register_saycmd("reset", "cmdReset", -1, "");  
register_saycmd("start", "cmdReset", -1, "");  

// Previous Check Point  
register_saycmd("stuck", "cmdStuck", -1, "");  
register_saycmd("unstuck", "cmdStuck", -1, "");  

// Misc  
register_saycmd("help", "cmdHelp", -1, "");  

// Admin Commands  
register_clcmd("amx_teleport", "cmdTeleport", ADMIN_BAN, "- amx_teleport <#userid|name|steamid> <#userid|name|steamid>");  

// Forwards  
register_forward(FM_PlayerPreThink, "PreThink", 1);  
register_forward(FM_ClientKill, "fm_ClientKill");  

// Dictionary files  
register_dictionary("time.txt");  

maxplayers = get_maxplayers();  
MsgSync = CreateHudSyncObj();  
SayText = get_user_msgid("SayText"); // Color messages  
RoundTime = get_user_msgid("RoundTime"); // Climb Timer  
mp_startmoney = get_cvar_pointer("mp_startmoney");  

get_configsdir(help_file, 63);  
formatex(help_file, 63, "%s/kz/help.txt", help_file);  

set_task(0.5, "hudtime", _, _, _, "b");  

set_cvar_num("mp_limitteams", 0);  
set_cvar_num("mp_autoteambalance", 0);  
set_cvar_num("mp_freezetime", 0);  
set_cvar_num("sv_airaccelerate", 10);  
set_cvar_num("sv_restartround", 1);  
set_cvar_num("respawn_enabled", 1); // Enables the respawn plugin on run.  
server_exec();  
}  

// This function was created to detect which maps are KZ  
// but to also cache some button information for speed.  
find_buttons()  
{  
new ent = engfunc(EngFunc_FindEntityByString, -1, "classname", "func_button");  

while(ent > 0)  
{  
new target[32];  
pev(ent, pev_target, target, 31);  

if(equal(target, "counter_start"))  
start = ent;  
else if(equal(target, "clockstartbutton"))  
start = ent;  
else if(equal(target, "firsttimerelay"))  
start = ent;  

if(equal(target, "clockstop"))  
end = ent;  
else if(equal(target, "counter_off"))  
end = ent;  
else if(equal(target, "clockstopbutton"))  
end = ent;  

ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_button");  
}  

if(start && end)  
{  
new map[32];  
get_mapname(map, 31);  

if(equali("surf_", map, 5))  
return 0;  

_get_brush_entity_origin(start, start_origin);  
_get_brush_entity_origin(end, end_origin);  

return 1;  
}  
return 0;  
}  

public plugin_natives()  
{  
register_library("kz");  
register_native("IsPlayerStarted", "native_is_player_started");  
register_native("IsPlayerFinished", "native_is_player_finish");  

// This has to be style 1. It be to complicated if it was style 0;  
register_native("kz_ShowSyncHudMsg", "native_showhud", 1);  
register_native("kz_ColorChat", "native_color_print_chat", 1);  
}  

public native_color_print_chat(player, color_type, const message[], {Float,Sql,Result,_}:...)  
{  
new nums = numargs();  

if(nums < 3)  
return log_error(AMX_ERR_NATIVE, "Bad native parameters");  

new i;  
for(i = 3; i <= nums; i++)  
param_convert(i);  

static msg[191];  
vformat(msg, 190, message, 4);  

if(player > 0 && player <= maxplayers)  
_color_chat(player, color_type, msg);  
else if(!player)  
{  
static players[32], nums, index;  
get_players(players, nums);  

for(new i = 0; i < nums; i++)  
{  
index = players[i];  
_color_chat(index, color_type, msg);  
}  
}  
return PLUGIN_CONTINUE;  
}  

public native_showhud(player, r, g, b, Float:x, Float:y, const message[], {Float,Sql,Result,_}:...)  
{  
new nums = numargs();  

if(nums < 7)  
return log_error(AMX_ERR_NATIVE, "Bad native parameters");  

new i;  
for(i = 7; i <= nums; i++)  
param_convert(i);  

static msg[191];  
vformat(msg, 190, message, 8);  
kz_show_hud(player, r, g, b, x, y, msg);  

return PLUGIN_CONTINUE;  
}  

public native_is_player_started(id, nums)  
{  
if(nums != 1)  
return log_error(AMX_ERR_NATIVE, "Bad native parameters");  

return Started[get_param(1)];  
}  

public native_is_player_finish(id, nums)  
{  
if(nums != 1)  
return log_error(AMX_ERR_NATIVE, "Bad native parameters");  

return completed_climb[get_param(1)];  
}  

public client_putinserver(id)  
{  
if(!get_pcvar_num(kz_enabled))  
return;  

set_task(10.0, "advert_help", id);  
}  

public client_connect(id)  
{  
if(!get_pcvar_num(kz_enabled))  
return;  

Started[id] = false;  
completed_climb[id] = false;  

Timer[id] = 0.0;  
cp_count[id] = -1;  
PauseTime[id] = 0.0;  

kz_died[id] = false;  
gc_count[id] = 0;  
cpCount[id] = 0;  
}  

public advert_help(id)  
{  
_color_chat(id, green, "[kz] For kz commands please type say /help");  
}  

public cmdPause(id)  
{  
if(get_pcvar_num(kz_enabled))  
{  
if(Started[id])  
{  
new temp = IsPaused[id];  
if(!temp || temp == 2)  
{  
PauseTime[id] += (thetime() - Timer[id]);  
IsPaused[id] = 1;  
Timer[id] = 0.0;  

kz_show_hud(id, 128, 0, 128, 0.43, 0.89, "PAUSED");  
set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN);  

SetPlayerNotSolid(id);  
SetPlayerPause(id, 1);  
}  
else  
{  
IsPaused[id] = (IsPaused[id] == 1) ? 2 : 1;  
Timer[id] = thetime();  

kz_show_hud(id, 128, 0, 128, 0.44, 0.89, "UNPAUSED");  
set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN);  

SetPlayerSolid(id);  
SetPlayerPause(id);  
}  
}  
else  
{  
kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You must start the timer before you can pause.");  
}  
return PLUGIN_HANDLED;  
}  
return PLUGIN_CONTINUE;  
}  

public cmdReset(id)  
{  
if(get_pcvar_num(kz_enabled))  
{  
Started[id] = false;  
reset_data(id);  
ExecuteForward(kz_fwd_reset, fwd_result, id);  
spawn_player(id);  

return PLUGIN_HANDLED;  
}  
return PLUGIN_CONTINUE;  
}  

public reset_data(id)  
{  
Timer[id] = 0.0;  
PauseTime[id] = 0.0;  
cpCount[id] = 0;  
gc_count[id] = 0;  
}  

public cmdHelp(id)  
{  
if(get_pcvar_num(kz_enabled))  
{  
show_motd(id, help_file);  
return PLUGIN_HANDLED;  
}  
return PLUGIN_CONTINUE;  
}  

public PreThink(id)  
{  
if(!get_pcvar_num(kz_enabled) && !is_user_alive(id))  
return FMRES_IGNORED;  

if(pev(id, pev_button) & IN_USE)  
{  
static button, body;  
get_user_aiming(id, button, body);  

if(button > maxplayers)  
{  
if(pev_valid(button))  
{  
static Float:origin[3];  
pev(id, pev_origin, origin);  

if(!Started[id] && button == start)  
{  
if(vector_distance(origin, start_origin) <= DISTANCE_FROM_BUTTON)  
{  
start_climb(id, origin);  
}  
}  
else if(button == end)  
{  
if(vector_distance(origin, end_origin) <= DISTANCE_FROM_BUTTON)  
{  
finish_climb(id);  
}  
}  
}  
}  
}  

// Checks if a player is in noclip. Do not allow him to continue the timer.  
/*if(Started[id] && pev(id, pev_movetype) == MOVETYPE_NOCLIP)  
{  
reset_data(id);  
Started[id] = false;  
kz_ColorChat(id, green, "[kz] NoClip Detected, Timer Stopped.");  
}*/  
return FMRES_IGNORED;  
}  

is_not_alive(id)  
{  
kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You must be alive to execute this command.");  
}  

start_climb(id, Float:origin[3])  
{  
static Float:angle[3];  
pev(id, pev_angles, angle);  

Started[id] = true;  
spawn_player(id); // Remove any long jump, etc...  

set_pev(id, pev_angles, angle);  
set_pev(id, pev_origin, origin);  
delay_duck(id);  

dllfunc(DLLFunc_Use, start, id); // Make sure the map timer starts  
Timer[id] = thetime();  

kz_show_hud(id, 128, 0, 128, 0.38, 0.89, "Timer started. Go Go Go!!!");  
client_cmd(id, "spk scientist/c3a2_sci_portopen");  

if(get_pcvar_num(kz_CpPrice))  
cs_set_user_money(id, get_pcvar_num(mp_startmoney));  

cp_count[id] = -1;  
IsPaused[id] = 0;  

ExecuteForward(kz_fwd_start, fwd_result, id);  

cs_set_user_deaths(id, 0);  
set_pev(id, pev_frags, 0.0);  
}  

finish_climb(id)  
{  
if(!is_user_alive(id))  
{  
is_not_alive(id);  
return;  
}  

if(!completed_climb[id] || Started[id])  
{  
completed_climb[id] = true;  

static time;  

if(Started[id])  
{  
dllfunc(DLLFunc_Use, end, id); // Make sure the map timer stops  

time = floatround((thetime() - Timer[id]) + PauseTime[id]);  

_convert_time(id, time);  

client_cmd(id, "spk woop");  
kz_show_hud(id, 128, 0, 128, 0.46, 0.89, "Finished.");  
}  

Started[id] = false;  

ExecuteForward(kz_fwd_finish, fwd_result, id, time, cpCount[id], gc_count[id]);  
reset_data(id);  
}  
}  

_convert_time(id, time)  
{  
static TimeMsg[128];  

static name[32];  
get_user_name(id, name, 31);  

// Display to everyone with server language.  
get_time_length(0, time, timeunit_seconds, TimeMsg, 127);  
kz_ColorChat(0, team, "[kz] It took %s %s to complete the climb.", name, TimeMsg);  
}  

public cmdCP(id)  
{  
if(get_pcvar_num(kz_enabled))  
{  
if(is_user_alive(id))  
{  
if(IsPaused[id] == 1)  
{  
paused(id);  
return PLUGIN_HANDLED;  
}  

if(get_pcvar_num(kz_CpPrice))  
{  
new money = cs_get_user_money(id);  

if(get_pcvar_num(kz_CpPrice) <= money)  
cs_set_user_money(id, money - get_pcvar_num(kz_CpPrice));  
else  
{  
kz_ShowSyncHudMsg(id, 128, 0, 128, 0.25, 0.89, "You don't have enough cash for more checkpoints. $%i", get_pcvar_num(kz_CpPrice));  
return PLUGIN_HANDLED;  
}  
}  

static vel[3];  
pev(id, pev_velocity, vel);  

if(vel[2] >= 0 && pev(id, pev_flags) & FL_ONGROUND)  
{  
cp_count[id]++;  
cpCount[id]++;  

if(cp_count[id] == MAX_CP)  
cp_count[id] = 0;  

pev(id, pev_origin, cp_location[id][cp_count[id]]);  
kz_ShowSyncHudMsg(id, 128, 0, 128, 0.41, 0.89, "Checkpoint saved. %i", cpCount[id]);  
}  
else  
{  
kz_show_hud(id, 128, 0, 128, 0.32, 0.89, "You can't make checkpoints while falling.");  
}  
}  
else  
{  
is_not_alive(id);  
}  
return PLUGIN_HANDLED;  
}  
return PLUGIN_CONTINUE;  
}  

paused(id)  
{  
kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You can't execute this command while paused.");  
}  

public cmdTele(id)  
{  
if(get_pcvar_num(kz_enabled))  
{  
if(!is_user_alive(id))  
{  
is_not_alive(id);  
return PLUGIN_HANDLED;  
}  

if(IsPaused[id] == 1)  
{  
paused(id);  
return PLUGIN_HANDLED;  
}  

if(cp_count[id] != -1)  
{  
static Float:origin[3], players[32], nums, person, i, Float:cp_origin[3];  
get_players(players, nums, "ac");  
SetPlayerNotSolid(id);  

cp_origin = cp_location[id][cp_count[id]];  

for(i = 0; i < nums; i++)  
{  
person = players[i];  

if(id == person)  
continue;  

pev(person, pev_origin, origin);  

if(vector_distance(origin, cp_origin) <= 74.0)  
{  
SetPlayerNotSolid(person);  
break;  
}  
}  

set_pev(id, pev_velocity, {0, 0, 0}); // Reset velocity  
set_pev(id, pev_origin, cp_origin);  
kz_show_hud(id, 128, 0, 128, 0.29, 0.89, "You have been teleported to your checkpoint.");  
delay_duck(id);  

gc_count[id]++;  
}  

return PLUGIN_HANDLED;  
}  
return PLUGIN_CONTINUE;  
}  

delay_duck(id)  
{  
set_task(0.01, "force_duck", id);  
_fm_set_entity_flags(id, FL_DUCKING, 1);  
}  

public force_duck(id)  
{  
_fm_set_entity_flags(id, FL_DUCKING, 1);  
}  

public cmdStuck(id)  
{  
if(!get_pcvar_num(kz_enabled))  
return PLUGIN_CONTINUE;  

if(!is_user_alive(id))  
{  
is_not_alive(id);  
return PLUGIN_HANDLED;  
}  

if(IsPaused[id] == 1)  
{  
paused(id);  
return PLUGIN_HANDLED;  
}  

if(cp_count[id] == -1)  
return PLUGIN_HANDLED;  

if(cp_count[id] > 0)  
cp_count[id]--;  

set_pev(id, pev_velocity, {0, 0, 0}); // Reset velocity  
kz_show_hud(id, 128, 0, 128, 0.30, 0.89, "Your previous checkpoint has been restored.");  
set_pev(id, pev_origin, cp_location[id][cp_count[id]]);  
delay_duck(id);  
return PLUGIN_HANDLED;  
}  

#if defined DEBUG  
public cmdEnt(id)  
{  
new target_id, body;  
get_user_aiming(id, target_id, body);  

if(target_id > maxplayers)  
{  
new class[32];  
pev(target_id, pev_classname, class, 31);  

new target[32];  
pev(target_id, pev_target, target, 31);  

client_print(id, print_chat, "ent id: %i classname: %s target: %s", target_id, class, target);  
}  
return PLUGIN_HANDLED;  
}  
#endif  

Float:thetime()  
{  
new Float:engine_time;  
global_get(glb_time, engine_time);  
return engine_time;  
}  

_color_chat(id, color, message[])  
{  
if(!id)  
return;  

if(is_user_connected(id))  
{  
static msg[192];  

switch(color)  
{  
case 1:  
msg = "^x03";  
case 2:  
msg = "^x04";  
}  

add(msg, 191, message);  

message_begin(MSG_ONE, SayText, {0, 0, 0}, id);  
write_byte(id);  
write_string(msg);  
message_end();  
}  
}  

_fm_set_entity_flags(index, flag, onoff) // Taken from fakemeta_util  
{  
new flags = pev(index, pev_flags);  

if ((flags & flag) > 0)  
return onoff == 1 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags - flag);  
else  
return onoff == 0 ? 2 : 1 + 0 * set_pev(index, pev_flags, flags + flag);  

return 0;  
}  

public cmdTeleport(id, level, cid)  
{  
if(!get_pcvar_num(kz_enabled))  
return PLUGIN_CONTINUE;  

if(!cmd_access(id, level, cid, 1))  
return PLUGIN_HANDLED;  

new arg[32], arg1[32];  
read_argv(1, arg, 31);  
read_argv(2, arg1, 31);  

new person = cmd_target(id, arg, 12);  
new player = cmd_target(id, arg1, 12);  

if(!person || !player)  
return PLUGIN_HANDLED;  

new Float:Origin[3];  

pev(player, pev_origin, Origin);  
set_pev(person, pev_origin, Origin);  
SetPlayerNotSolid(player);  
SetPlayerNotSolid(person);  
delay_duck(person);  

new name[32];  
new name1[32];  

get_user_name(person, name, 31);  
get_user_name(person, name1, 31);  

console_print(id, "[kz] You teleport %s to player %s position.", name, name1);  
return PLUGIN_HANDLED;  
}  

public DeathMessage(killer, victim, headshot, weaponname[])  
{  
if(get_pcvar_num(kz_enabled))  
kz_died[victim] = true;  
}  

public PostSpawn(id)  
{  
if(!get_pcvar_num(kz_enabled))  
return;  

if(!is_user_alive(id))  
return;  

if(kz_died[id])  
{  
kz_died[id] = false;  
cmdTele(id);  
}  
}  

kz_show_hud(id, r, g, b, Float:x, Float:y, const msg[])  
{  
if(is_user_connected(id)) // 128, 0, 128  
{  
set_hudmessage(r, g, b, x, y, 0, 0.0, 3.0, 0.0, 0.0, 4);  
ShowSyncHudMsg(id, MsgSync, "%s", msg);  
}  
}  

public fm_ClientKill(id)  
{  
if(get_pcvar_num(kz_enabled))  
return FMRES_SUPERCEDE;  

return FMRES_IGNORED;  
}  

public hudtime()  
{  
if(get_pcvar_num(kz_enabled))  
{  
static Players[32], count, i, index;  
get_players(Players, count, "ach");  

for(i = 0; i < count; i++)  
{  
index = Players[i];  

message_begin(MSG_ONE, RoundTime, {0, 0, 0}, index);  
write_short(func_29(index) + 1);  
message_end();  
}  
}  
}  

func_29(id)  
{  
static Float:blah;  
blah = 0.0;  

switch(IsPaused[id])  
{  
case 0:  
{  
if(Timer[id])  
blah = thetime() - Timer[id];  
}  
case 1:  
{  
blah = PauseTime[id];  
}  
case 2: // Player continue after paused.  
{  
blah = PauseTime[id] + (thetime() - Timer[id]);  
}  
}  
return floatround(blah);  
}  
public ct(id)  
{  
if(cs_get_user_team(id)==CS_TEAM_SPECTATOR)  
{  
new text[100]  
cs_set_user_team(id,CS_TEAM_CT)  
format(text,99,"^x04[kz]You were carried for command ct")  
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)  
write_byte(id)  
write_string(text)  
message_end()  
}  
}
public spec(id)  
{  
if(cs_get_user_team(id)!=CS_TEAM_SPECTATOR)  
{  
new text[100]  
user_kill(id)
cs_set_user_team(id,CS_TEAM_SPECTATOR)  
if(get_user_deaths(id)-get_pcvar_num(healths))
return PLUGIN_HANDLED
format(text,99,"^x04[kz]You were carried for command spectators")  
message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)  
write_byte(id)  
write_string(text)  
message_end()  
}  
}

Теперь попробуй,переходы сделал по другой анологии.


Раскручиваю сайты,ставлю трекера на хостинг.Всё бесплатно.Если заинтересовало,то моя аська 400538001
 
HafnerДата: Пятница, 31.07.2009, 20:02:47 | Сообщение # 7
Лейтенант
Группа: Пользователи
Сообщений: 46
Репутация: 0
Статус: Не в сети
Нет, не выходит. Скорее всего вы правы, тут речь о другом плагине, который контролирует респ...
Я уже из 3-х других плагинов код брал, происходит тоже самое=/
Уже даже сейв позиции сделал, но при уходе в спек модели по прежнему не исчезают :(
Code
/*================
Spectator controls functions
================*/
public cmdCT(id)   
{   
   if(get_pcvar_num(kz_enabled))   
          {   
                   if ( !is_user_alive(id) )    
                   {   
     if( Started[id] )
     {
      if( IsPaused[id] == 1 )
      {
       IsPaused[id] = (IsPaused[id] == 1) ? 2 : 1;
       Timer[id] = thetime();
      }
     }     
     cs_set_user_team(id, CS_TEAM_CT);
     ExecuteHamB(Ham_CS_RoundRespawn, id);
     set_pev(id, pev_health, g_spechp[id]);
                   set_pev(id, pev_origin, g_player_specposition[id]);
                   }   
            return PLUGIN_HANDLED;   
   }   
          return PLUGIN_CONTINUE;   
}   

public cmdSpec(id)   
{   
   if(get_pcvar_num(kz_enabled))   
   {
    if( is_user_alive(id) )
    {
     if( Started[id] )
     {     
      if( IsPaused[id] != 1 )
      {
       PauseTime[id] += (thetime() - Timer[id]);
       IsPaused[id] = 1;
       Timer[id] = 0.0;
      }
     }
     pev(id, pev_health, g_spechp[id]);
     pev(id, pev_origin, g_player_specposition[id]);
     cs_set_user_team(id, CS_TEAM_SPECTATOR);
     set_pev(id, pev_solid, SOLID_NOT);
     set_pev(id, pev_movetype, MOVETYPE_FLY);
     set_pev(id, pev_effects, EF_NODRAW);
     set_pev(id, pev_deadflag, DEAD_DEAD);
    }
           return PLUGIN_HANDLED;   
   }   
          return PLUGIN_CONTINUE;   
}

Есть ещё плагин контролирующий респ, который первым стартует, может кто глянет? Может именно там вся проблема?
Прикрепил к посту...

Прикрепления: respawn.inc (1.3 Kb) · respawn_control.sma (9.2 Kb)


Сообщение отредактировал Hafner - Пятница, 31.07.2009, 20:03:05
 
defaultNick8433Дата: Пятница, 31.07.2009, 20:22:55 | Сообщение # 8
Генерал-полковник
Группа: Скриптеры
Сообщений: 806
Репутация: 19
Статус: Не в сети
изменил немного respawn_controler.sma,скомпилируй его,потом,уже ставь свой плагин с переходами,который первый:
Прикрепления: respawn_control.sma (8.8 Kb)


Раскручиваю сайты,ставлю трекера на хостинг.Всё бесплатно.Если заинтересовало,то моя аська 400538001
 
HafnerДата: Суббота, 01.08.2009, 01:50:48 | Сообщение # 9
Лейтенант
Группа: Пользователи
Сообщений: 46
Репутация: 0
Статус: Не в сети
Там ошибка в коде, лишнию скобку потерли, вобщем не пашет даже так...
 
defaultNick8433Дата: Суббота, 01.08.2009, 08:50:49 | Сообщение # 10
Генерал-полковник
Группа: Скриптеры
Сообщений: 806
Репутация: 19
Статус: Не в сети
А если в твой kz код добавить вместо переноса игрока за кт,функцию респавна,spawn_player(id).В kz моде нету команды терроров,соответственно перенос произойдёт в команду контров.

Добавлено (2009-08-01, 8:50 Am)
---------------------------------------------
Кстати удали файл kz_fakeplayer.sma


Раскручиваю сайты,ставлю трекера на хостинг.Всё бесплатно.Если заинтересовало,то моя аська 400538001
 
HafnerДата: Суббота, 01.08.2009, 11:04:51 | Сообщение # 11
Лейтенант
Группа: Пользователи
Сообщений: 46
Репутация: 0
Статус: Не в сети
Quote (defaultNick8433)
Кстати удали файл kz_fakeplayer.sma

Это первое что я сделал, когда поставил kz мод.
Проблема то не в спавне игрока, а в переходе за спектаторов. Сам спавн происходит без проблем.
Трабл в самом respawn_control.sma, познаний в pawn у меня не достаточно к сожалению, чтобы найти трабл, и так уже на орге сижу читаю каждую функцию...

Добавлено (2009-08-01, 11:04 Am)
---------------------------------------------
А терры там есть, respawn_control также отвечает за то чтоб не заходил игрок за них.

 
defaultNick8433Дата: Суббота, 01.08.2009, 11:39:41 | Сообщение # 12
Генерал-полковник
Группа: Скриптеры
Сообщений: 806
Репутация: 19
Статус: Не в сети
Code
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <respawn>

/* Most of these idea are from CSDM 2.1 by BAILOPAN. When the player select team, model, Weapon Removal
  * Also the idea of when the player actually spawned. The reason I took this into a plugin
  * instead of just using the module CSDM was that I was only going to use it for my kz plugin.
  *
  * Experimental version.
  * I found that with respawn time of 3 secs with speeding up the death animation by 2x. That there
  * are no more ghost/dead body models on the floor. Seem to work very well.
  */

#pragma semicolon 1
#define RC_VERSION "0.04"

// Forwards
new fwd_RoundStart;
new fwd_RoundEnd;
new fwd_DeathMessage;
new fwd_PostSpawn;
new fwd_PreSpawn;
new fwd_result;

new OFFSET_INTERNALMODEL;

// Pointer Cvar
new spawn_time;
new weapon_stay;

// If round ended. Don't respawn player from death.
new bool:RoundEnded;

new bool:spawned[33];
new bool:spawning[33];
new bool:joined[33];
new Float:wait[33];

new MaxPlayers;
new respawn_enabled;

public plugin_init()
{
  register_plugin("Respawn Controller", RC_VERSION, "teame06");

  // Fakemeta Forwards
  register_forward(FM_AlertMessage, "fm_AlertMessage", 1);
  register_forward(FM_PlayerPreThink, "fm_PostThink");
   
  // Events
  register_event("DeathMsg", "Event_DeathMsg", "a");
  register_event("ShowMenu", "menuclass", "b", "4&CT_Select", "4&Terrorist_Select");
  register_event("VGUIMenu", "menuclass", "b", "1=26", "1=27");

  // Other Forwards
  fwd_RoundStart = CreateMultiForward("RoundStart", ET_STOP);
  fwd_RoundEnd = CreateMultiForward("RoundEnd", ET_IGNORE);
  fwd_DeathMessage = CreateMultiForward("DeathMessage", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_STRING);
  fwd_PreSpawn = CreateMultiForward("PreSpawn", ET_IGNORE, FP_CELL);
  fwd_PostSpawn = CreateMultiForward("PostSpawn", ET_IGNORE, FP_CELL);

  // Cvars
  spawn_time = register_cvar("respawn_time", "3.0");
  respawn_enabled = register_cvar("respawn_enabled", "0", FCVAR_SERVER|FCVAR_SPONLY);
  register_cvar("respawn_version", RC_VERSION, FCVAR_SERVER|FCVAR_SPONLY);
  weapon_stay = register_cvar("weapon_stay", "5");
  MaxPlayers = get_maxplayers();

  OFFSET_INTERNALMODEL = is_amd64_server() ? 152 : 126;

  // Weapon Removal
  register_clcmd("drop", "hook_drop");

  new config[64];
  get_configsdir(config, 63);
  server_cmd("exec %s/respawn.cfg", config);
  server_exec();
}

public plugin_natives()
{
  register_library("respawn");
  register_native("spawn_player", "native_spawn");
}

public native_spawn(id, nums)
{
  if(nums != 1)
   return log_error(10, "Bad native parameters");

  if(get_pcvar_num(respawn_enabled))
  {
   new index = get_param(1);

   if(index > 0 && index <= MaxPlayers)
   {
    if(is_user_connected(index))
    {
     spawning[index] = true;
     spawned[index] = false;
     respawn(index, 1);
    }
    else
     return log_error(10, "User is not connected"); // Need to change this.
   }
   else
    return log_error(10, "User ID out of range");
  }

  return 0;
}

public fm_AlertMessage(at_type, const message[])
{
  if(get_pcvar_num(respawn_enabled) && at_type == 5)
  {
   if(equal(message[17], "Round_Start", 11))
   {
    RoundEnded = false;
    ExecuteForward(fwd_RoundStart, fwd_result);
   }
   else if(equal(message[17], "Round_End", 9))
   {
    RoundEnded = true;
    ExecuteForward(fwd_RoundEnd, fwd_result);
   }
  }
  return FMRES_IGNORED;
}

public fm_PostThink(id)
{
  if(!get_pcvar_num(respawn_enabled))
   return FMRES_IGNORED;

  if(!is_user_connected(id))
   return FMRES_IGNORED;

  // Speed up death animation 2x
  if(pev(id, pev_deadflag) == DEAD_DYING)
   set_pev(id, pev_framerate, 2.0);

  if(spawned[id])
   return FMRES_IGNORED;

  static CsTeams:team;
  team = cs_get_user_team(id);

  if(team != CS_TEAM_CT && team != CS_TEAM_T)
   return FMRES_IGNORED;

Float:_time()
{
  new Float:engine_time;
  global_get(glb_time, engine_time);
  return engine_time;
}

public Event_DeathMsg()
{
  if(!get_pcvar_num(respawn_enabled))
   return;

  new Victim = read_data(2);

  if(!Victim)
   return;

  static weaponname[32];
  new CsTeams:team = cs_get_user_team(Victim);
  read_data(4, weaponname, 31);

  spawned[Victim] = false;

  // Would forwarding a weapon id would be better? I know it doesn't have weapon_ in the message.
  // Due to if any uses a certain natives in 1.75a and below will replace weaponname string with something else.
  ExecuteForward(fwd_DeathMessage, fwd_result, read_data(1), Victim, read_data(3), weaponname);

  if(team == CS_TEAM_CT || team == CS_TEAM_T)
  {
    
    spawning[Victim] = true;

    new Float:time = get_pcvar_float(spawn_time);

    set_task(time, "respawn_player", Victim);

    if(time >= 3.0)
     set_task(2.8, "freeze_player", Victim);
}
   

  static weapons[32], num, name[24];
  new wp, slot;

  get_user_weapons(Victim, weapons, num);

  for (new i=0; i<num; i++)
  {
   wp = weapons[i];
   slot = g_WeaponSlots[wp];

   if (slot == SLOT_PRIMARY || slot == SLOT_SECONDARY || slot == SLOT_C4)
   {
    get_weaponname(wp, name, 23);

    if(get_pcvar_float(weapon_stay) != -1)
     set_task(get_pcvar_float(weapon_stay), "delay", Victim, name, 24);
   }
  }
}

public freeze_player(id)
{
  if(!get_pcvar_num(respawn_enabled))
   return;

  if(!is_user_connected(id))
   return;

  new CsTeams:team = cs_get_user_team(id);
  if(team == CS_TEAM_CT || team == CS_TEAM_T)
  {
    
    set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN);
    set_pev(id, pev_deadflag, DEAD_DISCARDBODY);
   }
}

public respawn_player(id)
{
  if(!get_pcvar_num(respawn_enabled))
   return;

  if(!is_user_connected(id))
   return;

  new CsTeams:team = cs_get_user_team(id);
  if(team == CS_TEAM_CT || team == CS_TEAM_T)
  {
    
    respawn(id, 0);
   }
}

respawn(id, flags = 1)
{
  if(!get_pcvar_num(respawn_enabled))
   return;

  if(RoundEnded) // If round ended. Don't respawn player.
   return;

  ExecuteForward(fwd_PreSpawn, fwd_result, id);

  if(fwd_result > 0)
   return;

  if(flags == 0)
  {
   if(is_user_alive(id))
    return;

   // If just use with only DEAD_RESPAWNABLE
   // There are times where it doesn't respawn the player.
   // So they will have to type /respawn to respawn.
   set_pev(id, pev_deadflag, DEAD_RESPAWNABLE);

   // DLLFunc_Spawn would sometime spawn a
   // player without a hud from DeathMsg.
   //dllfunc(DLLFunc_Spawn, id);
   dllfunc(DLLFunc_Think, id);
  }
  else
  {
   dllfunc(DLLFunc_Spawn, id);
  }
}

public menuclass(id)
{
  if(!get_pcvar_num(respawn_enabled))
   return;

  // They changed teams
  SetPlayerModel(id, 0xFF);

  if(joined[id])
   wait[id] = -1.0;
}

public RoundStart()
{
  if(!get_pcvar_num(respawn_enabled))
   return;

  for(new i = 0; i <= MaxPlayers; i++)
   spawned[i] = false;
}
public client_connect(id)
{
  if(!get_pcvar_num(respawn_enabled))
   return;

  spawned[id] = false;
  spawning[id] = false;
  joined[id] = false;
  wait[id] = 0.0;
}

public hook_drop(id)
{
  if(!get_pcvar_num(respawn_enabled))
   return;

  static wp, c, a, name[24];
  if (read_argc() <= 1)
  {
   wp = get_user_weapon(id, c, a);
  } else {
   read_argv(1, name, 23);
   wp = get_weaponid(name);
  }

  if (wp)
  {
   static name[24];
   get_weaponname(wp, name, 23);

   if(get_pcvar_float(weapon_stay) != -1)
    set_task(get_pcvar_float(weapon_stay), "delay", id, name, 24);
  }
}

public delay(name[], player)
{
  remove_weapon(player, name);
}

remove_weapon(player, const weapon[])
{
  // Check index.
  if (player < 1 || player > MaxPlayers)
  {
   log_amx("Invalid player %d", player);
   return;
  }

  static ent, ent2;
  ent = engfunc(EngFunc_FindEntityByString, -1, "classname", "weaponbox");

  while(ent > 0)
  {
   if(pev_valid(ent))
   {
    if (pev(ent, pev_owner) == player)
    {
     ent2 = engfunc(EngFunc_FindEntityByString, -1, "classname", weapon);

     while(ent2 > 0 && pev_valid(ent2))
     {
      if (pev(ent2, pev_owner) == ent)
      {
       engfunc(EngFunc_RemoveEntity, ent2);
       engfunc(EngFunc_RemoveEntity, ent);
       return;
      }
      ent2 = engfunc(EngFunc_FindEntityByString, ent2, "classname", weapon);
     }
    }
   }
   ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "weaponbox");
  }
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/

Попробуй


Раскручиваю сайты,ставлю трекера на хостинг.Всё бесплатно.Если заинтересовало,то моя аська 400538001
 
HafnerДата: Суббота, 01.08.2009, 15:55:17 | Сообщение # 13
Лейтенант
Группа: Пользователи
Сообщений: 46
Репутация: 0
Статус: Не в сети
И так не вышло...
Гадание на кофейной гуще))

Добавлено (2009-08-01, 3:55 Pm)
---------------------------------------------
Проблему решил на половину, модели-фантомы убрал (http://amxmodx.ucoz.ru/forum/9-2906-1), осталось удалить оружие которое после ухода в спектр дропается :)

 
defaultNick8433Дата: Суббота, 01.08.2009, 16:44:24 | Сообщение # 14
Генерал-полковник
Группа: Скриптеры
Сообщений: 806
Репутация: 19
Статус: Не в сети
Code

#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
register_plugin("x","x","x")
register_forward(FM_FindEntityByString,"fw_FindEntityByString")
}
public fw_FindEntityByString()
{
new ent=engfunc(EngFunc_FindEntityByString,ent,"classname","weaponbox")
engfunc(EngFunc_RemoveEntity,ent)
}

Вот,попробуй


Раскручиваю сайты,ставлю трекера на хостинг.Всё бесплатно.Если заинтересовало,то моя аська 400538001


Сообщение отредактировал defaultNick8433 - Суббота, 01.08.2009, 16:57:24
 
HafnerДата: Воскресенье, 02.08.2009, 00:02:28 | Сообщение # 15
Лейтенант
Группа: Пользователи
Сообщений: 46
Репутация: 0
Статус: Не в сети
А как тоже самое только с помощью hamsandwich сделать(?), ради только этой функции не охото целую библиотеку подгружать.
 
AMX Mod X Форум » Скриптинг » Помощь по скриптингу » Kz Jump Plugin v0.08b + teamchange (корректировка кода)
  • Страница 1 из 2
  • 1
  • 2
  • »
Поиск:

AMX Mod X Russian Community © 2006-2024