AMX MOD X
Четверг, 25.04.2024, 07:35:04



Приветствую Вас Гость | RSS
[ Главная ] [ не получается изменить скорость - AMX Mod X Форум ] [ Регистрация ] [ Вход ]
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]

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

  • Страница 1 из 1
  • 1
Модератор форума: slogic, AlMod  
AMX Mod X Форум » Скриптинг » Помощь по скриптингу » не получается изменить скорость
не получается изменить скорость
HoRRoRДата: Четверг, 09.07.2009, 00:37:57 | Сообщение # 1
Полковник
Группа: Скриптеры
Сообщений: 181
Репутация: 8
Статус: Не в сети
Code
#include <amxmodx>
#include <fakemeta>
#include <zombieplague>
#include <fun>

#define PLUGIN "[ZP] Class - Hunter"
#define VERSION "1.0"
#define AUTHOR "HoRRoR"

// Zombie Attributes
new const zclass_name[] = "Hunter" // name
new const zclass_info[] = "- Very fast, but low HP" // description
new const zclass_model[] = "zombie_hunter" // model
new const zclass_clawmodel[] = "v_zombie.mdl" // claw model
const zclass_health = 1500 // health
const zclass_speed = 315 // speed
const Float:zclass_gravity = 1.15 // gravity
const Float:zclass_knockback = 2.5 // knockback

   
// Class IDs
new g_zclass_hunter

// Zombie Classes MUST be registered on plugin_precache
public plugin_precache()
{
  // Register the new class and store ID for reference
  g_zclass_hunter = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)  
}

public plugin_init()  
{
  register_plugin(PLUGIN, VERSION, AUTHOR)
   
  register_clcmd("ability1", "use_ability_one")
  register_concmd("ability1", "use_ability_one")
    
}

public use_ability_one(id)
{
  if (zp_get_user_zombie_class(id) == g_zclass_hunter)
  {
   // убираем лимиты в 400 скорости у клиента
   client_cmd(id,"cl_forwardspeed 2000;cl_backspeed 2000;cl_sidespeed 2000")
   
   set_user_maxspeed(id , 1000.0)
  //    set_pev(id,pev_maxspeed,1000.0)

   set_task(2.5,"set_normal_speed",id)
   client_print(id,print_chat,"[dev] - speed changed?")
  }
}

public set_normal_speed(id)
{
  if (zp_get_user_zombie_class(id) == g_zclass_hunter)
  {
   set_user_maxspeed(id , 300.0)
   client_print(id,print_chat,"[dev] - task executed")
  }
}

public zp_user_infected_post(id, infector)
{
  // Check if the infected player is using our custom zombie class
  if (zp_get_user_zombie_class(id) == g_zclass_hunter)
  {
   client_cmd(id,"bind F1 ability1")
   set_pev(id, pev_health, float(pev(id, pev_health)) + 0.0)
  }
}

суть в чем. это типо способность у зомби (ZP). игрок нажимает на F1 - его скорость резко увеличивается на несколько секунд. но вот, млин, не удаётся изменить скорость :(
с чем связано?

зы. еше много надо доделывать. мне б только сначала сделать так, чтоб скорость менялась

 
se7hДата: Четверг, 09.07.2009, 13:15:21 | Сообщение # 2
Генерал-майор
Группа: Cупер-модеры
Сообщений: 424
Репутация: 13
Статус: Не в сети
попробуй использовать функцию из fakemeta_util

Code
stock fm_set_user_maxspeed(index, Float:speed = -1.0) {
  engfunc(EngFunc_SetClientMaxspeed, index, speed);
  set_pev(index, pev_maxspeed, speed);

  return 1;
}


 
HoRRoRДата: Четверг, 09.07.2009, 13:41:41 | Сообщение # 3
Полковник
Группа: Скриптеры
Сообщений: 181
Репутация: 8
Статус: Не в сети
как то не совсем понял куда пихать это, ибо пр компиле куча ошибок вылезла

сделал немного другим способом. не помню уже где подсмотрел, но работает. а ты, плз, добавь в код в 1-ом посте. что б я хоть знал как и что там :)

