MySql Prob.
#1

idk why its occuring to me and idk to solve it. Im using BlueG's R7 mysql plugin.
Im sure that line is the one causing Problems.

The Whole Callback
pawn Код:
public SavePlayer(playerid)
{
    new IP[20];
    GetPlayerIp(playerid, IP, 20);
    new Query[500];
    new QueryFinal[1500] = "UPDATE `playerdata` SET ";
    format(Query, sizeof(Query), "`username`='%s',`Deaths`='%d',`ArmstreaksInHand`='%d', `TimePlayer`='%d', `Rank`='%d', `Achievements`='%d', `HeadShots`='%d', `LongShots`='%d', `IP`='%s', `Kills`='%d',`Cash`='%d', `ArmstreakRecieved`='%d',`PlayerXP`='%d',`PlayerRankNumber`='%d' WHERE `Username`='%s'", ReturnPlayerName(playerid),PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pArmstreak],PlayerInfo[playerid][pTimePlayer],PlayerInfo[playerid][pRank],PlayerInfo[playerid][pAchievements],PlayerInfo[playerid][pHeadShots], PlayerInfo[playerid][pLongShots], IP, PlayerInfo[playerid][pKills],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pArmstreakRecieved],PlayerInfo[playerid][pXP],PlayerInfo[playerid][pRankNumber],ReturnPlayerName(playerid));
    strcat(QueryFinal, Query);
    mysql_tquery(conn, QueryFinal, false, "OnQuerySend", "");
    return 1;
}
That whole line
pawn Код:
format(Query, sizeof(Query), "`username`='%s',`Deaths`='%d',`ArmstreaksInHand`='%d', `TimePlayer`='%d', `Rank`='%d', `Achievements`='%d', `HeadShots`='%d', `LongShots`='%d', `IP`='%s', `Kills`='%d',`Cash`='%d', `ArmstreakRecieved`='%d',`PlayerXP`='%d',`PlayerRankNumber`='%d' WHERE `Username`='%s'", ReturnPlayerName(playerid),PlayerInfo[playerid][pDeaths],PlayerInfo[playerid][pArmstreak],PlayerInfo[playerid][pTimePlayer],PlayerInfo[playerid][pRank],PlayerInfo[playerid][pAchievements],PlayerInfo[playerid][pHeadShots], PlayerInfo[playerid][pLongShots], IP, PlayerInfo[playerid][pKills],PlayerInfo[playerid][pCash],PlayerInfo[playerid][pArmstreakRecieved],PlayerInfo[playerid][pXP],PlayerInfo[playerid][pRankNumber],ReturnPlayerName(playerid));
Prob:
pawn Код:
DDM.pwn(362) : error 017: undefined symbol "cache_get_data"
DDM.pwn(361) : warning 203: symbol is never used: "field"
DDM.pwn(378) : error 017: undefined symbol "cache_get_data"
DDM.pwn(377) : warning 203: symbol is never used: "field"
DDM.pwn(388) : error 017: undefined symbol "mysql_tquery"
DDM.pwn(397) : error 075: input line too long (after substitutions)
DDM.pwn(398) : error 017: undefined symbol "playeri"
DDM.pwn(399) : error 017: undefined symbol "d"
DDM.pwn(399) : error 029: invalid expression, assumed zero
DDM.pwn(399) : error 029: invalid expression, assumed zero
DDM.pwn(399) : fatal error 107: too many error messages on one line
its just because of that line (it worked before but after i got a new HDD and forgot to save a bkup D: )
Im stuck in this line for some time.

Made a post in "Little Coding Question" but i couldn't get a fix. Hope someone help me with this

Tried R33, R5 and R7 with tquery and mysql_function_query
Reply
#2

Bump
Reply
#3

Idk if it solves the problem, but I think you need to change "mysql_tquery" to "mysql_query"
Reply
#4

Quote:
Originally Posted by Conradus
Посмотреть сообщение
Idk if it solves the problem, but I think you need to change "mysql_tquery" to "mysql_query"
Nice solution.


@OP:

Firstly. mysql_function_query was available till R7 to R21, after that mysql_tquery was introduced but the query is now cache only.

About the 'cache_get_data'. Where it is coming from? Use cache_get_row_count for getting row counts and cache_get_field_count for getting field counts which is better than getting both fields, rows and passing into a variable which is little slow.

Also, just use if it's a update query.

pawn Код:
mysql_tquery(conn, QueryFinal);
Also, please look the native before doing silly stuff:

pawn Код:
native mysql_tquery(connectionHandle, query[], callback[] = "", format[] = "", {Float,_}:...);
Use, wiki page if you want to know about all the natives.
Reply
#5

I asked another person to script it but he told me to ask in forums about to prob. will try what u say.
What is the one causing Problems?

