Weapons
#2

Use dini instead.

Add this at the top of your script:
pawn Код:
#define PATH "Weapons"  //  Folder where a player's weapons will save
Under /minigundm, add
pawn Код:
SaveWeaponsToFile(playerid);
Copy / paste this somewhere into your script, at the complete bottom is fine.
pawn Код:
SaveWeaponsToFile(playerid)
{
    new i, path[50], string[128], weaponid, ammo;
    path = GetPlayerFormattedName(playerid);
    if (!dini_Exists(path)) dini_Create(path);
    for (i=1; 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);
        dini_IntSet(path,string,ammo == 65535 ? 0 : ammo);
    }
}

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


forward LoadWeaponsToFile(playerid);
public LoadWeaponsToFile(playerid)
{
    new i, path[50], string[128], weaponid, ammo;
    path = GetPlayerFormattedName(playerid);
    ResetPlayerWeapons(playerid);
    for (i=1; i<13; i++)
    {
        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);
        SetTimerEx("LoadWeaponsToFile2", 2000, 0, "i", playerid);
    }
}
now under public OnPlayerDeath, add
pawn Код:
SetTimerEx("LoadWeaponsToFile",250,false,"i",playerid
The functions are not made by me, only edited. It does work for me, hope it does for you. Good luck.
Reply


Messages In This Thread
Weapons - by Kevin_Joshen - 05.08.2010, 04:59
Re: Weapons - by Faith - 05.08.2010, 05:25
Re: Weapons - by Kevin_Joshen - 05.08.2010, 05:32
Re: Weapons - by Faith - 05.08.2010, 05:34
Re: Weapons - by Kevin_Joshen - 05.08.2010, 05:47
Re: Weapons - by Faith - 05.08.2010, 05:52
Re: Weapons - by Kevin_Joshen - 05.08.2010, 05:54
Re: Weapons - by Faith - 05.08.2010, 05:56
Re: Weapons - by Kevin_Joshen - 05.08.2010, 06:01
Re: Weapons - by Faith - 05.08.2010, 06:03

Forum Jump:


Users browsing this thread: 1 Guest(s)