mysql commands
#3

Can anyone show me how to update this to R7, i find this tutorial very hard to understand:https://sampforum.blast.hk/showthread.php?tid=337810

pawn Код:
new string2[256], pname[24];
        GetPlayerName(playerid, pname, 24);
        format(string2, sizeof(string2), "UPDATE `playerdata` SET `frozen` = '%d' WHERE `user_name` = '%s'",PlayerInfo[playerid][pFrozen],pname);
This one isnt even working but still:
pawn Код:
new Query[500];
    strcat(Query, "mysql_query(CREATE TABLE IF NOT EXISTS `playerdata` (\
    `user` VARCHAR(24),\
    `password` VARCHAR(40),\
    `score` INT(20),\
    `money` INT(20),\
    `health` INT(20),\
    `armour` INT(20),\
    `interior` INT(20),"
);

    strcat(Query, "`virtualworld` INT(20),\
    `level` INT(20),\
    `vip` INT(20),\
    `kma` INT(20),\
    `rank` INT(20),\
    `kills` INT(20),\
    `deaths` INT(20),\
    `muted` INT(20),\
    `skin` INT(20),"
);
                     

    strcat(Query, "`spec` INT(20),\
    `duty` INT(20),\
    `jailed` INT(20),\
    `frozen` INT(20),\
    `mutedtimes` INT(20),\
    `jailedtimes` INT(20),\
    `frozentimes` INT(20),\
    `banned` INT(20),\
    `bannedby` VARCHAR(24),"
);
                     
    strcat(Query, "`logins` INT(20),\
    `posx` INT(20),\
    `posy` INT(20),\
    `posz` INT(20),\
    `posa` INT(20),\
    `Tut` INT(20),\
    `IP` VARCHAR(15),\
    PRIMARY KEY (`playerdata`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
);
    mysql_query(Query);
pawn Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new query[425], pname[24], IP[15];
    new Bannedby[20];
    format(Bannedby, 20, "Not Banned");
    GetPlayerName(playerid, pname, 24);
    GetPlayerIp(playerid, IP, 15);

    format(query, sizeof(query), "INSERT INTO playerdata (user, password, score, money, health, armour, interior, virtualworld, level, vip, kma, rank, kills, deaths, muted, skin, spec, duty, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, posx, posy, posz, posa, tut, IP) VALUES('%s', SHA1('%s'), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '%s', 0, 0, 0, 0, 0, 0, '%s')", pname, passwordstring, Bannedby, IP);
    mysql_query(query);
    SendMessage(playerid, "~g~Info: ~w~You have been registered on this server!");
    Logged[playerid] = 1;
    return 1;
}

stock MySQL_Login(playerid)
{
    new query[425], pname[24], savingstring[24];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT score, money, health, armour, interior, virtualworld, level, vip, kma, rank, kills, deaths, muted, skin, spec, duty, jailed, frozen, mutedtimes, jailedtimes, frozentimes, banned, bannedby, logins, posx, posy, posz, posa, tut, FROM playerdata WHERE user = '%s'", pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_fetch_field_row(savingstring, "score"); SetPlayerScore(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "money"); MoneyGiven[playerid] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "health"); SetPlayerHealth(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "armour"); SetPlayerArmour(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "interior"); SetPlayerInterior(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "virtualworld"); SetPlayerVirtualWorld(playerid, strval(savingstring));
        mysql_fetch_field_row(savingstring, "level"); PlayerInfo[playerid][pLevel] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "vip"); PlayerInfo[playerid][pVIP] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "kma"); PlayerInfo[playerid][pKMA] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "rank"); PlayerInfo[playerid][pRank] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "kills"); PlayerInfo[playerid][pKills] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "deaths"); PlayerInfo[playerid][pDeaths] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "muted"); PlayerInfo[playerid][pMuted] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "skin"); PlayerInfo[playerid][pSkin] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "spec"); PlayerInfo[playerid][pSpec] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "duty"); PlayerInfo[playerid][pDuty] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "jailed"); PlayerInfo[playerid][pJailed] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "frozen"); PlayerInfo[playerid][pFrozen] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "mutedtimes"); PlayerInfo[playerid][pMutedTimes] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "jailedtimes"); PlayerInfo[playerid][pJailedTimes] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "frozentimes"); PlayerInfo[playerid][pFrozenTimes] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "banned"); PlayerInfo[playerid][pBanned] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "bannedby"); PlayerInfo[playerid][pBannedBy] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "logins"); PlayerInfo[playerid][pLogins] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posx"); PlayerInfo[playerid][pPosX] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posy"); PlayerInfo[playerid][pPosY] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posz"); PlayerInfo[playerid][pPosZ] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "posa"); PlayerInfo[playerid][pPosA] = strval(savingstring);
        mysql_fetch_field_row(savingstring, "tut"); PlayerInfo[playerid][Tut] = strval(savingstring);
    }
    mysql_free_result();
    JustLogged[playerid] = 1;
    Logged[playerid] = 1;
    PlayerInfo[playerid][pLogins]++;
    SendMessage(playerid, "~g~Info: ~w~You have been logged-in!");
    return 1;
}
Reply


Messages In This Thread
mysql commands - by Markus1337 - 25.01.2013, 07:56
Re: mysql commands - by ikey07 - 25.01.2013, 09:11
Re: mysql commands - by Markus1337 - 25.01.2013, 14:28

Forum Jump:


Users browsing this thread: 1 Guest(s)