after spawning, player doesn't get his/her weapons
#1

Tile says almost everything.

Well, basically I made a timer, so after player spawns, they get health and armour (saves on logout) and should be the same with guns, but they don't get them.

OnPlayerSpawn:
PHP код:
SetTimerEx("LoadUserSpawn_data"500false"i"playerid); 
LoadUserSpawn_data:
PHP код:
forward LoadUserSpawn_data(playerid);
public 
LoadUserSpawn_data(playerid)
{
    new 
str[128];
    
// --------------------------
    
ResetPlayerMoney(playerid);
    
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); // <-- LOOK HERE
    // --------------------------
    
playerSpawned[playerid] = true;
    return 
1;

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

P.S. I already checked, and yes, weapons are saving.

Prove:
Reply
#2

Still doesn't work.
Reply
#3

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.

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

Try that.
Reply
#4

Where do you load all your values?
Reply
#5

Quote:
Originally Posted by Threshold
Посмотреть сообщение
Where do you load all your values?
OnPLayerFullyConnected. I use Emmet_'s "noclass.inc"

Quote:
Originally Posted by JordanZaundd
Посмотреть сообщение
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;
}
Try that.
Just tried, nothing. The guns are loading, but not giving. Because I checked the user_file.ini all the time, I even registered a few times more. Nothing.
Reply
#6

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
Reply
#7

Quote:
Originally Posted by -=Dar[K]Lord=-
Посмотреть сообщение
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
Yep, there was a mistake in loading function.

PHP код:
new str[24];
    for (new 
013++) // if (playerData[playerid][gun][i] > 0 ...
    
{
        
format(strsizeof(str), "gun%d"i);
        
INI_Int(strplayerData[playerid][gun][i]);
        
        
format(strsizeof(str), "ammo%d"i);
        
INI_Int(strplayerData[playerid][ammo][i]);
    } 
Now works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)