new Query[512], DBResult: Result, name[MAX_PLAYER_NAME], Field[20]; GetPlayerName(playerid, name, sizeof(name)); if(dialogid == 1) { if(response) { format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(inputtext)); Result = db_query(Database, Query); if(db_num_rows(Result) == 1) { db_get_field_assoc(Result, "ADMIN", Field, 30); PlayerInfo[playerid][Admin] = strval(Field); db_get_field_assoc(Result, "GM", Field, 30); PlayerInfo[playerid][GM] = strval(Field); db_get_field_assoc(Result, "LEVEL", Field, 30); PlayerInfo[playerid][Level] = strval(Field); db_get_field_assoc(Result, "NOVAC", Field, 30); PlayerInfo[playerid][Novac] = strval(Field); db_get_field_assoc(Result, "BANKA", Field, 30); PlayerInfo[playerid][Banka] = strval(Field); db_get_field_assoc(Result, "POSAO", Field, 30); PlayerInfo[playerid][Posao] = strval(Field); db_get_field_assoc(Result, "UGOVOR", Field, 30); PlayerInfo[playerid][Ugovor] = strval(Field); db_get_field_assoc(Result, "MOBITEL", Field, 30); PlayerInfo[playerid][Mobitel] = strval(Field); db_get_field_assoc(Result, "LIDER", Field, 30); PlayerInfo[playerid][Lider] = strval(Field); db_get_field_assoc(Result, "CLAN", Field, 30); PlayerInfo[playerid][Clan] = strval(Field); db_get_field_assoc(Result, "RANK", Field, 30); PlayerInfo[playerid][Rank] = strval(Field); db_get_field_assoc(Result, "KAZNAUGOVOR", Field, 30); PlayerInfo[playerid][Kaznaugovor] = strval(Field); db_get_field_assoc(Result, "SATIUBANDI", Field, 30); PlayerInfo[playerid][Satiubandi] = strval(Field); db_get_field_assoc(Result, "SATIIGRE", Field, 30); PlayerInfo[playerid][Satiigre] = strval(Field); db_get_field_assoc(Result, "DRZAVA", Field, 30); PlayerInfo[playerid][Drzava] = strval(Field); db_get_field_assoc(Result, "SPOL", Field, 30); PlayerInfo[playerid][Spol] = strval(Field); db_get_field_assoc(Result, "DOB", Field, 30); PlayerInfo[playerid][Dob] = strval(Field); db_get_field_assoc(Result, "EXP", Field, 30); PlayerInfo[playerid][Exp] = strval(Field); db_get_field_assoc(Result, "VDP", Field, 30); PlayerInfo[playerid][VDP] = strval(Field); db_get_field_assoc(Result, "UBOJSTVA", Field, 30); PlayerInfo[playerid][Ubojstva] = strval(Field); db_get_field_assoc(Result, "SMRTI", Field, 30); PlayerInfo[playerid][Smrti] = strval(Field); db_get_field_assoc(Result, "TRAVA", Field, 30); PlayerInfo[playerid][Trava] = strval(Field); db_get_field_assoc(Result, "DUHAN", Field, 30); PlayerInfo[playerid][Duhan] = strval(Field); db_get_field_assoc(Result, "RIZLE", Field, 30); PlayerInfo[playerid][Rizle] = strval(Field); db_get_field_assoc(Result, "KOKAIN", Field, 30); PlayerInfo[playerid][Kokain] = strval(Field); db_get_field_assoc(Result, "KREDIT", Field, 30); PlayerInfo[playerid][Kredit] = strval(Field); db_get_field_assoc(Result, "KREDITIZNOS", Field, 30); PlayerInfo[playerid][KreditIznos] = strval(Field); db_get_field_assoc(Result, "KUCA", Field, 30); PlayerInfo[playerid][Kuca] = strval(Field); db_get_field_assoc(Result, "FIRMA", Field, 30); PlayerInfo[playerid][Firma] = strval(Field); db_get_field_assoc(Result, "VOZILO", Field, 30); PlayerInfo[playerid][Vozilo] = strval(Field); db_get_field_assoc(Result, "MOTOR", Field, 30); PlayerInfo[playerid][Motor] = strval(Field); db_get_field_assoc(Result, "BICKIKLA", Field, 30); PlayerInfo[playerid][Bicikla] = strval(Field); db_get_field_assoc(Result, "LETJELICA", Field, 30); PlayerInfo[playerid][Letjelica] = strval(Field); db_get_field_assoc(Result, "PLOVILO", Field, 30); PlayerInfo[playerid][Plovilo] = strval(Field); db_get_field_assoc(Result, "VIKENDICA", Field, 30); PlayerInfo[playerid][Vikendica] = strval(Field); db_get_field_assoc(Result, "KLJUC1", Field, 30); PlayerInfo[playerid][Kljuc][0] = strval(Field); db_get_field_assoc(Result, "KLJUC2", Field, 30); PlayerInfo[playerid][Kljuc][1] = strval(Field); db_get_field_assoc(Result, "KLJUC3", Field, 30); PlayerInfo[playerid][Kljuc][2] = strval(Field); db_get_field_assoc(Result, "UPOZORENJA", Field, 30); PlayerInfo[playerid][Upozorenja] = strval(Field); db_get_field_assoc(Result, "NAOCALE", Field, 30); PlayerInfo[playerid][Naocale] = strval(Field); db_get_field_assoc(Result, "MASKA", Field, 30); PlayerInfo[playerid][Maska] = strval(Field); db_get_field_assoc(Result, "KAPA", Field, 30); PlayerInfo[playerid][Kapa] = strval(Field); db_get_field_assoc(Result, "SJEME", Field, 30); PlayerInfo[playerid][Sjeme] = strval(Field); db_get_field_assoc(Result, "MATERIJALI", Field, 30); PlayerInfo[playerid][Materijali] = strval(Field); db_get_field_assoc(Result, "ORUZJE", Field, 30); PlayerInfo[playerid][Oruzije] = strval(Field); db_get_field_assoc(Result, "MUNICIJA", Field, 30); PlayerInfo[playerid][Municija] = strval(Field); db_get_field_assoc(Result, "CARLIC", Field, 30); PlayerInfo[playerid][CarLic] = strval(Field); db_get_field_assoc(Result, "BOATLIC", Field, 30); PlayerInfo[playerid][BoatLic] = strval(Field); db_get_field_assoc(Result, "FLYLIC", Field, 30); PlayerInfo[playerid][FlyLic] = strval(Field); db_get_field_assoc(Result, "TRUCKLIC", Field, 30); PlayerInfo[playerid][TruckLic] = strval(Field); db_get_field_assoc(Result, "BIKELIC", Field, 30); PlayerInfo[playerid][BikeLic] = strval(Field); db_get_field_assoc(Result, "KACIGA", Field, 30); PlayerInfo[playerid][Kaciga] = strval(Field); db_get_field_assoc(Result, "SPAWN", Field, 30); PlayerInfo[playerid][Spawn] = strval(Field); db_get_field_assoc(Result, "SKIN", Field, 30); PlayerInfo[playerid][Skin] = strval(Field); db_get_field_assoc(Result, "ZDRAVSTVENO", Field, 30); PlayerInfo[playerid][Zdravstveno] = strval(Field); db_get_field_assoc(Result, "MEHMATS", Field, 30); PlayerInfo[playerid][MehMats] = strval(Field); db_get_field_assoc(Result, "BOMBA", Field, 30); PlayerInfo[playerid][Bomba] = strval(Field); db_get_field_assoc(Result, "BON", Field, 30); PlayerInfo[playerid][Bon] = strval(Field); Logged[playerid] = true; SendClientMessage(playerid, -1, "* "COL_GREEN"Uspjesno ste se"BIJELA" prijavili! "); SpawnThisPlayer(playerid); } else { format(dialogstring, sizeof(dialogstring), "Dobrodosli na server "SVIJETLOPLAVA"%s"BIJELA", vi ste registrirani\n\nMolimo da se prijavite upisujuci svoju lozinku.", name, playerid); ShowPlayerDialog(playerid, 1, DIALOG_STYLE_PASSWORD, "Prijava", dialogstring, "Login", "Leave"); SendClientMessage(playerid, -1, ""COL_RED"Kriva"BIJELA" lozinka, pokusajte opet!"); } db_free_result(Result); } else { SendClientMessage(playerid, -1, "* Otkazali ste! "); Kick(playerid); } }
if(db_num_rows(Result) == 1)
{
print("DEBUG: Rows found (Result)");
db_get_field_assoc(Result, "ADMIN", Field, 30);
PlayerInfo[playerid][Admin] = strval(Field);
printf("DEBUG: Admin = %d", PlayerInfo[playerid][Admin]);
// blabla..
This SQLite code is not loading values from the table and i don't know why.
|
[20:23:12] Incoming connection: 192.168.1.2:50755
[20:23:12] [join] Danijel has joined the server (0:192.168.1.2) [20:23:19] DEBUG: Rows found (Result) [20:23:19] DEBUG: Admin = 0 [20:23:23] [part] Danijel has left the server (0:1) |
#define FILTERSCRIPT
#include < a_samp >
new
DB: Database
;
public OnFilterScriptInit( )
{
Database = db_open( "DatabaseBLRP.db" );
new
DBResult: Result
;
Result = db_query( Database, "SELECT * FROM users WHERE name = 'Danijel_Glupan' AND password = 'dado123'" );
if( db_num_rows( Result ) )
{
new
Field[ 2 ],
admin = 0
;
db_get_field_assoc( Result, "admin", Field, 2 );
admin = strval( Field );
printf( "Danijel_Glupan's admin level is %d", admin );
}
db_free_result( Result );
return 1;
}
public OnFilterScriptExit( )
{
db_close( Database );
return 1;
}
// Output:
[01:13:14] Danijel_Glupan's admin level is 1
"CREATE TABLE IF NOT EXISTS users (name VARCHAR(24) COLLATE NOCASE, ... blabla.."