[MySQL] Position Help
#1

Hi guys i have got a problem, mysql isnt loading the positions as it should soo im sent to pos 0.

pawn Код:
// Part of code
enum Penum
{
    Float:posx,
    Float:posy,
    Float:posz,
    Float:angle
}

new Pinfo[MAX_PLAYERS][Penum]
Register Part

pawn Код:
new Query[256],pName[MAX_PLAYER_NAME],EscapedText[60], Float:x, Float:y, Float:z, Float:PAngle;
         GetPlayerName(playerid, pName, sizeof(pName));
         GetPlayerPos(playerid, x, y, z);
         GetPlayerFacingAngle(playerid, PAngle);
         mysql_real_escape_string(inputtext, EscapedText);
         format(Query,sizeof(Query),"INSERT PlayerInfo (Name, Password, Level, VIP, AdminLevel, FactionID, Money, RankID, Leader, Njailed, Ajailed, Sexo, Idade, x, y, z, Skin, Angle) VALUES ('%s', '%s', 0, 0, 0, 0, 5000, 0, 0, 0, 0, 0, 0, 0.00, 0.00, 0.00, 26, 0.00)", pName, EscapedText, x, y, z, PAngle);
         mysql_query(Query);
Loading Part

pawn Код:
new Query[128],pName[24];
   GetPlayerName(playerid,pName, sizeof(pName));
   format(Query, sizeof(Query),"SELECT * FROM `PlayerInfo` WHERE `Name` = '%s'", pName);
   mysql_query(Query);
   mysql_store_result();
   new datastr[256];
   while(mysql_fetch_row_format(Query, "|"))
   {
     mysql_fetch_field_row(datastr, "Money"); GivePlayerMoney(playerid, strval(datastr));
     mysql_fetch_field_row(datastr, "Level"); SetPlayerScore(playerid, strval(datastr));
     mysql_fetch_field_row(datastr, "VIP"); pInfo[playerid][VIP] = strval(datastr);
     mysql_fetch_field_row(datastr, "AdminLevel"); pInfo[playerid][AdminLevel] = strval(datastr);
     mysql_fetch_field_row(datastr, "FactionID"); pInfo[playerid][FactionID] = strval(datastr);
     mysql_fetch_field_row(datastr, "RankID"); pInfo[playerid][RankID] = strval(datastr);
     mysql_fetch_field_row(datastr, "Leader"); pInfo[playerid][Leader] = strval(datastr);
     mysql_fetch_field_row(datastr, "Njailed"); pInfo[playerid][Njailed] = strval(datastr);
     mysql_fetch_field_row(datastr, "Ajailed"); pInfo[playerid][Ajailed] = strval(datastr);
     mysql_fetch_field_row(datastr, "Sexo"); pInfo[playerid][Sexo] = strval(datastr);
     mysql_fetch_field_row(datastr, "Idade"); pInfo[playerid][Idade] = strval(datastr);
     mysql_fetch_field_row(datastr, "Skin"); pInfo[playerid][skin] = strval(datastr);
     mysql_fetch_field_row(datastr, "x"); pInfo[playerid][posx] = strval(datastr);
     mysql_fetch_field_row(datastr, "y"); pInfo[playerid][posy] = strval(datastr);
     mysql_fetch_field_row(datastr, "z"); pInfo[playerid][posz] = strval(datastr);
     mysql_fetch_field_row(datastr, "Angle"); pInfo[playerid][angle] = strval(datastr);
   }
   mysql_free_result();
   TogglePlayerSpectating(playerid, 0);
   SetSpawnInfo(playerid, 0, pInfo[playerid][skin], pInfo[playerid][posx], pInfo[playerid][posy], pInfo[playerid][posz], 0, 0, 0, 0, 0, 0, 0);
   SpawnPlayer(playerid);
   return 1;
Everything else works fine, any ideas?
Reply
#2

Change this:
pawn Код:
mysql_fetch_field_row(datastr, "x"); pInfo[playerid][posx] = strval(datastr);
     mysql_fetch_field_row(datastr, "y"); pInfo[playerid][posy] = strval(datastr);
     mysql_fetch_field_row(datastr, "z"); pInfo[playerid][posz] = strval(datastr);
     mysql_fetch_field_row(datastr, "Angle"); pInfo[playerid][angle] = strval(datastr);
To this:

pawn Код:
mysql_fetch_field_row(datastr, "x"); pInfo[playerid][posx] = floatstr(datastr);
     mysql_fetch_field_row(datastr, "y"); pInfo[playerid][posy] = floatstr(datastr);
     mysql_fetch_field_row(datastr, "z"); pInfo[playerid][posz] = floatstr(datastr);
     mysql_fetch_field_row(datastr, "Angle"); pInfo[playerid][angle] = floatstr(datastr);
Reply
#3

i did it but still it seems not to work yet :\
*bump*
Reply
#4

Verify that it's saving properly into the database. Open it and see.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)