Dead body pickups
#1

I am trying to make a system where when a player dies they drop a pickup with a unique id, when someone walks over the players dead body (in this case a floating skull) a message box pops up with information about that player (their name, how they died, and other player variables from when they died). I want the pickups to stay until they are reset by the script or a server restart. I have been attempting this for some time but can't figure out how to do it, any help would be much appreciated and i apologize if this has been asked before, I did try a search and could not find anything.
Reply
#2

May I know what you have tried? If it proves worthy, I'll help.
Reply
#3

Quote:
Originally Posted by Bakr
Посмотреть сообщение
May I know what you have tried? If it proves worthy, I'll help.
Hi Bakr, I have basically been trying to create each pickup in an array on player death so each time a player dies a new entry in to that array is made with the players unique pickup, after this I would need to loop through the array on PickUppickup until the ID matched with the one i wanted. Hopefully this would work although I haven't managed to write it successfully.
Reply
#4

Right, I would take the same approach.

When the player dies, insert new information into an array that holds the information. When a pickup is picked up, loop through the array and access the element that holds the ID of the pickup, and see if it matches the ID passed to the callback. If it does, display the information. A little skeleton:
pawn Код:
enum E_DEATH
{
    pickupID,
    playerID,
    // other info
};

new pDeathInfo[10][E_DEATH];

public OnPlayerDeath(playerid, killerid, reason)
{
    new id = GetEmptySlot(); // returns next empty slot in array
    pDeathInfo[id][pickupID] = CreatePickup(...);
    pDeathInfo[id][playerID] = playerid;
    // etc
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    for(new i = 0; i < 10; i++)
    {
        if(pickupid == pDeathInfo[i][pickupID])
        {
            // process info
        }
    }
}
Sorry for any errors, I haven't coded anything for SA:MP (with a compiler at least) in quite some time.
Reply
#5

Thank you very much Bakr this is a great help, +rep.
Reply
#6

Mh https://sampforum.blast.hk/showthread.php?tid=448355 you can try to complete my code as you fit
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)