AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved]Can i Replace This Code with Another Code? (https://forums.alliedmods.net/showthread.php?t=243143)

devilicioux 06-30-2014 10:02

[Solved]Can i Replace This Code with Another Code?
 
I lifted this code from somewhere

PHP Code:

set_msg_block(g_msgDeathMsg,BLOCK_ONCE
    
set_msg_block(g_msgScoreInfo,BLOCK_ONCE
    
user_kill(attacked
 
    
//user_kill removes a frag, this gives it back 
    
set_user_frags(attacked,get_user_frags(attacked) + 1

Can i replace this entire portion of code with

PHP Code:

user_silentkill(attacked

?

Point of the asking this question is description from documentation ..

Quote:

user_silentkill
Engine (engine_stocks.inc) Description
user_silentkill - Kills a user without a death message.
What i want is it should NOT be considered as a suicide .. !

mottzi 06-30-2014 17:30

Re: Can i Replace This Code with Another Code?
 
use user_silentkill(). It should not mess with frags as you mentioned.

Black Rose 06-30-2014 20:14

Re: Can i Replace This Code with Another Code?
 
Since it's a stock, you can easily open the include which contains the stock to see what it does and if that fits your need.

I found this in message_stocks.inc, don't know why yours say engine_stocks.inc.
Code:
/* Kills a user without a message. */ stock user_silentkill(index) {     static msgid = 0;     new msgblock;     if (!msgid)     {         msgid = get_user_msgid("DeathMsg");     }     msgblock = get_msg_block(msgid);     set_msg_block(msgid, BLOCK_ONCE);       user_kill(index, 1);     set_msg_block(msgid, msgblock);     return 1; }

As far as I see, it is not resetting the kills but I don't really know if user_kill() removes one.
You'll just have to try it out to make sure.

The second parameter of user_kill() prevents the score from changing.

YamiKaitou 06-30-2014 21:07

Re: Can i Replace This Code with Another Code?
 
Quote:

Originally Posted by Black Rose (Post 2160041)
I found this in message_stocks.inc, don't know why yours say engine_stocks.inc.

Because he is using documentation for 1.60. message_stocks.inc wasn't created until 1.76

devilicioux 07-02-2014 05:15

Re: Can i Replace This Code with Another Code?
 
Okay so i tested up things and the solution was met using Ham_killed..
Quote:

new bool:shouldgib = true;
// Let's gib!
ExecuteHam(Ham_Killed,target,attacker,shouldgib);
Quote:

/**
* Description: Normally called whenever an entity dies.
* Forward params: function(this, idattacker, shouldgib)
* Return type: None.
* Execute params: ExecuteHam(Ham_Killed, this, idattacker, shouldgib);
*/
Ham_Killed,


All times are GMT -4. The time now is 21:17.

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