AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SLOVED] Grenade plugin (https://forums.alliedmods.net/showthread.php?t=187476)

KillerMasa 06-13-2012 15:26

[SLOVED] Grenade plugin
 
hi there,
i have grenade_enhancer plugin, and my problem is when i thorw grenade the grenade hit me [take damage and i die] i have zombie infection server, and when you thorw zombies with grenade
you die also, someone can fix it? i want the grenade do not kill yourself,

i already added this "if(!attacker || !victim)" but this not help,
it take damage on you when u thorw HE grenade.

PHP Code:

#include <amxmodx>
#include <csx>
new 
toggle_plugin,toggle_power,toggle_type,
toggle_flash,toggle_shake,toggle_display,
toggle_trail,trail_color;
new 
g_MsgSync,g_trail,spower;
public 
plugin_init()
{
 
register_plugin("Grenade Enhancer","1.2","anakin_cstrike");
 
toggle_plugin register_cvar("grenade_enhancer","1");
 
toggle_flash register_cvar("grenade_enhancer_screenflash","1");
 
toggle_display register_cvar("grenade_enhancer_display","1");
 
toggle_trail register_cvar("grenade_enhancer_trail","1");
 
toggle_shake register_cvar("grenade_enhancer_shake","1");
 
toggle_power register_cvar("grenade_enhancer_damage","500");
 
toggle_type register_cvar("grenade_enhancer_damagetype","2");
 
trail_color register_cvar("grenade_enhancer_trailcolor","255000000");
 
spower get_pcvar_num(toggle_power);
 
g_MsgSync CreateHudSyncObj();
}
public 
plugin_precache()
 
g_trail precache_model("sprites/smoke.spr");
public 
client_damage(attacker,victim,damage,wpnindex,hitplace,TA)
{
 if(
get_pcvar_num(toggle_plugin) != 1)
  return 
PLUGIN_CONTINUE;
 if(!
attacker || !victim)
  return 
PLUGIN_CONTINUE;
 if(
wpnindex != CSW_HEGRENADE)
  return 
PLUGIN_CONTINUE;
 
 switch(
get_pcvar_num(toggle_type))
 {
  case 
0user_slap(victim,spower,0);
  case 
1user_slap(victim,spower,1);
  case 
2user_slap(victim,spower,2);
  default: 
user_slap(victim,spower,2);
 }
 if(
get_pcvar_num(toggle_flash) == 1)
 {
  if(
is_user_connected(victim) && !is_user_bot(victim))
   
Fade(victim,255,0,0,170);
 }
 if(
get_pcvar_num(toggle_shake) == 1)
 {
  if(
is_user_connected(victim) && !is_user_bot(victim))
   
Shake(victim);
 }
 if(
get_pcvar_num(toggle_display) == 1)
 {
  new 
sdamage damage spower;
  
set_hudmessage(random(255),random(255),random(255), 0.030.3006.012.0);
  
ShowSyncHudMsg(victim,g_MsgSync,"%i",sdamage);
 }
 return 
PLUGIN_CONTINUE;
}
public 
grenade_throw(id,gid,wid)
{
 if(
get_pcvar_num(toggle_plugin) != 1)
  return 
PLUGIN_CONTINUE;
 if(
get_pcvar_num(toggle_trail) != 1
  return 
PLUGIN_CONTINUE;
 if(
wid != CSW_HEGRENADE)
  return 
PLUGIN_CONTINUE;
 
 static 
rgb,color[10];
 
get_pcvar_string(trail_colorcolor9);
 new 
str_to_num(color);
 
1000000
 c 
%= 1000000 
 g 
1000
 b 
1000
 Follow
(gid,g_trail,10,5,r,g,b,195);
 return 
PLUGIN_CONTINUE;
}
Follow(entity,index,life,width,red,green,blue,alpha)
{
 
message_begin(MSG_BROADCASTSVC_TEMPENTITY);
 
write_byte(TE_BEAMFOLLOW);
 
write_short(entity);
 
write_short(index);
 
write_byte(life);
 
write_byte(width);
 
write_byte(red);
 
write_byte(green);
 
write_byte(blue);
 
write_byte(alpha);
 
message_end();
}
Fade(index,red,green,blue,alpha)
{
 
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("ScreenFade"),{0,0,0},index);
 
write_short(6<<10);
 
write_short(5<<10);
 
write_short(1<<12);
 
write_byte(red);
 
write_byte(green);
 
write_byte(blue);
 
write_byte(alpha);
 
message_end();
}
Shake(index)
{
 
message_begin(MSG_ONE,get_user_msgid("ScreenShake"),{0,0,0},index);
 
write_short(1<<13);
 
write_short(1<<13);
 
write_short(1<<13);
 
message_end();



Gooogle 06-13-2012 15:28

Re: Grenade plugin,
 
Code:
if( attacker == victim )
If the attacker attacks him or herself, the victim (attacker) will not get hurt.

KillerMasa 06-13-2012 15:42

Re: Grenade plugin,
 
Not work, i think the zombie infection mod is cause. because the change your team.

hornet 06-14-2012 08:38

Re: Grenade plugin,
 
The line if(!attacker || !victim) is not related to the grenade, as I'm assuming your using it to make sure the attacker and vitctim are both in fact players.

The final argument of client_damage() TA determines whether it was team damage or not, so you could also try checking that and returning PLUGIN_HANDLED.

KillerMasa 06-14-2012 09:05

Re: Grenade plugin,
 
So what i add/change now?

hornet 06-14-2012 09:09

Re: Grenade plugin,
 
Well you could try what Gooogle said ( and return ):

Code:
if( attacker == victim )     return PLUGIN_HANDLED;

Or

Code:
if( TA == 1 )     return PLUGIN_HANDLED;

KillerMasa 06-14-2012 09:22

Re: Grenade plugin,
 
the problem is clear
when you thorw HE grenade you dont die, but when someone is zombie and all other is CT you die when you thorw grenade,
can you make that only T who get damage? i mean grenade hit them.
EDIT: i tested this two code but not work, grenade still kill myself.


All times are GMT -4. The time now is 06:18.

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