18.09.2015, 11:02
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:
When player connects (Clears the variables and player data):
OnPLayerSpawn:
LoadUserSpawn_data:
SetWeapons:
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 i = 0; i < 13; i ++) if (playerData[playerid][gun][i] != 0 && playerData[playerid][ammo][i] != 0){
format(wep_str, sizeof(wep_str), "gun%d", i);
INI_WriteInt(File, wep_str, playerData[playerid][gun][i]);
format(wep_str, sizeof(wep_str), "ammo%d", i);
INI_WriteInt(File, wep_str, playerData[playerid][ammo][i]);
}
PHP код:
ResetPlayerWeapons(playerid);
for (new i = 0; i < 13; i ++) {
playerData[playerid][gun][i] = 0;
playerData[playerid][ammo][i] = 0;
}
PHP код:
SetTimerEx("LoadUserSpawn_data", 500, false, "i", playerid);
PHP код:
forward LoadUserSpawn_data(playerid);
public LoadUserSpawn_data(playerid)
{
new str[124];
// --------------------------
GivePlayerMoney(playerid, playerData[playerid][cash]);
SetPlayerHealth(playerid, playerData[playerid][health]);
SetPlayerArmour(playerid, playerData[playerid][armour]);
// --------------------------
format(str, sizeof(str), "Health: %.1f Armour: %.1f\n%s [%i]", ReturnHealth(playerid), ReturnArmour(playerid), ReturnName(playerid, 0), playerid);
NameTag[playerid] = CreateDynamic3DTextLabel(str, COLOR_GRAY, 0.0, 0.0, 0.2, 8.0, playerid, INVALID_VEHICLE_ID, 0, -1, -1, -1, 8.0);
Attach3DTextLabelToPlayer(NameTag[playerid], playerid, 0.0, 0.0, 0.2);
// --------------------------
SetWeapons(playerid);
// --------------------------
playerSpawned[playerid] = true;
return 1;
}
PHP код:
SetWeapons(playerid)
{
for (new i = 0; i < 13; i++) {
GivePlayerWeapon(playerid, playerData[playerid][gun][i], playerData[playerid][ammo][i]);
}
return 1;
}