зы. как сделал сейчас:

Code
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <zombieplague>
#include <fun>

#define PLUGIN "[ZP] Class - Hunter"
#define VERSION "1.0"
#define AUTHOR "HoRRoR"

// Zombie Attributes
new const zclass_name[] = "Hunter" // name
new const zclass_info[] = "- Very fast, but low HP" // description
new const zclass_model[] = "zombie_hunter" // model
new const zclass_clawmodel[] = "v_zombie.mdl" // claw model
const zclass_health = 1500 // health
const zclass_speed = 290 // speed
const Float:zclass_gravity = 1.15 // gravity
const Float:zclass_knockback = 2.5 // knockback

// --- config ------------------------ //
#define TRAIL_LIFE        2
#define TRAIL_WIDTH       10
#define TRAIL_RED         90
#define TRAIL_GREEN       200   
#define TRAIL_BLUE        90
#define TRAIL_BRIGTHNESS  220

new Float:g_fastspeed = 1000.0
new Float:g_normspeed = 290.0
new Float:g_abilonecooldown = 20.0
new Float:g_abilonelenght = 2.0
new const sound_hunter_sprint[] = "zombie_plague/spells/zombie_hunter/sprint.wav"
// ----------------------------------- //

new g_zclass_hunter
new g_speeded[33] = 0
new g_abil_one_used[33] = 0
new gSmokeTrail

// Zombie Classes MUST be registered on plugin_precache
public plugin_precache()
{
   // Register the new class and store ID for reference
   g_zclass_hunter = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)   
   precache_sound(sound_hunter_sprint)
}

public plugin_init()   
{
   register_plugin(PLUGIN, VERSION, AUTHOR)
   register_clcmd("ability1", "use_ability_one")
   register_concmd("ability1", "use_ability_one")
     
   register_forward( FM_PlayerPreThink, "client_prethink" )
     
   gSmokeTrail = engfunc( EngFunc_PrecacheModel, "sprites/smoke.spr" )
}

public client_prethink(id)
{
   if (zp_get_user_zombie_class(id) == g_zclass_hunter)
   {
    if(is_user_alive(id) && zp_get_user_zombie(id) && (zp_get_user_zombie_class(id) == g_zclass_hunter) && !zp_get_user_nemesis(id))
    Action(id);
   }
}

public Action(id)
{
   if (g_speeded[id] == 1)
   {
    set_user_maxspeed(id , g_fastspeed);   
   }
   else
   {
    set_user_maxspeed(id , g_normspeed);   
   }
       return PLUGIN_HANDLED;
}   

public use_ability_one(id)
{
   if ((zp_get_user_zombie_class(id) == g_zclass_hunter) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id))
   {
    // убираем лимиты в 400 скорости у клиента
    client_cmd(id,"cl_forwardspeed 2000;cl_backspeed 2000;cl_sidespeed 2000")
      
    if(g_abil_one_used[id] == 0)
    {
     message_begin ( MSG_BROADCAST, SVC_TEMPENTITY );
     write_byte ( TE_BEAMFOLLOW );
     write_short ( id );
     write_short ( gSmokeTrail );
     write_byte ( TRAIL_LIFE );
     write_byte ( TRAIL_WIDTH );
     write_byte ( TRAIL_RED );
     write_byte ( TRAIL_GREEN );
     write_byte ( TRAIL_BLUE );
     write_byte ( TRAIL_BRIGTHNESS );
     message_end();

     g_speeded[id] = 1
     emit_sound(id, CHAN_ITEM, sound_hunter_sprint, 1.0, ATTN_NORM, 0, PITCH_NORM)
     g_abil_one_used[id] = 1
     set_task(g_abilonelenght,"set_normal_speed",id)
//   client_print(id,print_chat,"[dev] - use ability")
    }    
   }
}

