weapons loads with twice as much bullets
#1

Well, after player spawns, they get the gun they left with, but with twice as much bullets.

I get no error or warnings in script, but this is something like script bug.

When player disconnects and SaveUser_data function has been called:
PHP код:
for (new 013++) if (playerData[playerid][gun][i] != && playerData[playerid][ammo][i] != 0){
    
format(wep_strsizeof(wep_str), "gun%d"i);
    
INI_WriteInt(Filewep_strplayerData[playerid][gun][i]);
    
    
format(wep_strsizeof(wep_str), "ammo%d"i);
    
INI_WriteInt(Filewep_strplayerData[playerid][ammo][i]);

When player connects (Clears the variables and player data):
PHP код:
ResetPlayerWeapons(playerid);
for (new 
013++) {
    
playerData[playerid][gun][i] = 0;
    
playerData[playerid][ammo][i] = 0;

OnPLayerSpawn:
PHP код:
SetTimerEx("LoadUserSpawn_data"500false"i"playerid); 
LoadUserSpawn_data:
PHP код:
forward LoadUserSpawn_data(playerid);
public 
LoadUserSpawn_data(playerid)
{
    new 
str[124];
    
// --------------------------
    
GivePlayerMoney(playeridplayerData[playerid][cash]);
    
SetPlayerHealth(playeridplayerData[playerid][health]);
    
SetPlayerArmour(playeridplayerData[playerid][armour]);
    
// --------------------------
    
format(strsizeof(str), "Health: %.1f Armour: %.1f\n%s [%i]"ReturnHealth(playerid), ReturnArmour(playerid), ReturnName(playerid0), playerid);
    
NameTag[playerid] = CreateDynamic3DTextLabel(strCOLOR_GRAY0.00.00.28.0playeridINVALID_VEHICLE_ID0, -1, -1, -18.0);
    
Attach3DTextLabelToPlayer(NameTag[playerid], playerid0.00.00.2);
    
// --------------------------
    
SetWeapons(playerid);
    
// --------------------------
    
playerSpawned[playerid] = true;
    return 
1;

SetWeapons:
PHP код:
SetWeapons(playerid)
{
    for (new 
013i++) {
        
GivePlayerWeapon(playeridplayerData[playerid][gun][i], playerData[playerid][ammo][i]);
    }
    return 
1;

Reply


Messages In This Thread
weapons loads with twice as much bullets - by thaKing - 18.09.2015, 11:02
Re: weapons loads with twice as much bullets - by rappy93 - 18.09.2015, 12:24
Re: weapons loads with twice as much bullets - by thaKing - 18.09.2015, 12:41
Re: weapons loads with twice as much bullets - by rappy93 - 18.09.2015, 12:46
Re: weapons loads with twice as much bullets - by thaKing - 18.09.2015, 13:07
Re: weapons loads with twice as much bullets - by rappy93 - 18.09.2015, 13:17

Forum Jump:


Users browsing this thread: 1 Guest(s)