Weapon data after death
#1

Hello. I trying to make script that gets players weapons data on player death and on player spawn give him his weapons which was before death. But now when I try to get weapons in OnPlayerDeath callback, it can't get data because player is dead and weapons are removed. So how else I can get player weapon data before he die?

Also tried OnPlayerUpdate, but when he die it calls OnPlayerUpdate callback and updates weapon data to nothing.


Here is my code OnPlayerDeath:
Code:
for(new tmp=0; tmp<12; tmp++) GetPlayerWeaponData(playerid, tmp, weaponsbeforedie[0][tmp], weaponsbeforedie[1][tmp]);
And OnPlayerSpawn:
Code:
for(new tmp=0; tmp<12; tmp++) GivePlayerWeapon(playerid, wepsbeforedie[0][tmp], wepsbeforedie[1][tmp]);
Reply
#2

You could try a timer that checks what weapons the player has if they are spawned.
Reply
#3

pawn Code:
// Save them to variables
new WeaponData[2];
for (new i = 0; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, WeaponData[0], WeaponData[1]);
    if(WeaponData[0] && WeaponData[1] && (WeaponData[1] < 65535 || !i || i == 1 || i == 10 || i == 12))
    {
        weaponsbeforedie[0][i] = WeaponData[0],
        weaponsbeforedie[1][i] = WeaponData[1];
    }
    WeaponData[0] = 0;
    WeaponData[1] = 0;
}


// Give them and reset variables
for (new i = 0; i < 13; i++)
{
    if(weaponsbeforedie[0][i] > 0 && weaponsbeforedie[1][i] > 0)
                GivePlayerWeaponEx(playerid, weaponsbeforedie[0][ti], weaponsbeforedie[0][i]);
    weaponsbeforedie[0][i] = 0;
    weaponsbeforedie[i][tmp] = 0;
}
Reply
#4

I know that this code goes to OnPlayerSpawn:
Code:
// Give them and reset variables
for (new i = 0; i < 13; i++)
{
    if(weaponsbeforedie[0][i] > 0 && weaponsbeforedie[1][i] > 0)
                GivePlayerWeaponEx(playerid, weaponsbeforedie[0][ti], weaponsbeforedie[0][i]);
    weaponsbeforedie[0][i] = 0;
    weaponsbeforedie[i][tmp] = 0;
}
But where this goes?
Code:
new WeaponData[2];
for (new i = 0; i < 13; i++)
{
    GetPlayerWeaponData(playerid, i, WeaponData[0], WeaponData[1]);
    if(WeaponData[0] && WeaponData[1] && (WeaponData[1] < 65535 || !i || i == 1 || i == 10 || i == 12))
    {
        weaponsbeforedie[0][i] = WeaponData[0],
        weaponsbeforedie[1][i] = WeaponData[1];
    }
    WeaponData[0] = 0;
    WeaponData[1] = 0;
}
OnPlayerDeath it's not working.

EDIT: Fixed it.
OnPlayerUpdate:
Code:
new Float:playerhp;
	GetPlayerHealth(playerid, playerhp);
	if(playerhp > 0) for(new i=0; i<13; i++) GetPlayerWeaponData(playerid, i, weaponsbeforedie[0][i], weaponsbeforedie[1][i]);
And OnPlayerSpawn:
Code:
for (new i = 0; i < 13; i++) GivePlayerWeapon(playerid, weaponsbeforedie[0][i], weaponsbeforedie[1][i]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)