Weapons don't load! :(
#3

PHP код:
#include <a_samp>
#include <dini> 
#define PATH "Weapons"  
new bool:AlreadyGiveWeapons[MAX_PLAYERS];
public 
OnFilterScriptInit()
{
    
printf("|------------------------------------------|");
    
printf("|--------- Weapons Saving System --------|");
    
printf("|No published version-----------------------|");
    return 
1;
}
public 
OnFilterScriptExit()
{
    
printf("|-----------------------------------------|");
    
printf("|---- Unload Weapons Saving System------|");
    
printf("|No published version----------------------|");
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    
AlreadyGiveWeapons[playerid] = false;
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
SaveWeaponsToFile(playerid);
    return 
1;
}
SaveWeaponsToFile(playerid)
{
    new 
ipath[50], string[128], weaponidammo;
    
path GetPlayerFormattedName(playerid);
    if (!
dini_Exists(path)) dini_Create(path);
    for (
i=0i<13i++)
    {
        
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 ammo);
    }
}
forward LoadWeaponsToFile(playerid);
public 
LoadWeaponsToFile(playerid)
{
    new 
ipath[50], string[128], weaponidammo;
    
path GetPlayerFormattedName(playerid);
    
ResetPlayerWeapons(playerid);
    for (
i=0i<13i++)
    {
        
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 (!
AlreadyGiveWeapons[playerid]) SetTimerEx("LoadWeaponsToFile",250,false,"i",playerid);
    return 
1;

Should work, I tested it worked
Reply


Messages In This Thread
Weapons don't load! :( - by Brandondw8 - 20.05.2014, 19:43
Re: Weapons don't load! :( - by DarK_FeneR - 20.05.2014, 21:50
Re: Weapons don't load! :( - by rumen98 - 20.05.2014, 22:01
Re: Weapons don't load! :( - by Brandondw8 - 20.05.2014, 22:08
Re: Weapons don't load! :( - by rumen98 - 20.05.2014, 22:10
Re: Weapons don't load! :( - by Brandondw8 - 20.05.2014, 22:15

Forum Jump:


Users browsing this thread: 1 Guest(s)