21.12.2014, 08:10
I wanted to create Ammo System save n load with mysql. Everything it's ok but only one little solve is can't not SetAmmo for player when he's logined. Anyone can help me sovle that. Thanks you then +rep back.
This stock im create for Load in OnPlayerConnect, it's worked i can check my ammo system (pAmmo) inside game but my weapon can't got the ammo still 0-0.
There is stock to load ammo to gun from my system. I don't know why this can't work for give ammo.
This stock im create for Load in OnPlayerConnect, it's worked i can check my ammo system (pAmmo) inside game but my weapon can't got the ammo still 0-0.
PHP код:
stock SetPlayerWeapons(playerid)
{
if(GetPVarInt(playerid, "IsInArena") >= 0) { return 1; }
ResetPlayerWeapons(playerid);
for (new weaponid = 16; weaponid < 44; weaponid++)
{
for(new s = 0; s < 12; s++)
{
if(PlayerInfo[playerid][pGuns][s] > 0 && PlayerInfo[playerid][pAGuns][s] == 0)
{
GivePlayerValidWeapon(playerid, PlayerInfo[playerid][pGuns][s], 0);
SetPlayerAmmos(playerid, weaponid);
}
}
}
return 1;
}
PHP код:
stock SetPlayerAmmos(playerid, weaponid)
{
if(GetPVarInt(playerid, "IsInArena") >= 0) { return 1; }
switch(weaponid)
{
case 16:
{
if(PlayerInfo[playerid][pAmmo][ 22 ] > 0)
{
SetPlayerAmmoEx(playerid, 16, PlayerInfo[playerid][pAmmo][ 22 ]);
}
else
{
}
}
case 17:
{
if(PlayerInfo[playerid][pAmmo][ 23 ] > 0)
{
SetPlayerAmmoEx(playerid, 17, PlayerInfo[playerid][pAmmo][ 23 ]);
}
else
{
}
}
case 18:
{
if(PlayerInfo[playerid][pAmmo][ 24 ] > 0)
{
SetPlayerAmmoEx(playerid, 18, PlayerInfo[playerid][pAmmo][ 24 ]);
}
else
{
}
}
case 22:
{
if(PlayerInfo[playerid][pAmmo][ 0 ] > 0)
{
SetPlayerAmmoEx(playerid, 22, PlayerInfo[playerid][pAmmo][ 0 ]);
}
else
{
}
}
case 23://SDpid
{
if(PlayerInfo[playerid][pAmmo][ 1 ] > 0)
{
SetPlayerAmmoEx(playerid, 23, PlayerInfo[playerid][pAmmo][ 1 ]);
}
else
{
}
}
case 24://DE
{
if(PlayerInfo[playerid][pAmmo][ 2 ] > 0)
{
SetPlayerAmmoEx(playerid, 24, PlayerInfo[playerid][pAmmo][ 2 ]);
}
else
{
}
}
case 25://Shotgun
{
if(PlayerInfo[playerid][pAmmo][ 3 ] > 0)
{
SetPlayerAmmoEx(playerid, 25, PlayerInfo[playerid][pAmmo][ 3 ]);
}
else
{
}
}
case 26://uzi
{
if(PlayerInfo[playerid][pAmmo][ 4 ] > 0)
{
SetPlayerAmmoEx(playerid, 26, PlayerInfo[playerid][pAmmo][ 4 ]);
}
else
{
}
}
case 27://uzi
{
if(PlayerInfo[playerid][pAmmo][ 5 ] > 0)
{
SetPlayerAmmoEx(playerid, 27, PlayerInfo[playerid][pAmmo][ 5 ]);
}
else
{
}
}
case 28://shotgun
{
if(PlayerInfo[playerid][pAmmo][ 6 ] > 0)
{
SetPlayerAmmoEx(playerid, 28, PlayerInfo[playerid][pAmmo][ 6 ]);
}
else
{
}
}
case 29:
{
if(PlayerInfo[playerid][pAmmo][ 7 ] > 0)
{
SetPlayerAmmoEx(playerid, 29, PlayerInfo[playerid][pAmmo][ 7 ]);
}
else
{
}
}
case 30:
{
if(PlayerInfo[playerid][pAmmo][ 8 ] > 0)
{
SetPlayerAmmoEx(playerid, 30, PlayerInfo[playerid][pAmmo][ 8 ]);
}
else
{
}
}
case 31:
{
if(PlayerInfo[playerid][pAmmo][ 9 ] > 0)
{
SetPlayerAmmoEx(playerid, 31, PlayerInfo[playerid][pAmmo][ 9 ]);
}
else
{
}
}
case 32:
{
if(PlayerInfo[playerid][pAmmo][ 10 ] > 0)
{
SetPlayerAmmoEx(playerid, 32, PlayerInfo[playerid][pAmmo][ 10 ]);
}
else
{
}
}
case 33:
{
if(PlayerInfo[playerid][pAmmo][ 11 ] > 0)
{
SetPlayerAmmoEx(playerid, 33, PlayerInfo[playerid][pAmmo][ 11 ]);
}
else
{
}
}
case 34:
{
if(PlayerInfo[playerid][pAmmo][ 12 ] > 0)
{
SetPlayerAmmoEx(playerid, 34, PlayerInfo[playerid][pAmmo][ 12 ]);
}
else
{
}
}
case 35:
{
if(PlayerInfo[playerid][pAmmo][ 13 ] > 0)
{
SetPlayerAmmoEx(playerid, 35, PlayerInfo[playerid][pAmmo][ 13 ]);
}
else
{
}
}
case 36:
{
if(PlayerInfo[playerid][pAmmo][ 14 ] > 0)
{
SetPlayerAmmoEx(playerid, 36, PlayerInfo[playerid][pAmmo][ 14 ]);
}
else
{
}
}
case 37:
{
if(PlayerInfo[playerid][pAmmo][ 15 ] > 0)
{
SetPlayerAmmoEx(playerid, 37, PlayerInfo[playerid][pAmmo][ 15 ]);
}
else
{
}
}
case 38:
{
if(PlayerInfo[playerid][pAmmo][ 16 ] > 0)
{
SetPlayerAmmoEx(playerid, 38, PlayerInfo[playerid][pAmmo][ 16 ]);
}
else
{
}
}
case 39:
{
if(PlayerInfo[playerid][pAmmo][ 17 ] > 0)
{
SetPlayerAmmoEx(playerid, 39, PlayerInfo[playerid][pAmmo][ 17 ]);
}
else
{
}
}
case 40:
{
if(PlayerInfo[playerid][pAmmo][ 18 ] > 0)
{
SetPlayerAmmoEx(playerid, 40, PlayerInfo[playerid][pAmmo][ 18 ]);
}
else
{
}
}
case 41:
{
if(PlayerInfo[playerid][pAmmo][ 19 ] > 0)
{
SetPlayerAmmoEx(playerid, 41, PlayerInfo[playerid][pAmmo][ 19 ]);
}
else
{
}
}
case 42:
{
if(PlayerInfo[playerid][pAmmo][ 20 ] > 0)
{
SetPlayerAmmoEx(playerid, 42, PlayerInfo[playerid][pAmmo][ 20 ]);
}
else
{
}
}
case 43:
{
if(PlayerInfo[playerid][pAmmo][ 21 ] > 0)
{
SetPlayerAmmoEx(playerid, 43, PlayerInfo[playerid][pAmmo][ 21 ]);
}
else
{
}
}
}
return 1;
}
PHP код:
stock SetPlayerAmmoEx(Player, weapon, ammo)
{
SetPlayerAmmo(Player, weapon, ammo);
}