SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 10/12/2012, 05:21 PM   #1
Daslee
Big Clucker
 
Join Date: Jul 2009
Location: Lithuania
Posts: 111
Reputation: 0
Default Weapon data after death

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]);
Daslee is offline   Reply With Quote
Old 10/12/2012, 05:46 PM   #2
you10
Little Clucker
 
Join Date: Jul 2011
Location: England, United Kingdom
Posts: 31
Reputation: 2
Default Re: Weapon data after death

You could try a timer that checks what weapons the player has if they are spawned.
__________________
you10 is offline   Reply With Quote
Old 10/12/2012, 05:54 PM   #3
Cypress
Gangsta
 
Cypress's Avatar
 
Join Date: Dec 2009
Location: Germany
Posts: 938
Reputation: 127
Default Re: Weapon data after death

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;
}
__________________

Welcome stranger. I like your attitude.
Cypress is offline   Reply With Quote
Old 10/12/2012, 06:30 PM   #4
Daslee
Big Clucker
 
Join Date: Jul 2009
Location: Lithuania
Posts: 111
Reputation: 0
Default Re: Weapon data after death

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]);
Daslee is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting player weapon data? 0ne Help Archive 0 02/05/2010 03:38 PM
Need help with getting a weapon from Weapon Data KuHS Help Archive 0 10/03/2010 06:12 PM
Save player weapon data Dezi Help Archive 4 14/06/2009 10:32 AM
Not saving to ini file (Weapon Data) Robbin237 Help Archive 5 02/05/2009 10:02 AM


All times are GMT. The time now is 06:06 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.