Help please MySQL R34
#4

pawn Код:
GetAccountID(playerid)
{
    // Setup local variables
    new query[128], sn[24];

    // Get playername
    GetPlayerName(playerid, sn, sizeof(sn));
    // Format the query to get the ID from the player's account (limit the amount of rows to 1 to prevent MySQL searching through the entire database)
    format(query, 128,"SELECT ID FROM "TABLE_ACCOUNT" WHERE Name = '%s' LIMIT 1", sn);
    // Execute the threaded query and call the callback "OnAccountIDLoad" with "playerid" as parameter when MySQL finished executing the query
    mysql_tquery(1, query, "OnAccountIDLoad", "i", playerid);

    return 0;
}

// This callback is called by MySQL when the query has finished execution
forward OnAccountIDLoad(playerid);
public OnAccountIDLoad(playerid)
{
    // Check if there was a result
    if (cache_get_row_count() == 1)
    {
        // Get the contents of the "ID" field as an integer (from row 0) and store it
        PlayerInfo[playerid][pID] = cache_get_field_content_int(0, "ID");
    }

    // Clear the cache-data upon exiting this callback
    return 1;
}
Reply


Messages In This Thread
Help please MySQL R34 - by Size - 03.02.2014, 12:16
Re: Help please MySQL R34 - by PowerPC603 - 03.02.2014, 12:21
Re: Help please MySQL R34 - by Size - 03.02.2014, 12:25
Re: Help please MySQL R34 - by PowerPC603 - 03.02.2014, 12:28
Re: Help please MySQL R34 - by Size - 03.02.2014, 12:39
Re: Help please MySQL R34 - by PowerPC603 - 03.02.2014, 12:43
Re: Help please MySQL R34 - by Size - 03.02.2014, 12:51

Forum Jump:


Users browsing this thread: 1 Guest(s)