MySQL how do I grab offline database ID?
#1

So I have a /osetname command and I want to save it in logs with the database ID of the target, but I'm quite clueless on how to grab that DBID. Still learning MySQL, I've searched on the internet and so on, but I can't figure it out.. Anyone knows? Right now it gives this error. I've marked the code in question red.

Код:
./inc/stock.inc(221) : error 035: argument type mismatch (argument 3)
I know it gives this error because it's not a indexed value, but how do I solve it so I can grab that id?

Код:
forward OnOSetNameProcess(playerid, newname[], oldname[]);
public OnOSetNameProcess(playerid, newname[], oldname[])
{
    new rows, fields, str[128];
    cache_get_data(rows, fields);

    if(!rows)
        return SCM(playerid, COLOR_ERROR, "That username does not exist.");

    format(str,sizeof(str), "You have set %s their name to %s.", oldname, newname);
    SCM(playerid, COLOR_COOLBLUE, str);
    SCM(playerid, COLOR_INFO, "Please inform the player of this change, or they might lose their account.");

    new targetid = cache_get_field_content_int(0, "acc_dbid", oldname);

    format(str, sizeof(str), "%s(%i)[%i] orenamed %s[%i] to %s", ReturnName(playerid), playerid, PlayerInfo[playerid][pDBID], oldname, targetid, newname);
    StatsLog(str);

    new query[128];
    mysql_format(ourConnection, query, sizeof(query), "UPDATE `accounts` SET `acc_name` = '%e' WHERE `acc_name` = '%e' LIMIT 1", newname, oldname);
    mysql_tquery(ourConnection, query);
    return 1;
}
Reply
#2

Hey,

Grab the latest version of MySQL by BlueG;
https://github.com/pBlueG/SA-MP-MySQL/releases

Assuming your query only expects one row;
PHP код:
new
    
resultId
;
cache_get_value_name_int(0"acc_dbid"resultId); 
Reply
#3

Quote:
Originally Posted by d1git
Посмотреть сообщение
Hey,

Grab the latest version of MySQL by BlueG;
https://github.com/pBlueG/SA-MP-MySQL/releases

Assuming your query only expects one row;
PHP код:
new
    
resultId
;
cache_get_value_name_int(0"acc_dbid"resultId); 
Hey! Thanks a lot for your help so far. I want to use the latest version but a lot of things changed, and as a beginner I struggle to figure it all out. However, I guess I will try it out.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)