Weapons wont load. -
It save the ammo but gives the player the spawn weapons. it keeps the ammo and eventually people get unlimited ammo.
Код:
public OnGameModeInit()
{
ShowPlayerMarkers(1);
ShowNameTags(1);
SetGameModeText("FreeMode|Airplanes|Hydra");
//Grove Street
AddPlayerClass(105, 2480.5820, -1675.8840, 13.3377, 356.0161, 23, 1000, 26, 1000, 31, 3000);
AddPlayerClass(106, 2480.5820, -1675.8840, 13.3377, 356.0161, 23, 1000, 26, 1000, 31, 3000);
AddPlayerClass(107, 2484.2603, -1678.2600, 13.3366, 356.0161, 23, 1000, 26, 1000, 31, 3000);
//Ballas
AddPlayerClass(102, 2484.2603, -1678.2600, 13.3366, 25.1564, 24, 1000, 27, 1000, 30, 3000);
AddPlayerClass(103, 2484.2603, -1678.2600, 13.3366, 25.1564, 24, 1000, 27, 1000, 30, 3000);
AddPlayerClass(104, 2484.2603, -1678.2600, 13.3366, 25.1564, 24, 1000, 27, 1000, 30, 3000);
//Los Aztecas
AddPlayerClass(114, 2488.2173, -1677.5657, 13.3371, 21.0830, 22, 4000, 25, 1000, 33, 3000);
AddPlayerClass(115, 2488.2173, -1677.5657, 13.3371, 21.0830, 22, 4000, 25, 1000, 33, 3000);
AddPlayerClass(116, 2488.2173, -1677.5657, 13.3371, 21.0830, 22, 4000, 25, 1000, 33, 3000);
//Los Santos Vagos
AddPlayerClass(108, 2493.3796, -1676.0822, 13.3382, 52.7300, 23, 1000, 26, 1000, 31, 3000);
AddPlayerClass(109, 2493.3796, -1676.0822, 13.3382, 52.7300, 23, 1000, 26, 1000, 31, 3000);
AddPlayerClass(110, 2493.3796, -1676.0822, 13.3382, 52.7300, 23, 1000, 26, 1000, 31, 3000);
//Da Nang Boys
AddPlayerClass(121, 2498.9998, -1674.3905, 13.3457, 63.6968, 24, 1000, 27, 1000, 30, 3000);
AddPlayerClass(122, 2498.9998, -1674.3905, 13.3457, 63.6968, 24, 1000, 27, 1000, 30, 3000);
AddPlayerClass(123, 2498.9998, -1674.3905, 13.3457, 63.6968, 24, 1000, 27, 1000, 30, 3000);
//San Fierro Rifa
AddPlayerClass(173, 2503.4653, -1668.0095, 13.3644, 78.4236, 22, 4000, 25, 1000, 33, 3000);
AddPlayerClass(174, 2503.4653, -1668.0095, 13.3644, 78.4236, 22, 4000, 25, 1000, 33, 3000);
AddPlayerClass(175, 2503.4653, -1668.0095, 13.3644, 78.4236, 22, 4000, 25, 1000, 33, 3000);
//Triads
AddPlayerClass(117, 2501.6843, -1663.1902, 13.3738, 111.9505, 23, 1000, 26, 1000, 31, 3000);
AddPlayerClass(118, 2501.6843, -1663.1902, 13.3738, 111.9505, 23, 1000, 26, 1000, 31, 3000);
AddPlayerClass(119, 2501.6843, -1663.1902, 13.3738, 111.9505, 23, 1000, 26, 1000, 31, 3000);
//Bikers
AddPlayerClass(247, 2498.9150, -1659.1862, 13.3570, 120.4106, 24, 1000, 27, 1000, 30, 3000);
AddPlayerClass(248, 2498.9150, -1659.1862, 13.3570, 120.4106, 24, 1000, 27, 1000, 30, 3000);
AddPlayerClass(254, 2498.9150, -1659.1862, 13.3570, 120.4106, 24, 1000, 27, 1000, 30, 3000);
//The Russian Mafia
AddPlayerClass(111, 2496.1155, -1656.3430, 13.3684, 160.5177, 22, 4000, 25, 1000, 33, 3000);
AddPlayerClass(112, 2496.1155, -1656.3430, 13.3684, 160.5177, 22, 4000, 25, 1000, 33, 3000);
AddPlayerClass(113, 2496.1155, -1656.3430, 13.3684, 160.5177, 22, 4000, 25, 1000, 33, 3000);
//Italian Mafia
AddPlayerClass(124, 2490.8250, -1657.5001, 13.3594, 195.6113, 23, 1000, 26, 1000, 31, 3000);
AddPlayerClass(125, 2490.8250, -1657.5001, 13.3594, 195.6113, 23, 1000, 26, 1000, 31, 3000);
AddPlayerClass(126, 2490.8250, -1657.5001, 13.3594, 195.6113, 23, 1000, 26, 1000, 31, 3000);
AddPlayerClass(127, 2490.8250, -1657.5001, 13.3594, 195.6113, 23, 1000, 26, 1000, 31, 3000);
Код:
#define FILTERSCRIPT
#include <a_samp>
#include <dini>
#include <dudb>
#include <sscanf2>
new file[256];
enum WepData
{
Weapon1,
Weapon1a,
Weapon2,
Weapon2a,
Weapon3,
Weapon3a,
Weapon4,
Weapon4a,
Weapon5,
Weapon5a,
Weapon6,
Weapon6a,
Weapon7,
Weapon7a,
Weapon8,
Weapon8a,
Weapon9,
Weapon9a,
Weapon10,
Weapon10a,
Weapon11,
Weapon11a,
Weapon12,
Weapon12a,
}
new WeaponInfo[MAX_PLAYERS][WepData];
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Weapon Saving + Loading by Milan_Huizen");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "weapons/%s.ini", name);
if (!dini_Exists(file))
{
dini_Create(file);
dini_IntSet(file, "Weapon1",WeaponInfo[playerid][Weapon1] = 0);
dini_IntSet(file, "Weapon1a",WeaponInfo[playerid][Weapon1a] = 0);
dini_IntSet(file, "Weapon2",WeaponInfo[playerid][Weapon2] = 0);
dini_IntSet(file, "Weapon2a",WeaponInfo[playerid][Weapon2a] = 0);
dini_IntSet(file, "Weapon3",WeaponInfo[playerid][Weapon3] = 0);
dini_IntSet(file, "Weapon3a",WeaponInfo[playerid][Weapon3a] = 0);
dini_IntSet(file, "Weapon4",WeaponInfo[playerid][Weapon4] = 0);
dini_IntSet(file, "Weapon4a",WeaponInfo[playerid][Weapon4a] = 0);
dini_IntSet(file, "Weapon5",WeaponInfo[playerid][Weapon5] = 0);
dini_IntSet(file, "Weapon5a",WeaponInfo[playerid][Weapon5a] = 0);
dini_IntSet(file, "Weapon6",WeaponInfo[playerid][Weapon6] = 0);
dini_IntSet(file, "Weapon6a",WeaponInfo[playerid][Weapon6a] = 0);
dini_IntSet(file, "Weapon7",WeaponInfo[playerid][Weapon7] = 0);
dini_IntSet(file, "Weapon7a",WeaponInfo[playerid][Weapon7a] = 0);
dini_IntSet(file, "Weapon8",WeaponInfo[playerid][Weapon8] = 0);
dini_IntSet(file, "Weapon8a",WeaponInfo[playerid][Weapon8a] = 0);
dini_IntSet(file, "Weapon9",WeaponInfo[playerid][Weapon9] = 0);
dini_IntSet(file, "Weapon9a",WeaponInfo[playerid][Weapon9a] = 0);
dini_IntSet(file, "Weapon10",WeaponInfo[playerid][Weapon10] = 0);
dini_IntSet(file, "Weapon10a",WeaponInfo[playerid][Weapon10a] = 0);
dini_IntSet(file, "Weapon11",WeaponInfo[playerid][Weapon11] = 0);
dini_IntSet(file, "Weapon11a",WeaponInfo[playerid][Weapon11a] = 0);
dini_IntSet(file, "Weapon12",WeaponInfo[playerid][Weapon12] = 0);
dini_IntSet(file, "Weapon12a",WeaponInfo[playerid][Weapon12a] = 0);
}
else
{
WeaponInfo[playerid][Weapon1] = dini_Int(file, "Weapon1");
WeaponInfo[playerid][Weapon1a] = dini_Int(file, "Weapon1a");
WeaponInfo[playerid][Weapon2] = dini_Int(file, "Weapon2");
WeaponInfo[playerid][Weapon2a] = dini_Int(file, "Weapon2a");
WeaponInfo[playerid][Weapon3] = dini_Int(file, "Weapon3");
WeaponInfo[playerid][Weapon3a] = dini_Int(file, "Weapon3a");
WeaponInfo[playerid][Weapon4] = dini_Int(file, "Weapon4");
WeaponInfo[playerid][Weapon4a] = dini_Int(file, "Weapon4a");
WeaponInfo[playerid][Weapon5] = dini_Int(file, "Weapon5");
WeaponInfo[playerid][Weapon5a] = dini_Int(file, "Weapon5a");
WeaponInfo[playerid][Weapon6] = dini_Int(file, "Weapon6");
WeaponInfo[playerid][Weapon6a] = dini_Int(file, "Weapon6a");
WeaponInfo[playerid][Weapon7] = dini_Int(file, "Weapon7");
WeaponInfo[playerid][Weapon7a] = dini_Int(file, "Weapon7a");
WeaponInfo[playerid][Weapon8] = dini_Int(file, "Weapon8");
WeaponInfo[playerid][Weapon8a] = dini_Int(file, "Weapon8a");
WeaponInfo[playerid][Weapon9] = dini_Int(file, "Weapon9");
WeaponInfo[playerid][Weapon9a] = dini_Int(file, "Weapon9a");
WeaponInfo[playerid][Weapon10] = dini_Int(file, "Weapon10");
WeaponInfo[playerid][Weapon10a] = dini_Int(file, "Weapon10a");
WeaponInfo[playerid][Weapon11] = dini_Int(file, "Weapon11");
WeaponInfo[playerid][Weapon11a] = dini_Int(file, "Weapon11a");
WeaponInfo[playerid][Weapon12] = dini_Int(file, "Weapon12");
WeaponInfo[playerid][Weapon12a] = dini_Int(file, "Weapon12a");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Weapon1a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Weapon2a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Weapon3a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Weapon4a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Weapon5a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Weapon6a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Weapon7a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Weapon8a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Weapon9a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Weapon10a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Weapon11a]);
GivePlayerWeapon(playerid, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Weapon12a]);
SetTimerEx("save", 2000, true, "i", playerid);
return 1;
}
forward save(playerid);
public save(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "weapons/%s.ini", name);
GetPlayerWeaponData(playerid, 1, WeaponInfo[playerid][Weapon1], WeaponInfo[playerid][Weapon1a]);
GetPlayerWeaponData(playerid, 2, WeaponInfo[playerid][Weapon2], WeaponInfo[playerid][Weapon2a]);
GetPlayerWeaponData(playerid, 3, WeaponInfo[playerid][Weapon3], WeaponInfo[playerid][Weapon3a]);
GetPlayerWeaponData(playerid, 4, WeaponInfo[playerid][Weapon4], WeaponInfo[playerid][Weapon4a]);
GetPlayerWeaponData(playerid, 5, WeaponInfo[playerid][Weapon5], WeaponInfo[playerid][Weapon5a]);
GetPlayerWeaponData(playerid, 6, WeaponInfo[playerid][Weapon6], WeaponInfo[playerid][Weapon6a]);
GetPlayerWeaponData(playerid, 7, WeaponInfo[playerid][Weapon7], WeaponInfo[playerid][Weapon7a]);
GetPlayerWeaponData(playerid, 8, WeaponInfo[playerid][Weapon8], WeaponInfo[playerid][Weapon8a]);
GetPlayerWeaponData(playerid, 9, WeaponInfo[playerid][Weapon9], WeaponInfo[playerid][Weapon9a]);
GetPlayerWeaponData(playerid, 10, WeaponInfo[playerid][Weapon10], WeaponInfo[playerid][Weapon10a]);
GetPlayerWeaponData(playerid, 11, WeaponInfo[playerid][Weapon11], WeaponInfo[playerid][Weapon11a]);
GetPlayerWeaponData(playerid, 12, WeaponInfo[playerid][Weapon12], WeaponInfo[playerid][Weapon12a]);
dini_IntSet(file, "Weapon1",WeaponInfo[playerid][Weapon1]);
dini_IntSet(file, "Weapon1a",WeaponInfo[playerid][Weapon1a]);
dini_IntSet(file, "Weapon2",WeaponInfo[playerid][Weapon2]);
dini_IntSet(file, "Weapon2a",WeaponInfo[playerid][Weapon2a]);
dini_IntSet(file, "Weapon3",WeaponInfo[playerid][Weapon3]);
dini_IntSet(file, "Weapon3a",WeaponInfo[playerid][Weapon3a]);
dini_IntSet(file, "Weapon4",WeaponInfo[playerid][Weapon4]);
dini_IntSet(file, "Weapon4a",WeaponInfo[playerid][Weapon4a]);
dini_IntSet(file, "Weapon5",WeaponInfo[playerid][Weapon5]);
dini_IntSet(file, "Weapon5a",WeaponInfo[playerid][Weapon5a]);
dini_IntSet(file, "Weapon6",WeaponInfo[playerid][Weapon6]);
dini_IntSet(file, "Weapon6a",WeaponInfo[playerid][Weapon6a]);
dini_IntSet(file, "Weapon7",WeaponInfo[playerid][Weapon7]);
dini_IntSet(file, "Weapon7a",WeaponInfo[playerid][Weapon7a]);
dini_IntSet(file, "Weapon8",WeaponInfo[playerid][Weapon8]);
dini_IntSet(file, "Weapon8a",WeaponInfo[playerid][Weapon8a]);
dini_IntSet(file, "Weapon9",WeaponInfo[playerid][Weapon9]);
dini_IntSet(file, "Weapon9a",WeaponInfo[playerid][Weapon9a]);
dini_IntSet(file, "Weapon10",WeaponInfo[playerid][Weapon10]);
dini_IntSet(file, "Weapon10a",WeaponInfo[playerid][Weapon10a]);
dini_IntSet(file, "Weapon11",WeaponInfo[playerid][Weapon11]);
dini_IntSet(file, "Weapon11a",WeaponInfo[playerid][Weapon11a]);
dini_IntSet(file, "Weapon12",WeaponInfo[playerid][Weapon12]);
dini_IntSet(file, "Weapon12a",WeaponInfo[playerid][Weapon12a]);
return 1;
}
Re: Weapons wont load. -
Try to read some documentation. I suggest you to do it in double-dimensional array..
this will load all the ammo, put it in a for loop and read the documentation. Instead of grabbing a pre-made script, make your own? You'll learn much faster that way.
When a player spawns, you need to reset their ammo value and then add it again, so save it into the variable, remove it and give it back again, since it duplicates.