EDIT:
pawn Код:
public CheckAccount(playerid, account[])
{
    new rows, field;
    cache_get_data(rows, field);
    if(rows>=1)
    {
        ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Welcome back","Welcome back to Contract Wars!\n\nType in your password below to login","Login","Leave");
        accountExists[playerid] = true;
    }
    else
    {
        ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_PASSWORD, "New account","Please input your password below to register a account","Register","Leave");
        accountExists[playerid] = false;
    }
    return 1;
}
public CheckAccountEx(account[])
{
    new rows, field;
    cache_get_data(rows, field);
    if(rows >= 1) { QueryState = true; }
    else { QueryState = false; }
    return QueryState;
}
cache_get_data comes in these two lines.
line 359-382

Edit: If i use cache_get_row_count(), it says error 017: undefined symbol "cache_get_row_count"
Reply
#6

Quote:
Originally Posted by newbie scripter
Посмотреть сообщение
I asked another person to script it but he told me to ask in forums about to prob. will try what u say.
What is the one causing Problems?

EDIT:
pawn Код:
public CheckAccount(playerid, account[])
{
    new rows, field;
    cache_get_data(rows, field);
    if(rows>=1)
    {
        ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Welcome back","Welcome back to Contract Wars!\n\nType in your password below to login","Login","Leave");
        accountExists[playerid] = true;
    }
    else
    {
        ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_PASSWORD, "New account","Please input your password below to register a account","Register","Leave");
        accountExists[playerid] = false;
    }
    return 1;
}
public CheckAccountEx(account[])
{
    new rows, field;
    cache_get_data(rows, field);
    if(rows >= 1) { QueryState = true; }
    else { QueryState = false; }
    return QueryState;
}
cache_get_data comes in these two lines.
line 359-382

Edit: If i use cache_get_row_count(), it says error 017: undefined symbol "cache_get_row_count"
pawn Код:
if(rows >= 1) // Nah, no need to do like this.

if(rows) // There are rows found!

if(!rows) // No rows found!

// OR

if(rows)
{
    // Found rows
}
else
{
    // No rows found
}

// If you really want to use the cache_get_data, just simply.

new rows, field;
cache_get_data(rows, field);
#undef fields
// OR if you're getting fields so
#undef rows

// Little bit simplifying your CheckAccountEx function

public CheckAccountEx(account[])
{
    new rows, field;
    cache_get_data(rows, field);
    #undef field
    if(rows)
        QueryState = true;
    else
        QueryState = false;
    return (QueryState ? true : false); // IDK, maybe just return QueryState. (Not needed this I guess)
}
Are you REALLY sure that you are using the latest release of BlueG's plugin R38?
https://github.com/pBlueG/SA-MP-MySQL/releases

Eh, you don't need to do this "accountExists[playerid]" variable at all. You can just simply get the rows and save them to the player variables instead of doing that afterwards. Waste of memory.
Reply
#7

pawn Код:
public CheckAccount(playerid, account[])
{
    new rows, field;
    cache_get_data(rows, field); // 362
    #undef field // 363
    if(rows) // 364
    {
        ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Welcome back","Welcome back to Contract Wars!\n\nType in your password below to login","Login","Leave");
        accountExists[playerid] = true;
    }
    else
    {
        ShowPlayerDialog(playerid, REGISTER, DIALOG_STYLE_PASSWORD, "New account","Please input your password below to register a account","Register","Leave");
        accountExists[playerid] = false;
    }
    return 1;
}

public CheckAccountEx(account[])
{
    new rows, field;
    cache_get_data(rows, field);
    #undef field
    if(rows)
        QueryState = true;
    else
        QueryState = false;
    return QueryState;
}
Errors:
pawn Код:
DDM.pwn(362) : error 017: undefined symbol "cache_get_data"
DDM.pwn(363) : error 017: undefined symbol "field"
DDM.pwn(363) : error 029: invalid expression, assumed zero
DDM.pwn(363 -- 364) : warning 215: expression has no effect
DDM.pwn(364) : error 001: expected token: ";", but found "if"
DDM.pwn(364) : fatal error 107: too many error messages on one lin
Tried cache_get_row_count instead of cache_get_data but got more errors
Reply
#8

From where are you sending the query for CheckAccount? And AFAIK, there's nothing except a wrong version that could cause an unknown symbol error.
Reply
#9

pawn Код:
CheckAccountExist(playerid, account[])
{
    if(IsPlayerNPC(playerid)) return 0;
    new Query[90];
    format(Query, sizeof(Query), "SELECT * FROM `playerdata` WHERE Username='%s'", account);
   mysql_tquery(conn, Query, true, "CheckAccount", "is", playerid, account);
    return 1;
}
Reply
#10

bump and the place i use CheckAccountExist is
pawn Код:
public OnPlayerConnect(playerid)
{
        // other things
        CheckAccountExist(playerid, ReturnPlayerName(playerid));
       // other things
}
and ReturnPlayerName:
pawn Код:
ReturnPlayerName(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    return pName;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)