19.03.2017, 09:02
Hello there! so i have started learning SQLite ways, but i got a little question about it,
For example i tried this first to test,
it's from a tutorial, i would know how to make a database in scriptfiles, for example like yourdb.dll, it got compiled gratefully but didn't show any file in scriptfiles, does it require player to join the server and use it and to be showen? thanks anyway!
For example i tried this first to test,
PHP код:
#include <a_samp>
#include <a_sampdb>
#include <zcmd>
main() { }
new DB: someDB; // Handle for database. Our queries need to use this so the queries know where to handle things
public OnGameModeInit() {
someDB = db_open("your.db"); // file 'your.db' will be our SQLite database
}
CMD:getmyname(playerid, params[]) {
new szQuery[74], szOut[32], DBResult: query, szPlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, szPlayerName, MAX_PLAYER_NAME);
format(szQuery, sizeof(szQuery), "select * from `players` where `playername` = '%s'", szPlayerName);
query = db_query(someDB, szQuery);
if(db_num_rows(query) > 0) {
SendClientMessage(playerid, 0, "There is more than 0 rows, meaning there is at least 1 row!");
SendClientMessage(playerid, 0, "So there is a registered account with my name!");
db_get_field_assoc(query, "Motto", szOut, sizeof(szOut));
SendClientMessage(playerid, 0, "Your motto is:");
SendClientMessage(playerid, 0, szOut);
db_free_result(query);
}
return 1;
}