Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dini>
- /*
- Salvando Armas
- */
- #define PATH "Armas"
- new bool:AlreadyGiveWeapons[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- printf("|----------------------------------------------------|");
- printf("|----------------- Sistema De Armas -----------------|");
- printf("|----------------------------------------------------|");
- return 1;
- }
- public OnFilterScriptExit()
- {
- printf("|----------------------------------------------------|");
- printf("|----------------- Sistema De Armas -----------------|");
- printf("|----------------------------------------------------|");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- AlreadyGiveWeapons[playerid] = false;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SaveWeaponsToFile(playerid);
- 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),"Arma - %d",i);
- dini_IntSet(path,string,weaponid);
- format(string,sizeof(string),"Municao - %d",i);
- dini_IntSet(path,string,ammo == 65535 ? 0 : ammo);
- }
- }
- forward LoadArmasToFile(playerid);
- public LoadArmasToFile(playerid)
- {
- new i, path[50], string[128], weaponid, ammo;
- path = GetPlayerFormattedName(playerid);
- ResetPlayerWeapons(playerid);
- for (i=0; i<13; i++)
- {
- format(string,sizeof(string),"Arma - %d",i);
- weaponid = dini_Int(path,string);
- format(string,sizeof(string),"Municao - %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("LoadArmasToFile",250,false,"i",playerid);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement