06.09.2013, 08:40
I just have some questions: i work on a project and again i need your help with something.
1. So i created an weapon saving systems for 3 weapons: throwable weapon ( grenades, gas, molotov), secundary weapon ( pistols), primary weapons ( guns ) it work perfectly no errors/warnings, but when i set myself a grenade, it doesn't disappear when ammo is 0 ( in database), and it save the variable to 1:
So when i enter again on my server i get a grenade that should've disappear last date.
I used this under OnPlayerUpdate
2. I should use a timer for this or continue to use OnPlayerUpdate?
1. So i created an weapon saving systems for 3 weapons: throwable weapon ( grenades, gas, molotov), secundary weapon ( pistols), primary weapons ( guns ) it work perfectly no errors/warnings, but when i set myself a grenade, it doesn't disappear when ammo is 0 ( in database), and it save the variable to 1:
So when i enter again on my server i get a grenade that should've disappear last date.
I used this under OnPlayerUpdate
pawn Код:
public OnPlayerUpdate(playerid)
{
SetPlayerScore(playerid, Z_Info[playerid][Level]);
//weapons and ammos
new w_ammo = GetPlayerAmmo(playerid);
new weapon = GetPlayerWeapon(playerid);
if(weapon == Z_Info[playerid][Weapon1])
{
Z_Info[playerid][Weapon1Ammo] = w_ammo;
}
if(weapon == Z_Info[playerid][Weapon2])
{
Z_Info[playerid][Weapon2Ammo] = w_ammo;
}
if(weapon == Z_Info[playerid][Weapon3])
{
Z_Info[playerid][Weapon3Ammo] = w_ammo;
}
if(Z_Info[playerid][Weapon1Ammo] <= 0)
{
Z_Info[playerid][Weapon1] = 0;
}
if(Z_Info[playerid][Weapon2Ammo] <= 0)
{
Z_Info[playerid][Weapon2] = 0;
}
if(Z_Info[playerid][Weapon3Ammo] <= 0)
{
Z_Info[playerid][Weapon3] = 0;
}
//position saver
if(fexist(GetFile(playerid) ) && IsSpawned[playerid] == 1 )
{
new Float: X, Float:Y, Float:Z;
new interior = GetPlayerInterior(playerid);
new vworld = GetPlayerVirtualWorld(playerid);
GetPlayerPos(playerid, X, Y, Z);
Z_Info[playerid][PosX] = X;
Z_Info[playerid][PosY] = Y;
Z_Info[playerid][PosZ] = Z;
Z_Info[playerid][VWorld] = vworld;
Z_Info[playerid][Interior] = interior;
}
return 1;
}