AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Stock doesn't kill a players (https://forums.alliedmods.net/showthread.php?t=262981)

OnePL 05-16-2015 14:11

Stock doesn't kill a players
 
I have my own stock

PHP Code:

stock UserKill(idinflictor 0killer 0weapon 0body 0shouldgib 0damagebits 0bool:addDeath false) {
if(!
userAlive(id) || !userConnected(killer)) return;

new 
iDeaths;
if(!
addDeathiDeaths get_pdata_int(id444);
set_pdata_int(id75body);
set_pdata_int(id76damagebits);
set_pdata_int(id1071);
set_pev(idpev_dmg_inflictorinflictor inflictor killer killer id);
set_msg_block(83BLOCK_ONCE);
ExecuteHamB(Ham_Killedidkiller killer idshouldgib);
if(!
addDeathset_pdata_int(id444iDeaths);

if(
userAlive(id)) return;

new 
effect pev(idpev_effects);
if(
effect 128set_pev(idpev_effectseffect 128);

new 
lenname[32];
if(
get_weaponname(weaponname31)) {
if(~
1<<4|1<<6|1<<9|1<<25 1<<weaponlen 7;
else 
name "grenade";
}
else 
name weapon == "tracktrain" "world";

emessage_begin(MSG_ALL83);
ewrite_byte(killer killer id);
ewrite_byte(id);
ewrite_byte(body == 0);
ewrite_string(name[len]);
emessage_end();


when I use it in the following way (suicide):

PHP Code:

public SomeFunction(id) {
UserKill(id);


doesn't kill a player

Nextra 05-16-2015 14:22

Re: Stock doesn't kill a players
 
You're using ExecuteHamB. Could something be blocking your call?

OnePL 05-16-2015 14:30

Re: Stock doesn't kill a players
 
I think that checking userConnected (killer) blocks a call. Now it noticed
By default killer = 0

so, userConnected(0) is wrong

I changed

userConnected(killer)

to

userConnected(killer ? killer : id)

I'll check if that works

OnePL 05-16-2015 16:17

Re: Stock doesn't kill a players
 
Solved

fysiks 05-16-2015 22:55

Re: Stock doesn't kill a players
 
You know better than to blank out your post . . .


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

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