Saving names in MySQL
#1

Hello,

Currently I'm using numbers in MySQL. Example of a command:
pawn Код:
CMD:makeadmin(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");
    new id, lvl;
    GetPlayerRame(id, str, 24);
    if(sscanf(params, "ui", id, lvl)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY"[CMD] / "#COL_SGREY"[PlayerID/PartOfName] [Level]");
    else
    {
        PlayerInfo[id][Adminlevel] = lvl;
    }
    return 1;
}

// This will save the Adminlevel that I drop into the command (f ex. /makeadmin 0 1)
But now I wanna save words / names. Something like this:
pawn Код:
CMD:setword(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,".:: You are not authorized to use this command ::.");
    new id, word;
    GetPlayerRame(id, str, 24);
    if(sscanf(params, "ui", id, word)) return SendClientMessage(playerid, COLOR_WHITE, ""#COL_DGREY"[CMD] / "#COL_SGREY"[PlayerID/PartOfName] [Word]");
    else
    {
        PlayerInfo[id][Word] = word;
    }
    return 1;
}
How can I get something like that working. So in the database it's like:

Word = Hello

__
Hope you will understand this since I had struggs with writing this.
Reply
#2

Make sure that you have 'word' set as array in your enum (e.g. word[32]). Then use strcpy to copy the string into another string.

pawn Код:
stock strcpy(dest[], const source[], maxlength=sizeof dest)
{
    return strcat((dest[0] = EOS, dest), source, maxlength);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)