SA-MP Forums Archive
mysql r7 - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: mysql r7 (/showthread.php?tid=418819)



mysql r7 - speed258 - 26.02.2013

hi guys in new r7 plungin blueg is a new funcktion cache_get_row so how correctly know where and which row is getting server to player? example:
Код:
cache_get_row(0, 6, temp), sscanf(temp, "f", zpos[0]),
	cache_get_row(0, 7, temp), sscanf(temp, "f", zpos[1]),
	cache_get_row(0, 8, temp), sscanf(temp, "f", zpos[2]),
in my mysql database x.y,z pos is X - 6, Y -7, Z -8 but still nothing i get any ideas what can be wrong?


Re: mysql r7 - speed258 - 26.02.2013

Quote:

stock CheckAccount(playerid)
{
format(query, sizeof(query), "SELECT SQLID, Password FROM `profiles` WHERE `Name` = '%s' LIMIT 1", PlayerName(playerid));
mysql_function_query(data, query, true, "checkacc", "i", playerid);
printf("SQLID nick %s",PlayerName(playerid));//here i get NULL
return 1;
}

forward checkacc(playerid);
public checkacc(playerid)
{
if(playerid != INVALID_PLAYER_ID)// if the player is still connected
{
new rows, fields;
cache_get_data(rows, fields, data);

if(rows)
{
new id[30];
cache_get_row(0, 0, id, duomenys); usrDB[playerid][SQLID] = strval(id);
cache_get_row(0, 2, usrDB[playerid][password], data);
printf("SQLID nickslap %s",usrDB[playerid][password]); /// and here i get NULL
ShowPlayerDialog(playerid,3,DIALOG_STYLE_PASSWORD, "{2981FC}RPG {FFFFFF}• {F82222}Login","{FFFFFF}Please login:{FFFFFF}","Resume","Quit");
}
else
{
ShowPlayerDialog(playerid,2,DIALOG_STYLE_PASSWORD, "{2981FC}RPG {FFFFFF}• {F82222}Register","{FFFFFF}Please register,"Register","quit");
}
}
return 1;

and login system
Quote:

if(dialogid == 3) //
{
if(!response) //
{
SendClientMessage(playerid,BLUE,"RPG: Kick ASS");
Kick(playerid);
}
if(response) //
{
new textt[40];
if(sscanf(inputtext,"s[18]",textt)) return ShowPlayerDialog(playerid,3,DIALOG_STYLE_PASSWORD, "{2981FC}RPG {FFFFFF}• {F82222}Login","{FFFFFF}Insert Your password:","Resume","Quit");
printf("Text %s",textt); //here i get what i write into dialog
printf("Textas %s",usrDB[playerid][password]); //here i get NULL
if(strcmp(textt, usrDB[playerid][password]))
LoadAccount(playerid);
}
else
{
connect[playerid]++;
if(connect[playerid] == MAX_connect)
{
return SendClientMessage(playerid, RED, "RPG: out of wrong moves");
}
ShowPlayerDialog(playerid,3,DIALOG_STYLE_PASSWORD, "{2981FC}RPG {FFFFFF}• {F82222}Login","{FFFFFF}Your password is incorrect type new","resume","quit");

}
}
}

so any ideas what can be wrong whit this script?


Re: mysql r7 - speed258 - 26.02.2013

and here my mysql database any ideas what can be wrong?


Re: mysql r7 - speed258 - 26.02.2013

anyone please help my to solve the problem


Re: mysql r7 - Misiur - 26.02.2013

1. Set your database and tables encoding to utf8_general_ci - this will spare you problems later
2. Use [ pawn] tag, not quotes
3. Missing quote in checkacc
4. Use mysql_format, not normal format (sql injection and stuff)
5. Wrong index in cache_get_row (2 instead of 1)

pawn Код:
stock CheckAccount(playerid)
{
    mysql_format(data, query, "SELECT SQLID, Password FROM `profiles` WHERE `Name` = '%e' LIMIT 0,1", PlayerName(playerid));
    mysql_function_query(data, query, true, "checkacc", "i", playerid);
    return 1;
}

forward checkacc(playerid);
public checkacc(playerid)
{
    if(playerid != INVALID_PLAYER_ID)// if the player is still connected
    {
        new rows, fields;
        cache_get_data(rows, fields, data);

        if(rows)
        {
            new id[30];
            cache_get_row(0, 0, id, data);
            usrDB[playerid][SQLID] = strval(id);
            cache_get_row(0, 1, usrDB[playerid][password], data);
            ShowPlayerDialog(playerid,3,DIALOG_STYLE_PASSWORD, "{2981FC}RPG {FFFFFF}• {F82222}Login","{FFFFFF}Please login:{FFFFFF}","Resume","Quit");
        }
        else
        {
            ShowPlayerDialog(playerid,2,DIALOG_STYLE_PASSWORD, "{2981FC}RPG {FFFFFF}• {F82222}Register","{FFFFFF}Please register","Register","quit");
        }
    }
    return 1;
}



Re: mysql r7 - speed258 - 26.02.2013

pawn Код:
if(dialogid == 3) //
{
if(!response) //
{
SendClientMessage(playerid,BLUE,"RPG: Kick ASS");
Kick(playerid);
}
if(response) //
{
new textt[40];
if(sscanf(inputtext,"s[18]",textt)) return ShowPlayerDialog(playerid,3,DIALOG_STYLE_PASSWORD, "{2981FC}RPG {FFFFFF}• {F82222}Login","{FFFFFF}Insert Your password:","Resume","Quit");
printf("Text %s",textt); //here i get what i write into dialog
printf("Textas %s",usrDB[playerid][password]); //here i get NULL
if(strcmp(textt, usrDB[playerid][password]))
LoadAccount(playerid);
}
else
{
connect[playerid]++;
if(connect[playerid] == MAX_connect)
{
return SendClientMessage(playerid, RED, "RPG: out of wrong moves");
}
ShowPlayerDialog(playerid,3,DIALOG_STYLE_PASSWORD, "{2981FC}RPG {FFFFFF}• {F82222}Login","{FFFFFF}Your password is incorrect type new","resume","quit");

}
}
}
and this code is correct? how about LoadAccount(playerid) better use here or after playerspawn callback?


