SqlLite question - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SqlLite question (
/showthread.php?tid=649916)
SqlLite question -
jasperschellekens - 17.02.2018
Hello i am creating a command which deletes a players pincode.
The command works like this:
PHP код:
if(!IsPlayerAdmin(playerid)) return ShowPlayerDialog(playerid, DIALOG_NONE, DIALOG_STYLE_MSGBOX, "Oops...", "You are not authorized to use this command", "OK", "");
if(strlen(params) <2) return SendClientMessage(playerid, -1, "USAGE: /deletepincode [PlayerName]");
new DBResult:CLEAR_RESULT;
new szQuery[128];
format(szQuery, sizeof(szQuery), "delete from `PINCODES` where `PlayerName` = '%s'", DB_Escape(params));
CLEAR_RESULT = db_query(PIN_DATABASE, szQuery);
db_free_result(CLEAR_RESULT);
My question is, how do i check if the player table exists? so i can return a message like this player does not exist.
Re: SqlLite question -
Mugala - 17.02.2018
you have to use
db_num_rows like this:
PHP код:
new DBResult:CLEAR_RESULT;
new szQuery[128];
format(szQuery, sizeof(szQuery), "SELECT * from `PINCODES` where `PlayerName` = '%s'", DB_Escape(params));
CLEAR_RESULT = db_query(PIN_DATABASE, szQuery);
if(db_num_rows(CLEAR_RESULT))
{
//it's found
}
else
{
//it's NOT found
}
https://sampwiki.blast.hk/wiki/Db_num_rows
Re: SqlLite question -
jasperschellekens - 17.02.2018
Quote:
Originally Posted by Mugala
you have to use db_num_rows like this:
PHP код:
new DBResult:CLEAR_RESULT;
new szQuery[128];
format(szQuery, sizeof(szQuery), "SELECT * from `PINCODES` where `PlayerName` = '%s'", DB_Escape(params));
CLEAR_RESULT = db_query(PIN_DATABASE, szQuery);
if(db_num_rows(CLEAR_RESULT))
{
//it's found
}
else
{
//it's NOT found
}
https://sampwiki.blast.hk/wiki/Db_num_rows
|
thanks
Re: SqlLite question -
Mugala - 17.02.2018
yeah u're welcome