PDA

View Full Version : AwkwardSQL


x96664
24/09/2013, 03:39 PM
<Moved to a new topic>

x96664
24/09/2013, 04:51 PM
Bump.

x96664
25/09/2013, 04:18 PM
Bump! I bump my post because I don't want to create a whole new topic as many people there do/

maxisaibot
25/09/2013, 04:39 PM
So there comes the first problem, when player leaves the server the stored values are set to all other players in the database, so when someone logs it will set him the same stats, that the last player who left the server had. Let me just note that it doesn't change the passwords, names and ID's.

find

format(query, sizeof(query), "UPDATE players SET Health = %.1f, Armor = %0.f, Interior = %d, VW = %d, Skin = %d, X = %f, Y = %f, Z = %f, A = %f WHERE Name = '%s'", HP, AP, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid), GetPlayerSkin(playerid), X, Y, Z, A, gName);

change with

format(query, sizeof(query), "UPDATE players SET Health = %.1f, Armor = %0.f, Interior = %d, VW = %d, Skin = %d, X = %f, Y = %f, Z = %f, A = %f WHERE Name = '%s'", HP, AP, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid), GetPlayerSkin(playerid), X, Y, Z, A, GetPName(playerid));


gName not defined you must use GetPName(playerid) for get player name ;)

How to load the player co-ordinates on his first spawn (maybe using my variable FirstSpawn)?

find this lines ( in public LoadStats(playerid) )

SetPlayerHealth(playerid, PInfo[playerid][pHealth]);
SetPlayerArmour(playerid, PInfo[playerid][pArmor]);
SetPlayerInterior(playerid, PInfo[playerid][pInterior]);
SetPlayerVirtualWorld(playerid, PInfo[playerid][pVirtualWorld]);
SetPlayerSkin(playerid, PInfo[playerid][pSkin]);
SetPlayerPos(playerid, PInfo[playerid][pX], PInfo[playerid][pY], PInfo[playerid][pZ]);
SetPlayerFacingAngle(playerid, PInfo[playerid][pA]);

Use this codes on public OnPlayerSpawn(playerid). This values 0.0 if user not registered. So you must add extra call for this is first spawn with sql user or new register user. If you want when players died they spawn with same location, use getposition in onplayerdeath btw.

x96664
25/09/2013, 05:01 PM
find

format(query, sizeof(query), "UPDATE players SET Health = %.1f, Armor = %0.f, Interior = %d, VW = %d, Skin = %d, X = %f, Y = %f, Z = %f, A = %f WHERE Name = '%s'", HP, AP, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid), GetPlayerSkin(playerid), X, Y, Z, A, gName);

change with

format(query, sizeof(query), "UPDATE players SET Health = %.1f, Armor = %0.f, Interior = %d, VW = %d, Skin = %d, X = %f, Y = %f, Z = %f, A = %f WHERE Name = '%s'", HP, AP, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid), GetPlayerSkin(playerid), X, Y, Z, A, GetPName(playerid));



Okay, thank you for the response, I will try it and tell you the result.

Edit:
new
gName[MAX_PLAYER_NAME], //actually gName is defined there
IMDb,
Registered[MAX_PLAYERS],
Logged[MAX_PLAYERS],
PInfo[MAX_PLAYERS][PlayerInfo];

And it's not the problem its still doing the same thing.

If I add this in the OnPlayerSpawn callback it will spawn me everytime when I die at the stored position.