SetTimerEx("LoadUserSpawn_data", 500, false, "i", playerid);
forward LoadUserSpawn_data(playerid);
public LoadUserSpawn_data(playerid)
{
new str[128];
// --------------------------
ResetPlayerMoney(playerid);
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); // <-- LOOK HERE
// --------------------------
playerSpawned[playerid] = true;
return 1;
}
SetWeapons(playerid)
{
for (new i = 0; i < 13; i ++) if (playerData[playerid][gun][i] > 0 && playerData[playerid][ammo][i] > 0) {
GivePlayerWeapon(playerid, playerData[playerid][gun][i], playerData[playerid][ammo][i]);
}
return 1;
}
SetWeapons(playerid)
{
for (new i = 0; i < 13; i ++)
GivePlayerWeapon(playerid, playerData[playerid][gun][i], playerData[playerid][ammo][i]);
return 1;
}
|
Whats the point of "if (playerData[playerid][gun][i] > 0 && playerData[playerid][ammo][i] > 0)"?
It's going to skip the GivePlayerWeapon since i=0. Код:
SetWeapons(playerid)
{
for (new i = 0; i < 13; i ++)
GivePlayerWeapon(playerid, playerData[playerid][gun][i], playerData[playerid][ammo][i]);
return 1;
}
|
|
Echo the variables(weapon variables) and check if all the variables are assigned correctly on load.
If not there is some problem while assigning the weapon ids to variables |
new str[24];
for (new i = 0; i < 13; i ++) // if (playerData[playerid][gun][i] > 0 ...
{
format(str, sizeof(str), "gun%d", i);
INI_Int(str, playerData[playerid][gun][i]);
format(str, sizeof(str), "ammo%d", i);
INI_Int(str, playerData[playerid][ammo][i]);
}