SA-MP Forums Archive
Object Spawns OnPlayerDeath - 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: Object Spawns OnPlayerDeath (/showthread.php?tid=407422)



Object Spawns OnPlayerDeath - AphexCCFC - 13.01.2013



I have a weapon saving system, all works perfectly except one thing, when I die and spawn back an object spawns next to me in the air, either a cigar or an empty bottle. I can't seem to find out why, here is the script:

pawn Код:
#include <a_samp>
#include <dini> //  Programmed with Dini.inc version 1.5.1
/*
    Weapons Saving System by Phyro - 2009
    Searching some technical SA-MP Tools ? visit : http://www.phyro.co.nr
    Email : mottiokla@gmail.com
*/


#define PATH "Weapons"  //  Folder where players data saved

#define COLOR_GREEN 0x33AA33AA

forward Health();

new bool:AlreadyGiveWeapons[MAX_PLAYERS];

new Death[MAX_PLAYERS];

public OnFilterScriptInit()
{
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    AlreadyGiveWeapons[playerid] = false;
    Death[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    SaveWeaponsToFile(playerid);
    return 1;
}

public Health()
{
    for(new i; i<MAX_PLAYERS; i++)
    {
            {
            new Float:health;
            GetPlayerHealth(i, health);
            if(health < 20)
            {
            SaveWeaponsToFile(i);
            }
        }
    }
    return 1;
}

SaveWeaponsToFile(playerid)
{
    new i, path[50], string[128], weaponid, ammo;
    path = GetPlayerFormattedName(playerid);
    if (!dini_Exists(path)) dini_Create(path);
    for (i=0; i<13; i++)
    {
        GetPlayerWeaponData(playerid,i,weaponid,ammo);
        format(string,sizeof(string),"Weapon: %d",i);
        dini_IntSet(path,string,weaponid);
        format(string,sizeof(string),"AmmoID: %d",i);
        dini_IntSet(path,string,ammo == 65535 ? 0 : ammo);
    }
}

forward LoadWeaponsToFile(playerid);
public LoadWeaponsToFile(playerid)
{
    new i, path[50], string[128], weaponid, ammo;
    path = GetPlayerFormattedName(playerid);
    ResetPlayerWeapons(playerid);
    for (i=0; i<13; i++)
    {
        GetPlayerWeaponData(playerid,i,weaponid,ammo);
        format(string,sizeof(string),"Weapon: %d",i);
        weaponid = dini_Int(path,string);
        format(string,sizeof(string),"AmmoID: %d",i);
        ammo = dini_Int(path,string);
        GivePlayerWeapon(playerid,weaponid,ammo);
        AlreadyGiveWeapons[playerid] = true;
    }
}

GetPlayerFormattedName(playerid)
{
    new name[24], full[50];
    GetPlayerName(playerid,name,sizeof(name));
    format(full,sizeof(full),"%s/%s.txt",PATH,name);
    return full;
}

public OnPlayerSpawn(playerid)
{
    if(Death[playerid] == 0)
    {
        if(!AlreadyGiveWeapons[playerid])
        {
            SetTimerEx("LoadWeaponsToFile",250,false,"i",playerid);
            return 1;
        }
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    Death[playerid] = 1;
    ResetPlayerWeapons(playerid);
}
I would appreciate it if you could help, thanks.


Re: Object Spawns OnPlayerDeath - Shetch - 13.01.2013

It's a sa-mp bug I think, I've seen it on other servers too.
Nothing you can really do..


AW: Object Spawns OnPlayerDeath - BiosMarcel - 13.01.2013

But this bug has a reason are you sure that the weapon system is the reasonї


Re: Object Spawns OnPlayerDeath - AphexCCFC - 13.01.2013

Yeah I'm sure it is, cause I stopped using the weapon filterscript to check and everything was fine. Someone please help.


Re: Object Spawns OnPlayerDeath - AphexCCFC - 14.01.2013

Anyone able to help? I'll rep and it will be very appreciated. Haven't been able to find out why this is for weeks now :/