01.06.2010, 20:09
Hello again,
This will be a difficult problem. But I hope anyone of you can resolv it. The problem is short but big. I canґt save the money from stats. When I disconnect the money wonґt save and in game the money donґt increase when I earn some. I know wait it donґt save but I canґt fix it ;( I need urgently help!
I know I must put something between OnPlayerDisconnect but I donґt know what and I donґt know really how to save money ;/
I would be grateful if someone help me ;(
This will be a difficult problem. But I hope anyone of you can resolv it. The problem is short but big. I canґt save the money from stats. When I disconnect the money wonґt save and in game the money donґt increase when I earn some. I know wait it donґt save but I canґt fix it ;( I need urgently help!
pawn Код:
enum PlayerData
{
Registered,
LoggedIn,
AdminLevel,
Password,
Kills,
Deaths,
Money,
PlayerIP
pawn Код:
public OnPlayerConnect(playerid)
{
if(playerIP[50] == playerIp[49])
{
SendClientMessage(playerid, COLOR_GREEN, "You have been automatically logged in! Welcome back to the server.");
PlayerInfo[playerid][Registered] = 1;
PlayerInfo[playerid][LoggedIn] = 1;
PlayerInfo[playerid][AdminLevel] = dini_Int(PlayerFile, "AdminLevel");
PlayerInfo[playerid][Kills] = dini_Int(PlayerFile, "Kills");
PlayerInfo[playerid][Deaths] = dini_Int(PlayerFile, "Deaths");
PlayerInfo[playerid][Money] = dini_Int(PlayerFile, "Money");
}
else
{
PlayerInfo[playerid][Registered] = 1;
PlayerInfo[playerid][LoggedIn] = 0;
SendClientMessage(playerid, COLOR_GREEN," Since you are registered, please use /login to login onto your account.");
}
pawn Код:
dcmd_login(playerid, params[])
{
new pName[24], PlayerFile[50], Pass[256], plrIP[50];
GetPlayerName(playerid, pName, sizeof(pName));
format(PlayerFile, sizeof(PlayerFile), "/users/%s.ini", pName);
if(PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You are already logged in!");
if(PlayerInfo[playerid][Registered] == 0) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: You are not registered! Use /register to register.");
if(sscanf(params, "s", Pass)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "Usage: /login [password]");
Pass = dini_Get(PlayerFile, "Password");
if(!strcmp(MD5_Hash(params), Pass, true))
{
GetPlayerIp(playerid, plrIP, sizeof(plrIP));
dini_Set(PlayerFile, "PlayerIP", plrIP);
SendClientMessage(playerid, COLOR_GREEN, "You have been succesfully logged in");
PlayerInfo[playerid][LoggedIn] = 1;
PlayerInfo[playerid][AdminLevel] = dini_Int(PlayerFile, "AdminLevel");
PlayerInfo[playerid][Kills] = dini_Int(PlayerFile, "Kills");
PlayerInfo[playerid][Deaths] = dini_Int(PlayerFile, "Deaths");
PlayerInfo[playerid][Money] = dini_Int(PlayerFile, "Money");
}
else
{
pawn Код:
dcmd_stats(playerid, params[])
{
new pName[24], PlayerFile[50], str[128], pDeaths[50], pKills[50], pMoney[50],targetid;
if(!strlen(params)) targetid = playerid;
else targetid = strval(params);
GetPlayerName(targetid, pName, sizeof(pName));
format(PlayerFile, sizeof(PlayerFile), "/users/%s.ini", pName);
if(!dini_Exists(PlayerFile)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "Usage: /stats [ID].");
if(dini_Exists(PlayerFile))
{
pDeaths[24] = dini_Int(PlayerFile, "Deaths");
pKills[24] = dini_Int(PlayerFile, "Kills");
pMoney[24] = dini_Int(PlayerFile, "Money");
new Float:Ratio=floatdiv(pKills[24], pDeaths[24]);
format(str, sizeof(str), " ||%sґs Statistics ||", pName);
SendClientMessage(playerid, COLOR_GREEN, str);
format(str, sizeof(str), "(Money): Money: %d", pMoney[24]);
SendClientMessage(playerid, COLOR_YELLOW, str);
format(str, sizeof(str), "(Stats): Kills: %d || Deaths: %d || Ratio: %.2f || Money: %d", pKills[24], pDeaths[24], Ratio, pMoney[24]);
SendClientMessage(playerid, COLOR_YELLOW, str);
I would be grateful if someone help me ;(