SA-MP Forums Archive
Mysql cache - 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 cache (/showthread.php?tid=414746)



Mysql cache - thefatshizms - 10.02.2013

Hello, I'm trying to convert to mysql r7 with cache functions but for some reason it's saying my money and admin 52 when actually my money is 0 and my admin is 4

pawn Код:
public OnPlayerConnect(playerid)
{
    mysql_function_query(Gconnection, "SELECT * FROM users WHERE `username`='thefatshizms'", true, "OnPlayerLogin", "d", "playerid");
    return 1;
}

forward OnPlayerLogin(playerid);
public OnPlayerLogin(playerid) {
    new rows, fields;
    cache_get_data(rows, fields, Gconnection);
    if(rows)
    {
        new temp[12];
        cache_get_field_content(0, "admin", temp);
        printf("thefatshizms admin level is %d", temp);
        cache_get_field_content(0, "money", temp);
        printf("thefatshizms money is %d", temp);
    }
    return 1;

}



Re: Mysql cache - MP2 - 10.02.2013

https://sampforum.blast.hk/showthread.php?tid=337810


Re: Mysql cache - thefatshizms - 10.02.2013

That's what I've been using to convert. But to me my code looks "fine" so I don't know if I have missed anything :/


Re: Mysql cache - ReVo_ - 10.02.2013

mysql_function_query(Gconnection, "SELECT * FROM users WHERE `username`='thefatshizms'", true, "OnPlayerLogin", "d", "playerid");

`username`='thefatshizms'

Why?

You should put player name..

format (query, sizeof query, "SELECT * FROM users WHERE `username`='%s'", player_name);

now change
mysql_function_query(Gconnection, "SELECT * FROM users WHERE `username`='thefatshizms'", true, "OnPlayerLogin", "d", "playerid");

to

mysql_function_query(Gconnection, query, true, "OnPlayerLogin", "d", "playerid");


Re: Mysql cache - thefatshizms - 10.02.2013

Ahem, I know how to do this, if didn't I wouldn't be converting i would be trying to learn it. I'm doing this because i like to TEST functions I haven't used yet before actually making something with it.

just used this:

pawn Код:
public OnPlayerConnect(playerid)
{
    mysql_function_query(Gconnection, "SELECT * FROM users WHERE `username`='thefatshizms'", true, "OnPlayerLogin", "d", "playerid");
    return 1;
}

forward OnPlayerLogin(playerid);
public OnPlayerLogin(playerid) {
    new rows, fields;
    cache_get_data(rows, fields, Gconnection);
    if(rows)
    {
        new temp[12];
        cache_get_row(0, 8, temp);
        printf("thefatshizms admin level is %d", temp);
        cache_get_row(0, 3, temp);
        printf("thefatshizms money is %d", temp);
    }
    return 1;

}
Still saying 52, I can give a screen shot of my table if needed.


AW: Mysql cache - Tommyx3 - 10.02.2013

Код:
public OnPlayerConnect(playerid)
{
    mysql_function_query(Gconnection, "SELECT * FROM users WHERE `username`='thefatshizms'", true, "OnPlayerLogin", "d", "playerid");
    return 1;
}

forward OnPlayerLogin(playerid);
public OnPlayerLogin(playerid) {
    new rows, fields;
    cache_get_data(rows, fields, Gconnection);
    if(rows)
    {
        new temp[12], temp2;
        cache_get_field_content(0, "admin", temp);
        temp2 = strval(temp);
        printf("thefatshizms admin level is %d", temp2);
        cache_get_field_content(0, "money", temp);
        temp2 = strval(temp);
        printf("thefatshizms money is %d", temp2);
    }
    return 1;

}



Re: AW: Mysql cache - thefatshizms - 10.02.2013

Quote:
Originally Posted by Tommyx3
Посмотреть сообщение
Код:
public OnPlayerConnect(playerid)
{
    mysql_function_query(Gconnection, "SELECT * FROM users WHERE `username`='thefatshizms'", true, "OnPlayerLogin", "d", "playerid");
    return 1;
}

forward OnPlayerLogin(playerid);
public OnPlayerLogin(playerid) {
    new rows, fields;
    cache_get_data(rows, fields, Gconnection);
    if(rows)
    {
        new temp[12], temp2;
        cache_get_field_content(0, "admin", temp);
        temp2 = strval(temp);
        printf("thefatshizms admin level is %d", temp2);
        cache_get_field_content(0, "money", temp);
        temp2 = strval(temp);
        printf("thefatshizms money is %d", temp2);
    }
    return 1;

}
Thanks, forgot to turn the string back into an int!