PDA

View Full Version : Wont save money


cruising
04/10/2011, 08:51 PM
I cant figure this out why the script doesnt save the money, its the same principle to save admin lvls and that works fine, so why dont the money?

Code:
enum pInfo
{
Money,
Admin,
};

public OnPlayerConnect(playerid)
{
format(file, sizeof(file), "/Users/%s.ini", playername3);
if (dini_Exists(file))
{
PlayerInfo[playerid][Admin] = dini_Int(file, "Admin");
PlayerInfo[playerid][Money] = dini_Int(file, "Money");
}
return 1;
}

public OnPlayerRegister(playerid, password[])
{
dini_IntSet(file, "Admin", PlayerInfo[playerid][Admin]);
dini_IntSet(file, "Money", PlayerInfo[playerid][Money]);
}
return 1;
}

public OnPlayerLogin(playerid,password[])
{
PlayerInfo[playerid][Admin] = dini_Int(file, "Admin");
PlayerInfo[playerid][Money] = dini_Int(file, "Money");
}
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
if(dini_Exists(file))
{
dini_IntSet(file, "Admin", PlayerInfo[playerid][Admin]);
dini_IntSet(file, "Money", PlayerInfo[playerid][Money]);
}
return 1;
}

Tigerkiller
04/10/2011, 09:43 PM
you load it correct but you forgot to set the money

Scenario
04/10/2011, 09:44 PM
You need to OBTAIN their money value before saving, otherwise you are saving whatever value the money variable holds if that makes sense...

Naruto_Emilio
04/10/2011, 09:45 PM
Why don't you use y_ini it's much better and faster to use...

Tigerkiller
04/10/2011, 09:49 PM
Why don't you use y_ini it's much better and faster to use...

why you dont use mysql ? its the fastes

Scenario
04/10/2011, 09:51 PM
why you dont use mysql ? its the fastes

No, MySQL is actually really slow compared to many other systems (including y_ini). As of right now, y_ini is the fastest INI-based system. File-functions are always faster than anything, but they don't offer as many features without slowing the system down.

Naruto_Emilio
04/10/2011, 09:53 PM
why you dont use mysql ? its the fastes

You are wrong sir, it's not he fatest, it's the slowest* compared to y_ini.

Tigerkiller
04/10/2011, 09:56 PM
hmm ok never used y ini but i will try it

BACK TO TOPIC

Kush
05/10/2011, 01:13 AM
No, MySQL is actually really slow compared to many other systems (including y_ini). As of right now, y_ini is the fastest INI-based system. File-functions are always faster than anything, but they don't offer as many features without slowing the system down.

As these file based systems (y_ini, dini, dof2) derive from the native file functions, this is true. The point of these INI Systems are merely for simplicity. Comparison in speed does play a major factor, as y_ini takes less time to do these 'operations' should I say.

Steven82
05/10/2011, 03:14 AM
This is a REALLY easy fix..


public OnPlayerDisconnect(playerid, reason)
{
if(dini_Exists(file))
{
dini_IntSet(file, "Admin", PlayerInfo[playerid][Admin]);
dini_IntSet(file, "Money", GetPlayerMoney(playerid)); // Changed PlayerInfo[playerid][Money] to GetPlayerMoney(playerid);
}
return 1;
}