Mysql pos and armour
#1

Hy.

I wan to save players health, armour and pos to mysql.
At first its work for my but it write someona and its broken. I dont know what the problem.
Can everyone help me?

How i can read and save the pos from mysql? And health?

A lot of thanks. By.
Reply
#2

Why do you want to use MySQL for such a simple stuff? I'd recommend using just the basic File Functions. Also it is really hard to start troubleshooting the problem you have if you're not giving any info on it, like the server log, statistics saving script or something else like that.
Reply
#3

I need mysql, because i read it from a webpage..
Yeah, its string, its my last try. (unter enum)
Код:
	pPosX[30],
	pPosY[30],
	pPosZ[30],
Its read the pos: (load player stat)
Код:
    cache_get_row(0, 13, temp); PlayerInfo[playerid][pPosX] = temp;
    cache_get_row(0, 14, temp); PlayerInfo[playerid][pPosY] = temp;
    cache_get_row(0, 15, temp); PlayerInfo[playerid][pPosZ] = temp;
Its the save: (save player stat)
Код:
	new Float: x, Float: y, Float: z;
	GetPlayerPos(playerid, x, y, z);

	mysql_format(sqldb, query, sizeof(query), "UPDATE users SET posx ='%f' WHERE nev ='%e'", x, GetName(playerid));
	mysql_query(sqldb, query);

	mysql_format(sqldb, query, sizeof(query), "UPDATE users SET posy ='%f' WHERE nev ='%e'", y, GetName(playerid));
	mysql_query(sqldb, query);

	mysql_format(sqldb, query, sizeof(query), "UPDATE users SET posz ='%f' WHERE nev ='%e'", z, GetName(playerid));
	mysql_query(sqldb, query);
After login
Код:
SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
Reply
#4

I think the load and the login part is wrong..
Reply
#5

up pls
Reply
#6

in the save ,edit yours to :
pawn Код:
new Float: x, Float: y, Float: z;
       GetPlayerPos(playerid, x, y, z);
       PlayerInfo[playerid][pPosX] = x;
       PlayerInfo[playerid][pPosY] = y;
       PlayerInfo[playerid][pPosZ] = z;
       mysql_format(sqldb, query, sizeof(query), "UPDATE users SET posx ='%f', posy ='%f',posz ='%f' WHERE nev ='%e'", PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ], GetName(playerid));
       mysql_query(sqldb, query);
you have to tell pawno that x = playerinfo[playerid][pposx] and y = PlayerInfo[playerid][pPosY] and z = PlayerInfo[playerid][pPosZ] , also you don't have to make more than one query, so i edited it to you to be one query.
Reply
#7

