SA-MP Forums Archive
A explosion kills a player, but player does not recieve credit. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: A explosion kills a player, but player does not recieve credit. (/showthread.php?tid=421283)



A explosion kills a player, but player does not recieve credit. - rangerxxll - 09.03.2013

So I've added another talent to my code, which is called Suicider. Pretty self explanatory. You spawn, and when you die, you explode. (The explosion lights players in a 6.0 radius on fire.) But when/if they die from the fire, I want the person who created the explosion to receive credit for the kill. In this case, get money and score.

Here's some of my code that I have added.

pawn Код:
if(PlayerInfo[playerid][pTalent] == 5)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        CreateExplosion(x, y, z, 1, 6.0);
        SendClientMessage(playerid, COLOR_BRIGHTRED, "BOOM!!!");
        ForceClassSelection(playerid);
        SetPlayerHealth(playerid, 0);
    }
This is under OnPlayerDeath. Pretty self-explanatory code as well. When you die, you create a explosion at your location.

Now would I define CreateExplosion as a variable?
pawn Код:
new explosion = CreateExplosion
Something like that? Because I'm totally lost.

Any help is appreciated. Much love.


Re: A explosion kills a player, but player does not recieve credit. - MP2 - 09.03.2013

You'll have to store the 'last damaged by explosion player ID' in a variable, and if they die, and were recently exploded, give the player credit.

I wouldn't personally use CreateExplosion. I'd use CreateObject with the explosion particle effect with a sound (playerplay sound at the coordinates) and destroy the object after 3 seconds, then set players nearby on fire by attaching a flame object to them (SetPlayerAttachedObject or AttachObjectToPlayer) then reduce their health over time - that way makes it flawless.


Re: A explosion kills a player, but player does not recieve credit. - rangerxxll - 09.03.2013

I'm not quite sure how I would do that. Could you start me off a little bit?
I'm a bit confused when you mention
Код:
'last damaged by explosion player ID'



Re: A explosion kills a player, but player does not recieve credit. - MP2 - 09.03.2013

The death from the fire will be after the explosion, so you need to remember who caused the explosion that set that player on fire.

I'm going to bed now so can't help further sorry. I would only go to all that length as to not rely on OnPlayerDeath as it is inaccurate with the killerid.


Re: A explosion kills a player, but player does not recieve credit. - rangerxxll - 09.03.2013

I'm really not sure what you mean. How would I go to do that?

Still need help.


Re: A explosion kills a player, but player does not recieve credit. - MP2 - 09.03.2013

It's pretty complicated.


Re: A explosion kills a player, but player does not recieve credit. - iggy1 - 09.03.2013

A fairly simple way which i have used in the past is...

When you create the explosion store the x, y and z co-ordinates of the explosion.

Under OnPlayerDeath check if the player was killed by an explosion.

If the player died by explosion - check if they are in range of the explosion, use the x, y, z co-ords you saved when creating the explosion.

Now you can give credit to player who created the explosion.

It's not %100 accurate, but iv used this method before and it works.