Sscanf & MySQL help :D
#8

Okay,
pawn Код:
MySQL_Login(playerid)
{
    new query[250], pname[24], savingstring[250], money;
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT * FROM users WHERE name='%s' LIMIT 1", pname);
    mysql_query(query);
    mysql_store_result();
    if(mysql_fetch_row_format(savingstring))
    {
        sscanf(savingstring,"p<|>e<{iii}iiis[19]{i}iiii>",
        Playerdata[playerid][Skin],
        Playerdata[playerid][Adminlevel],
        Playerdata[playerid][Vip],
        Playerdata[playerid][Vipexp],
        money,
        Playerdata[playerid][Level],
        Playerdata[playerid][Kill],
        Playerdata[playerid][Death]);
    }
    mysql_free_result();
    format(string, sizeof(string), "Welcome back %s!", pname);
    SendClientMessage(playerid, COLOR_YELLOW2, string);
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, money);
    SetPlayerScore(playerid, Playerdata[playerid][Level]);
    if(Playerdata[playerid][Adminlevel] > 0)
    {
        format(string, sizeof(string), "You are a staff member, rank: %i", Playerdata[playerid][Adminlevel]);
        SendClientMessage(playerid, COLOR_YELLOW2, string);
    }
    SetSpawnInfo(playerid, Playerdata[playerid][Skin], 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
    SpawnPlayer(playerid);
    return 1;
}
Whole login script.
Database structuur:
Quote:

CREATE TABLE IF NOT EXISTS `users` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` varchar(225) NOT NULL,
`password` text NOT NULL,
`skin` int(250) NOT NULL DEFAULT '101',
`adminlevel` int(4) NOT NULL DEFAULT '0',
`vip` int(3) NOT NULL DEFAULT '0',
`vipexp` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`ip` varchar(20) NOT NULL,
`money` int(225) NOT NULL DEFAULT '0',
`level` int(10) NOT NULL DEFAULT '1',
`kill` int(10) NOT NULL DEFAULT '1',
`death` int(10) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
Reply


Messages In This Thread
Sscanf & MySQL help :D - by wouter0100 - 31.08.2011, 12:25
Re: Sscanf & MySQL help :D - by [MWR]Blood - 31.08.2011, 12:28
Re: Sscanf & MySQL help :D - by wouter0100 - 31.08.2011, 12:30
Re: Sscanf & MySQL help :D - by [MWR]Blood - 31.08.2011, 12:33
Re: Sscanf & MySQL help :D - by Sinner - 31.08.2011, 12:40
Re: Sscanf & MySQL help :D - by mprofitt - 31.08.2011, 12:47
Re: Sscanf & MySQL help :D - by wouter0100 - 31.08.2011, 12:59
Re: Sscanf & MySQL help :D - by wouter0100 - 31.08.2011, 13:03
Re: Sscanf & MySQL help :D - by mprofitt - 31.08.2011, 13:04
Re: Sscanf & MySQL help :D - by [MWR]Blood - 31.08.2011, 15:26

Forum Jump:


Users browsing this thread: 2 Guest(s)