06.01.2012, 09:16
What do you mean by neat? I think that's personal because every scripter has a different style.
A couple of things that might help you though.
What is the use of the id field? if it's for finding the players record, you can use your name field.
For example:
And remember to escape the string to stop injections.
Another thing that might be usefull to know, but not necessary is a specifier for SSCANF, you can use the enum specifier to enumerate the data you retrieve using sscanf, for example in your code:
Can become:
However, your enumerator (the one used for PlayerInfo) will have to be in the SAME order as the mysql table for players.
A couple of things that might help you though.
Код:
SELECT * FROM `players` WHERE `id`=%d LIMIT 1
For example:
Код:
SELECT * FROM `players` WHERE `username` = '%s'
Another thing that might be usefull to know, but not necessary is a specifier for SSCANF, you can use the enum specifier to enumerate the data you retrieve using sscanf, for example in your code:
Код:
if ( sscanf( string, "p<|>s[20]ddddddddddddfffdd", trash, PlayerInfo[playerid][banned], PlayerInfo[playerid][Level], PlayerInfo[playerid][SEELevel], money, score, PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][GTLLevel], PlayerInfo[playerid][SMPLevel], PlayerInfo[playerid][LSTLevel], PlayerInfo[playerid][TSGLevel], PlayerInfo[playerid][eLevel], PlayerInfo[playerid][Exp], PlayerInfo[playerid][pos_x], PlayerInfo[playerid][pos_y], PlayerInfo[playerid][pos_z], PlayerInfo[playerid][FavSkin], PlayerInfo[playerid][rBan] ) )
Код:
if ( sscanf( string, "e<p<|>s[20]ddddddddddddfffdd>", PlayerInfo[playerid] ) )