30.12.2012, 20:33
Hello.
I've noticed that when I have money Ingame and I /q on my script it doesn't save my money to the Database!
OnPlayerDisconnect calls the function "saveplayer(playerid)"
And it does work but it doesn't save the money, It counts it as 0. O_O.
Also, How would I make it load the money to the player when He spawns? The money from his account.
Current OnPlayerSpawn:
My "saveplayer" function.
Anyone know the resolutions!? been trying to figure it out for ages now!
I've noticed that when I have money Ingame and I /q on my script it doesn't save my money to the Database!
OnPlayerDisconnect calls the function "saveplayer(playerid)"
And it does work but it doesn't save the money, It counts it as 0. O_O.
Also, How would I make it load the money to the player when He spawns? The money from his account.
Current OnPlayerSpawn:
pawn Код:
public OnPlayerSpawn(playerid) {
// Let's check if the player has logged in. Have they not? Let's kick them.
new string[128];
if(playerVariables[playerid][pStatus] != 1){
if(playerVariables[playerid][pAdmin]){
format(string, sizeof(string), "SERVER: {FFFFFF}You are logged in as level %d administrator.", playerVariables[playerid][pAdmin]);
SendClientMessage(playerid, COLOR_NICERED, string);}
SetPlayerColor(playerid, COLOR_GREY);
GivePlayerMoney(playerid, playerVariables[playerid][pMoney]);
SendClientMessage(playerid, COLOR_GREY, "You need to login before you can spawn.");
return Kick(playerid);
}
return 1;
}
pawn Код:
stock savePlayer(playerid) {
// Let's save the player's information into the mysql database so when they login it can be reset.
// Before we do anything, we need to grab the most up-to-date information and save it into the player variables.
new
szQuery[512]; // Since we're going to save a lot of data, our query size will need to be big.
// We need to get the position and facing angle of the player, so we can save it. IF, they are logged in.
GetPlayerPos(playerid, playerVariables[playerid][pPos][0], playerVariables[playerid][pPos][1], playerVariables[playerid][pPos][2]);
GetPlayerFacingAngle(playerid, playerVariables[playerid][pPos][3]);
// Interior and virtual world too... In fact, everything else significant about the player that SA-MP can tell us.
playerVariables[playerid][pInterior] = GetPlayerInterior(playerid);
playerVariables[playerid][pVirtualWorld] = GetPlayerVirtualWorld(playerid);
GetPlayerHealth(playerid, playerVariables[playerid][pHealth]);
GetPlayerArmour(playerid, playerVariables[playerid][pArmour]);
GetPlayerMoney(playerid, playerVariables[playerid][pMoney]);
// We will now take the nformation we grabbed and input it to make a query.
// Remember the database ID? This is one instance of where it will be useful to use.
format(szQuery, sizeof(szQuery), "UPDATE players SET Health = '%f', Armour = '%f', PosX = '%f', PosY = '%f', PosZ = '%f', PosR = '%f'", playerVariables[playerid][pHealth], playerVariables[playerid][pArmour], playerVariables[playerid][pPos][0], playerVariables[playerid][pPos][1], playerVariables[playerid][pPos][2], playerVariables[playerid][pPos][3]);
format(szQuery, sizeof(szQuery), "%s, Interior = %d, Skin = %d, Money = %d WHERE ID = %d", szQuery, playerVariables[playerid][pInterior], playerVariables[playerid][pSkin], playerVariables[playerid][pMoney], playerVariables[playerid][pDBID]);
mysql_query(szQuery, THREAD_NO_RESULT, playerid, iConnectionHandle);
return 1;
}
Anyone know the resolutions!? been trying to figure it out for ages now!