Re: mysql r7 - Misiur - 26.02.2013

I don't know if code is correct, run it maybe? Placement is good, because you might want to load some spawn-related data (position, skin or something)


Re: mysql r7 - speed258 - 26.02.2013

pawn Код:
stock LoadAccount(playerid)
{
    mysql_format(data, query, "SELECT * FROM `users` WHERE `SQLID` = %i", usrDB[playerid][SQLID]);
    mysql_function_query(duomenys, query, true, "LoadPlayerData", "i", playerid);
}
here i prepare load data
pawn Код:
stock LoadPlayerData(playerid)
{
new Float:zpos[4];
    new temp[140];
cache_get_row(0, 5, temp), sscanf(temp, "f", zpos[0]), // x
    cache_get_row(0, 6, temp), sscanf(temp, "f", zpos[1]),//y
    cache_get_row(0, 7, temp), sscanf(temp, "f", zpos[2]),//z
    cache_get_row(0, 8, temp), sscanf(temp, "f", zpos[3]);//angle
SetPlayerPos(playerid,zpos[0],zpos[1],zpos[2]);
    //
    SetPlayerFacingAngle(playerid,zpos[3]);
here my load data and nothing loading i'm still falling from sky but in my database x,y,z,angle id is X(6), Y(7), Z(, ANGLE(9) any ideas why i'am falling?


Re: mysql r7 - Misiur - 26.02.2013

pawn Код:
cache_get_row(0, 5, temp), sscanf(temp, "f", zpos[0]), // x
cache_get_row(0, 6, temp), sscanf(temp, "f", zpos[1]),//y
cache_get_row(0, 7, temp), sscanf(temp, "f", zpos[2]),//z
cache_get_row(0, 8, temp), sscanf(temp, "f", zpos[3]);//angle
1. Move index back by 1 (in PMA they start at 1, cache_get_row is 0 based)
2. use floatval

pawn Код:
cache_get_row(0, 4, temp);
zpos[0] = floatstr(temp);
cache_get_row(0, 5, temp);
zpos[1] = floatstr(temp);
cache_get_row(0, 6, temp);
zpos[2] = floatstr(temp);
cache_get_row(0, 7, temp);
zpos[3] = floatstr(temp);
#e: oops, stupid me


Re: mysql r7 - speed258 - 26.02.2013

but if i want use sscanf so no way to make on sscanf just floatstr? you see on sscanf simplier to use to me so every script if possible use sscanf