AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   log_kill and frags problems (https://forums.alliedmods.net/showthread.php?t=48072)

spunko 12-03-2006 15:46

log_kill and frags problems
 
hi.. the problem with this code is that when you kill someone, it sets the frags to you (1 / 0) but the victim gets (-1 / 1).. so if you kill him again u will have (2 / 0) and the victim (-2 / 2)

I dunno what the problem is.. can any one help me with this?
PHP Code:

public event_damageid ) {
 
 new 
victim_id id;
 if( !
is_user_connectedvictim_id ) ) return PLUGIN_CONTINUE
 
new dmg_take read_data);
 new 
dmgtype read_data);
 new 
Float:multiplier get_pcvar_float(CVAR_DAMAGE);
 new 
Float:damage dmg_take multiplier;
 new 
health get_user_healthvictim_id );
 
 new 
iWeapIDattacker_id get_user_attackervictim_idiWeapID );
 
 if( !
is_user_connectedattacker_id ) || !is_user_alivevictim_id ) ) {
  return 
PLUGIN_HANDLED
 
}
 
 if( 
iWeapID == CSW_KNIFE && knife_model[attacker_id] == ) {
 
  if( 
floatround(damage) >= health ) {
   if( 
victim_id == attacker_id ) {
    return 
PLUGIN_CONTINUE
    
}else{
    
log_killattacker_idvictim_id"knife");
   }
 
   return 
PLUGIN_CONTINUE
   
}else {
   if( 
victim_id == attacker_id ) return PLUGIN_CONTINUE
 
   fakedamage
victim_id"weapon_knife"damagedmgtype );
  }
 }
 return 
PLUGIN_CONTINUE
}
 
stock log_kill(killervictimweapon[],headshot) {
 
user_silentkillvictim );
 
 
message_beginMSG_ALLget_user_msgid"DeathMsg" ), {0,0,0}, );
 
write_bytekiller );
 
write_bytevictim );
 
write_byteheadshot );
 
write_stringweapon );
 
message_end();
 
 new 
kfrags get_user_fragskiller );
 
set_user_fragskillerkfrags );
 new 
vfrags get_user_fragsvictim );
 
set_user_fragsvictimvfrags );
 
 return  
PLUGIN_CONTINUE



jim_yang 12-03-2006 23:00

Re: log_kill and frags problems
 
probably because you get the victim's frags - 1 when he died.
new vfrags = get_user_frags( victim );
set_user_frags( victim, vfrags - 1 );

spunko 12-03-2006 23:24

Re: log_kill and frags problems
 
ok.. but what should i put then?
PHP Code:

new vfrags get_user_fragsvictim );
set_user_fragsvictimvfrags ); 

if i do that, i think it wont regioster the kill

The Specialist 12-04-2006 12:36

Re: log_kill and frags problems
 
why would you take kills from a person becasue they died ?

spunko 12-04-2006 19:40

Re: log_kill and frags problems
 
well i thought that too.. so i did this and the pluing still have the same problem..
PHP Code:

stock log_kill(killervictimweapon[],headshot) {
 
set_msg_block(get_user_msgid("DeathMsg"),BLOCK_ONCE)
 
user_silentkillvictim )
 
set_msg_block(get_user_msgid("DeathMsg"), BLOCK_NOT)
 
 
message_beginMSG_ALLget_user_msgid"DeathMsg" ), {0,0,0}, );
 
write_bytekiller );
 
write_bytevictim );
 
write_byteheadshot );
 
write_stringweapon );
 
message_end();
 
 new 
kfrags get_user_fragskiller );
 
set_user_fragskillerkfrags );
 
//new vfrags = get_user_frags( victim );
 //set_user_frags( victim, vfrags++ );
 
 
return  PLUGIN_CONTINUE



jim_yang 12-04-2006 22:51

Re: log_kill and frags problems
 
this is not related to your problem, but you don't have to block DeathMsg when you use user_silentkill, it will do that for u.

spunko 12-04-2006 23:30

Re: log_kill and frags problems
 
well look at the first post, it isn't with the block DeathMsg.. i did that to see if that helps cuz i saw some codes with that.. but guess what?? it didnt make any difference.. the problem is still there and i really dunno how to fix it, also i don't have much time cuz im working like crazy..

I hope someone could help me with this..

dutchmeat 12-05-2006 07:16

Re: log_kill and frags problems
 
The problem you're having is because the scoreboard doesn't update after set_frags...
here's an example i used for ESF:

Code:

new g_iMsgScoreInfo = get_user_msgid( "ScoreInfo" )
public AddScore(id){
new playerClass = entity_get_int(id, EV_INT_playerclass)
new team[32]
get_user_team(id,team,31)
message_begin(MSG_ALL,g_iMsgScoreInfo)
write_byte(id)
write_short(get_user_frags(id))
write_short(get_user_deaths(id))
write_short(0)
write_short(playerClass)
if( containi( team, "Good" ) != -1 ) {
write_short(1) //color of the player line
}else if( containi( team, "Evil" ) != -1 ) {
write_short(2)
}
message_end()
}

Note that this example is based on ESF, the message could be different on CT

spunko 12-05-2006 17:25

Re: log_kill and frags problems
 
going to see if it works.. thanx..

dutchmeat 12-05-2006 17:33

Re: log_kill and frags problems
 
Karma karma karma, spamming for karma :D hehe
but like i said, you might have to find the right arguments for CS.

btw, " g_iMsgScoreInfo " = get_user_msgid( "ScoreInfo" )
fixed my post


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

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