public set_normal_speed(id)
{
   if ((zp_get_user_zombie_class(id) == g_zclass_hunter) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id))
   {
    g_speeded[id] = 0
    set_task(g_abilonecooldown,"set_ability_one_cooldown",id)
//  client_print(id,print_chat,"[dev] - executed 'set normal speed' task")
   }
}

public set_ability_one_cooldown(id)
{
   if ((zp_get_user_zombie_class(id) == g_zclass_hunter) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id))
   {
    g_abil_one_used[id] = 0
    new text[100]
    format(text,99,"^x04[ZP]^x01 Your ability ^x04SPRINT^x01 is ready.")
    message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)   
    write_byte(id)   
    write_string(text)   
    message_end()
   }  
}

public zp_user_infected_post(id, infector)
{
   if ((zp_get_user_zombie_class(id) == g_zclass_hunter) && !zp_get_user_nemesis(id))
   {
    new text[100]
    format(text,99,"^x04[ZP]^x01 Your ability is ^x04SPRINT^x01. Cooldown:^x04 20 ^x01seconds.")
    message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)   
    write_byte(id)   
    write_string(text)   
    message_e nd()
      
    g_speeded[id] = 0
    g_abil_one_used[id] = 0
    client_cmd(id,"bind F1 ability1")
   }
}


Сообщение отредактировал HoRRoR - Четверг, 09.07.2009, 13:42:42
 
se7hДата: Четверг, 09.07.2009, 14:02:28 | Сообщение # 4
Генерал-майор
Группа: Cупер-модеры
Сообщений: 424
Репутация: 13
Статус: Не в сети
Code
#include <amxmodx>  
#include <engine>  
#include <fakemeta>  
#include <zombieplague>  
#include <fun>  

#define PLUGIN "[ZP] Class - Hunter"  
#define VERSION "1.0"  
#define AUTHOR "HoRRoR"  

// Zombie Attributes  
new const zclass_name[] = "Hunter" // name  
new const zclass_info[] = "- Very fast, but low HP" // description  
new const zclass_model[] = "zombie_hunter" // model  
new const zclass_clawmodel[] = "v_zombie.mdl" // claw model  
const zclass_health = 1500 // health  
const zclass_speed = 290 // speed  
const Float:zclass_gravity = 1.15 // gravity  
const Float:zclass_knockback = 2.5 // knockback  

// --- config ------------------------ //  
#define TRAIL_LIFE        2  
#define TRAIL_WIDTH       10  
#define TRAIL_RED         90  
#define TRAIL_GREEN       200    
#define TRAIL_BLUE        90  
#define TRAIL_BRIGTHNESS  220  

new Float:g_fastspeed = 1000.0  
new Float:g_normspeed = 290.0  
new Float:g_abilonecooldown = 20.0  
new Float:g_abilonelenght = 2.0  
new const sound_hunter_sprint[] = "zombie_plague/spells/zombie_hunter/sprint.wav"  
// ----------------------------------- //  

new g_zclass_hunter  
new g_speeded[33] = 0  
new g_abil_one_used[33] = 0  
new gSmokeTrail  

// Zombie Classes MUST be registered on plugin_precache  
public plugin_precache()  
{  
    // Register the new class and store ID for reference  
    g_zclass_hunter = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)    
    precache_sound(sound_hunter_sprint)  
}  

public plugin_init()    
{  
    register_plugin(PLUGIN, VERSION, AUTHOR)  
    register_clcmd("ability1", "use_ability_one")  
    register_concmd("ability1", "use_ability_one")  
       
    register_forward( FM_PlayerPreThink, "client_prethink" )  
       
    gSmokeTrail = engfunc( EngFunc_PrecacheModel, "sprites/smoke.spr" )  
}  

