AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   c4 replacement help (https://forums.alliedmods.net/showthread.php?t=60884)

AlMod 09-15-2007 13:37

c4 replacement help
 
I one of my mods i need to replace c4 with other weapon - the portal gun. But i have some troubles in weapon animation.

I need to play one sequence at one second, and other at the other second. In my code it looks like this:
PHP Code:

public on_PreThink(id)
{
 if (!
g_Mod) return
 if (
is_user_alive(id)) 
 {
  new 
wpnidclipammo
  wpnid 
get_user_weapon(idclipammo)
  if (
wpnid == CSW_C4)
  {
   new 
attack get_user_button(id) & IN_ATTACK
   
new oldattack get_user_oldbutton(id) & IN_ATTACK
   
new attack2 get_user_button(id) & IN_ATTACK2
   
new oldattack2 get_user_oldbutton(id) & IN_ATTACK2
 
   
if (attack && !oldattack && g_CanShoot1[id]) 
   {
    
portalgun_spin(id)
    
client_print(id,print_chat,"TEST 3")
 
   }
 
   if (
g_PlaySpin[id])
   {
    
entity_set_int(id,EV_INT_weaponanim,2)
   }
   if (
g_PlayFire[id])
   {
    
entity_set_int(id,EV_INT_weaponanim,4)
   }
 
  }
 
 }
}
...
public 
portalgun_spin(id)
{
 if (!
is_user_connected(id)) return
 
 new 
wpnidclipammo
 wpnid 
get_user_weapon(idclipammo)
 if (
wpnid == CSW_C4)
 {
  
g_CanShoot1[id]=false
  g_PlaySpin
[id]=true
  emit_sound
(idCHAN_WEAPONg_Gun_Sound_Spin0.9ATTN_NORM0PITCH_NORM)
  
client_print(id,print_chat,"TEST 1")
  
set_task(1.0,"portalgun_fire",id)
 }
}
public 
portalgun_fire(id)
{
 if (!
is_user_connected(id)) return
 
 new 
wpnidclipammo
 wpnid 
get_user_weapon(idclipammo)
 if (
wpnid == CSW_C4)
 {
  
g_CanShoot1[id]=false
  g_PlaySpin
[id]=false
  g_PlayFire
[id]=true
  emit_sound
(idCHAN_WEAPONg_Gun_Sound_Fire0.9ATTN_NORM0PITCH_NORM)
  
client_print(id,print_chat,"TEST 2")
  
set_task(1.0,"portalgun_dropfire",id)
 }
}
public 
portalgun_dropfire(id)
{
 if (!
is_user_connected(id)) return
 
 new 
wpnidclipammo
 wpnid 
get_user_weapon(idclipammo)
 if (
wpnid == CSW_C4)
 {
  
g_CanShoot1[id]=true
  g_PlayFire
[id]=false
 
}


u can see there my test sequences :wink:. I'll tried to put if's in prethink in postthink, but nothing helps - after one left mouse click - aimation starting but then momentally sets idle 0 (no animation). But if i holding left mouse button animation playing correctly - charge, then fire.

If u can help me did it faster as u can - I want very much to make "pOrtal" in CS

AlMod 09-15-2007 16:41

Re: c4 replacement help
 
Ok. I have found the decision. I only add +attack execute in _spin and -attack in _dropfire


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

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