SQL issue
#1

Hey, so Ive created this small character system (currently supports 1 character only), im only now wondering how to load the character for the player? Ive created MasterID for characters but Ive got no luck to get the player name, or any informations.

pawn Код:
mysql_format(mysql, query, sizeof(query), "SELECT `PlayerName` FROM `characters` WHERE `MasterID` = '%d' LIMIT 1", AccInfo[playerid][ID]);
                mysql_tquery(mysql, query, "OnCharacterLoad", "i", playerid);

public OnCharacterLoad(playerid)
{
    CharInfo[playerid][PlayerName] = cache_get_field_name(0,"PlayerName");
    CharInfo[playerid][Age] = cache_get_field_content_int(0, "Age");
    CharInfo[playerid][Sex] = cache_get_field_content_int(0, "Sex");
    return true;
}

Im not any good with SQL, but basically what Im trying to do is:
1. Look for Player name (table characters) thats MasterID is same as AccInfo[playerid][ID]
Reply
#2

pawn Код:
public OnCharacterLoad(playerid)
{
    if(cache_get_row_count())
    {
        new TempName[MAX_PLAYER_NAME + 1];
        cache_get_field_content(0, "PlayerName", TempName);
        CharInfo[playerid][PlayerName][0] = EOS;
        strcat(CharInfo[playerid][PlayerName],TempName,MAX_PLAYER_NAME);

        CharInfo[playerid][Age] = cache_get_field_content_int(0, "Age");
        CharInfo[playerid][Sex] = cache_get_field_content_int(0, "Sex");
    }
    return true;
}
Reply
#3

Aha nice, but how could I check for multiple characters? Lets say player has 3 characters, what should I do regarding that?
Reply
#4

You need skip to next rows instead of 0
Reply
#5

Aha thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)