A explosion kills a player, but player does not recieve credit.
#1

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.
Reply
#2

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.
Reply
#3

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'
Reply
#4

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.
Reply
#5

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

Still need help.
Reply
#6

It's pretty complicated.
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)