stats not updating - 
facekche -  01.08.2015
so ive been trying to fix a problem with my /stats command or somewhere within my login/register system...
this is the code for the cmd
Код:
CMD:stats(playerid, params[])
{
	new string[40];
	new kills = PlayerInfo[playerid][pKills];
	new deaths = PlayerInfo[playerid][pDeaths];
	new exp = PlayerInfo[playerid][pExp];
	format(string, sizeof(string), "† Kills: %d † Deaths: %d † Experience: %d †", kills, deaths, exp);
	SendClientMessage(playerid, COLOR_GREEN, string);
	return 1;
}
 but it returns 0 for all the stats in game, even if i have amounts in each
Re: stats not updating - 
xVIP3Rx -  01.08.2015
Use this to debug it.
pawn Код:
CMD:stats(playerid, params[])
{
    new string[128];
    format(string, sizeof(string), "† Kills: %d † Deaths: %d † Experience: %d †", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pExp]);
    SendClientMessage(playerid, COLOR_GREEN, string);
    PlayerInfo[playerid][pKills] ++;
    PlayerInfo[playerid][pDeaths]++;
    PlayerInfo[playerid][pExp]   ++;
    
    format(string, sizeof(string), "† Kills: %d † Deaths: %d † Experience: %d †", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pExp]);
    SendClientMessage(playerid, COLOR_GREEN, string);
    return 1;
}
 
Also show me how do you increase it.
Re: stats not updating - 
Keyhead -  01.08.2015
Make sure that you increase both of the variables OnPlayerDeath.
Re: stats not updating - 
facekche -  01.08.2015
yes look at my onplayerdeath
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	PlayerInfo[killerid][pKills] ++;
	PlayerInfo[playerid][pDeaths] ++;
	PlayerInfo[killerid][pExp] +=5;
	PlayerInfo[killerid][Money] +=15;
	PlayerInfo[playerid][Money] -=5;
	SetPlayerScore(killerid, PlayerInfo[killerid][pExp]);
	ResetPlayerMoney(killerid);
	ResetPlayerMoney(playerid);
	GivePlayerMoney(killerid, PlayerInfo[killerid][Money]);
	SendDeathMessage(killerid, playerid, reason);
}
 
Re: stats not updating - 
xVIP3Rx -  01.08.2015
Okay, you should check if killerid = invalid_player_id though
Also, are you making any kills/deaths before doing /stats ?
Re: stats not updating - 
facekche -  02.08.2015
oh i might have tested using /kill when i had a variable in that command checking if the player was logged in so my stats werent updating (deaths) because i wasnt being killed
ill take a look at it when i can and post if i have a problem
Re: stats not updating - 
facekche -  02.08.2015
ok so i tried with the code u showed me;
Код:
CMD:stats(playerid, params[])
{
	new string[128];
	format(string, sizeof(string), "† Kills: %d † Deaths: %d † Experience: %d †", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pExp]);
	SendClientMessage(playerid, COLOR_GREEN, string);
	PlayerInfo[playerid][pKills] ++;
	PlayerInfo[playerid][pDeaths]++;
	PlayerInfo[playerid][pExp]   ++;
	
	format(string, sizeof(string), "† Kills: %d † Deaths: %d † Experience: %d †", PlayerInfo[playerid][pKills], PlayerInfo[playerid][pDeaths], PlayerInfo[playerid][pExp]);
	SendClientMessage(playerid, COLOR_GREEN, string);
	return 1;
}
 the first string returns 0 in all the variables but the second returns 1 in each....
what could be the problem? im using an account that i can confirm has several of each (kills,deaths,exp...)
this is my onplayerdeath pretty much
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	PlayerInfo[killerid][pKills] ++;
	PlayerInfo[playerid][pDeaths] ++;
	PlayerInfo[killerid][pExp] +=5;
	PlayerInfo[killerid][Money] +=15;
	PlayerInfo[playerid][Money] -=5;
	SetPlayerScore(killerid, PlayerInfo[killerid][pExp]);
	ResetPlayerMoney(killerid);
	ResetPlayerMoney(playerid);
	GivePlayerMoney(killerid, PlayerInfo[killerid][Money]);
	SendDeathMessage(killerid, playerid, reason);
        return 1;
}
 maybe my account system isnt working properly?
Re: stats not updating - 
xVIP3Rx -  02.08.2015
If you tried killing yourself few times and it's still giving zeros, then your probably resetting them to zero somewhere in the script.
Re: stats not updating - 
facekche -  02.08.2015
ive fixed the /stats problem, but now i know whats the problem with my saving thing... my onplayerconnect callback has nothing about loading a users stats into the variables, so therefore every time a user connects, his stats are pretty much reset to 0...
using dini, how could i load a users stats from their file to the variables? like i know how to set values into files when a player disconnects using dini_IntSet but idk about when one connects
Re: stats not updating - 
xVIP3Rx -  02.08.2015
[TUT] Creating a Register System using Dini