public client_prethink(id)  
{  
    if (zp_get_user_zombie_class(id) == g_zclass_hunter)  
    {  
     if(is_user_alive(id) && zp_get_user_zombie(id) && (zp_get_user_zombie_class(id) == g_zclass_hunter) && !zp_get_user_nemesis(id))  
     Action(id);  
    }  
}  

public Action(id)  
{  
    if (g_speeded[id] == 1)  
    {  
     fm_set_user_maxspeed(id , g_fastspeed);    
    }  
    else  
    {  
     fm_set_user_maxspeed(id , g_normspeed);    
    }  
        return PLUGIN_HANDLED;  
}    

public use_ability_one(id)  
{  
    if ((zp_get_user_zombie_class(id) == g_zclass_hunter) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id))  
    {  
     // убираем лимиты в 400 скорости у клиента  
     client_cmd(id,"cl_forwardspeed 2000;cl_backspeed 2000;cl_sidespeed 2000")  
        
     if(g_abil_one_used[id] == 0)  
     {  
      message_begin ( MSG_BROADCAST, SVC_TEMPENTITY );  
      write_byte ( TE_BEAMFOLLOW );  
      write_short ( id );  
      write_short ( gSmokeTrail );  
      write_byte ( TRAIL_LIFE );  
      write_byte ( TRAIL_WIDTH );  
      write_byte ( TRAIL_RED );  
      write_byte ( TRAIL_GREEN );  
      write_byte ( TRAIL_BLUE );  
      write_byte ( TRAIL_BRIGTHNESS );  
      message_end();  

      g_speeded[id] = 1  
      emit_sound(id, CHAN_ITEM, sound_hunter_sprint, 1.0, ATTN_NORM, 0, PITCH_NORM)  
      g_abil_one_used[id] = 1  
      set_task(g_abilonelenght,"set_normal_speed",id)  
//   client_print(id,print_chat,"[dev] - use ability")  
     }     
    }  
}  

public set_normal_speed(id)  
{  
    if ((zp_get_user_zombie_class(id) == g_zclass_hunter) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id))  
    {  
     g_speeded[id] = 0  
     set_task(g_abilonecooldown,"set_ability_one_cooldown",id)  
//  client_print(id,print_chat,"[dev] - executed 'set normal speed' task")  
    }  
}  

public set_ability_one_cooldown(id)  
{  
    if ((zp_get_user_zombie_class(id) == g_zclass_hunter) && zp_get_user_zombie(id) && !zp_get_user_nemesis(id))  
    {  
     g_abil_one_used[id] = 0  
     new text[100]  
     format(text,99,"^x04[ZP]^x01 Your ability ^x04SPRINT^x01 is ready.")  
     message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)    
     write_byte(id)    
     write_string(text)    
     message_end()  
    }   
}  

public zp_user_infected_post(id, infector)  
{  
    if ((zp_get_user_zombie_class(id) == g_zclass_hunter) && !zp_get_user_nemesis(id))  
    {  
     new text[100]  
     format(text,99,"^x04[ZP]^x01 Your ability is ^x04SPRINT^x01. Cooldown:^x04 20 ^x01seconds.")  
     message_begin(MSG_ONE,get_user_msgid("SayText"),{0,0,0},id)    
     write_byte(id)    
     write_string(text)    
     message_e nd()  
        
     g_speeded[id] = 0  
     g_abil_one_used[id] = 0  
     client_cmd(id,"bind F1 ability1")  
    }  
}

stock fm_set_user_maxspeed(index, Float:speed = -1.0)
{  
   engfunc(EngFunc_SetClientMaxspeed, index, speed)
   set_pev(index, pev_maxspeed, speed)

   return 1
}


 
AMX Mod X Форум » Скриптинг » Помощь по скриптингу » не получается изменить скорость
  • Страница 1 из 1
  • 1
Поиск:

AMX Mod X Russian Community © 2006-2024