warning 213: tag mismatch in the " PlayerInfo[playerid][pPosX] = x;" and y and z.
but it still work. and the load i think not..
Код:
    cache_get_row(0, 0, temp); PlayerInfo[playerid][pID] = strval(temp);
    cache_get_row(0, 1, temp); PlayerInfo[playerid][pNev] = temp;
    cache_get_row(0, 2, temp); PlayerInfo[playerid][pJelszo] = temp;
    cache_get_row(0, 3, temp); PlayerInfo[playerid][pAdmin] = strval(temp);
    cache_get_row(0, 4, temp); PlayerInfo[playerid][pSzint] = strval(temp);
    cache_get_row(0, 5, temp); PlayerInfo[playerid][pFigyelmeztetes] = strval(temp);
    cache_get_row(0, 6, temp); PlayerInfo[playerid][pWV] = strval(temp);
    cache_get_row(0, 7, temp); PlayerInfo[playerid][pInt] = strval(temp);
    cache_get_row(0, 8, temp); PlayerInfo[playerid][pKorhaz] = strval(temp);
	// ban
    cache_get_row(0, 9, temp); PlayerInfo[playerid][pBanned] = strval(temp);
    cache_get_row(0, 10, temp); PlayerInfo[playerid][pBannedReason] = temp;
    cache_get_row(0, 11, temp); PlayerInfo[playerid][pBannAdmin] = temp;
    cache_get_row(0, 12, temp); PlayerInfo[playerid][pBannIdo] = temp;
	// pos
    cache_get_row(0, 13, temp); PlayerInfo[playerid][pPosX] = temp;
    cache_get_row(0, 14, temp); PlayerInfo[playerid][pPosY] = temp;
    cache_get_row(0, 15, temp); PlayerInfo[playerid][pPosZ] = temp;
    cache_get_row(0, 16, temp); PlayerInfo[playerid][pSkin] = strval(temp);
    //
    cache_get_row(0, 17, temp); PlayerInfo[playerid][pPenz] = strval(temp);
    cache_get_row(0, 18, temp); PlayerInfo[playerid][pElet] = floatstr(temp);
    cache_get_row(0, 19, temp); PlayerInfo[playerid][pPajzs] = floatstr(temp);
    cache_get_row(0, 20, temp); PlayerInfo[playerid][pNem] = strval(temp);
    cache_get_row(0, 21, temp); PlayerInfo[playerid][pBirthM] = temp;
    cache_get_row(0, 22, temp); PlayerInfo[playerid][pBirthD] = temp;
    cache_get_row(0, 23, temp); PlayerInfo[playerid][pBirthY] = temp;
    cache_get_row(0, 24, temp); PlayerInfo[playerid][pJob] = strval(temp);
    cache_get_row(0, 25, temp); PlayerInfo[playerid][pTel] = strval(temp);
    cache_get_row(0, 26, temp); PlayerInfo[playerid][pTelSzam] = strval(temp);
    cache_get_row(0, 27, temp); PlayerInfo[playerid][pSzemelyi] = strval(temp);
	cache_get_row(0, 28, temp); PlayerInfo[playerid][pSzemelyiSz] = strval(temp);
	cache_get_row(0, 29, temp); PlayerInfo[playerid][pUtlevel] = strval(temp);
	cache_get_row(0, 30, temp); PlayerInfo[playerid][pJogsiA] = strval(temp);
	cache_get_row(0, 31, temp); PlayerInfo[playerid][pJogsiB] = strval(temp);
	cache_get_row(0, 32, temp); PlayerInfo[playerid][pJogsiC] = strval(temp);
	cache_get_row(0, 33, temp); PlayerInfo[playerid][pHaz] = strval(temp);
	cache_get_row(0, 34, temp); PlayerInfo[playerid][pHazSz] = strval(temp);
	cache_get_row(0, 35, temp); PlayerInfo[playerid][pBszSzam] = strval(temp);
	cache_get_row(0, 36, temp); PlayerInfo[playerid][pBszPass] = temp;
	cache_get_row(0, 37, temp); PlayerInfo[playerid][pFrakcio] = strval(temp);
	cache_get_row(0, 38, temp); PlayerInfo[playerid][pFrRang] = strval(temp);
	cache_get_row(0, 39, temp); PlayerInfo[playerid][pFrLeader] = strval(temp);
	cache_get_row(0, 40, temp); PlayerInfo[playerid][pKorozott] = strval(temp);
	cache_get_row(0, 41, temp); PlayerInfo[playerid][pKorozottLeiras] = temp;
all load is ok, but the pos and health is not working
Reply
#8

Код:
	if(dialogid == LOGIN_DIALOG)
	{
		if(!response) return Kick(playerid);
		if(strcmp(inputtext, PlayerInfo[playerid][pJelszo], true) == 0)
		{
			SetPlayerPos(playerid, PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid]
                        .....
[pPosZ]);
its my setlayepos.. and its not working.
after this i put this code:
Код:
			format(string, sizeof(string), "%s %s %s", PlayerInfo[playerid][pPosX], PlayerInfo[playerid][pPosY], PlayerInfo[playerid][pPosZ]);
			SendClientMessage(playerid, -1, string);
and its working..
[19:07:23] -211.596588 1133.683105 22.185123
Reply
#9

edit this :
pawn Код:
cache_get_row(0, 13, temp); PlayerInfo[playerid][pPosX] = temp;
    cache_get_row(0, 14, temp); PlayerInfo[playerid][pPosY] = temp;
    cache_get_row(0, 15, temp); PlayerInfo[playerid][pPosZ] = temp;
to this:
pawn Код:
cache_get_row(0, 13, temp); PlayerInfo[playerid][pPosX] = strval(temp);
    cache_get_row(0, 14, temp); PlayerInfo[playerid][pPosY] = strval(temp);
    cache_get_row(0, 15, temp); PlayerInfo[playerid][pPosZ] = strval(temp);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)