Lots of errors on SQLite..
#1

Hello again! I am trying to create an admin system but I get some errors.

Код:
C:\Users\Chris\Desktop\Personal Folder\Servers\GTA SAMP DreamLand [Public]\filterscripts\AccSys.pwn(135) : warning 202: number of arguments does not match definition
C:\Users\Chris\Desktop\Personal Folder\Servers\GTA SAMP DreamLand [Public]\filterscripts\AccSys.pwn(163) : warning 202: number of arguments does not match definition
C:\Users\Chris\Desktop\Personal Folder\Servers\GTA SAMP DreamLand [Public]\filterscripts\AccSys.pwn(163) : error 039: constant symbol has no size
C:\Users\Chris\Desktop\Personal Folder\Servers\GTA SAMP DreamLand [Public]\filterscripts\AccSys.pwn(164) : warning 202: number of arguments does not match definition
C:\Users\Chris\Desktop\Personal Folder\Servers\GTA SAMP DreamLand [Public]\filterscripts\AccSys.pwn(164) : error 039: constant symbol has no size
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Every error is located on OnDialogResponse. Here it is:
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch (
dialogid)
    {
        case 
DIALOG_REGISTER:
        {
            if(!
response) return Kick(playerid);
            
            if(!(
<= strlen(inputtext) <= 20))
            {
                
SendClientMessage(playerid,0xFFFFFFFF"{33CCCC}DreamLand:{FFFFFF} Your password has to be between 5-20 characters");
                
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Register""Welcome to DreamLand!\n\nType your password below to register your account:""Register""Cancel");
                return 
1;
            }
            
            new
                
q[208];
                
            
WP_Hash(User[playerid][P_PASSWORD], 129inputtext);
            
format(qsizeof(q),"INSERT INTO Accounts (username, password) VALUES ('%q', '%s')",User[playerid][P_NAME], User[playerid][P_PASSWORD]);
            
db_query(Databaseq);
            
            
SendClientMessage(playerid, -1"{33CCCC}DreamLand:{FFFFFF} Thank you for registering on the server! It means a lot to us!");
            
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
            
            new
                
DBResultResult;
                
            
Result db_query(Database"SELECT last_insert_rowid()");
            
User[playerid][P_ID] = db_get_field_assoc_int(Result);
            
            
db_free_result(Result);
        }
        case 
DIALOG_LOGIN:
        {
            if(!
response) return Kick(playerid);
            
            new
                
buf[129];
                
            
WP_Hash(buf129inputtext);
            
            if(
strcmp(bufUser[playerid][P_PASSWORD]))
            {
                
SendClientMessage(playerid, -1"{33CCCC}DreamLand:{FFFFFF} Incorrect password, try again!");
                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Login""Welcome back!\n\nType your password below to login with your account:""Login""Cancel");
                return 
1;
            }
            
            new
                
DBResultResult;
                
            
format(bufsizeof(buf), "SELECT * FROM Accounts WHERE username = '%q' LIMIT 1"User[playerid][P_NAME]);
            
Result db_query(Databasebuf);
            
            if(
db_num_rows(Result))
            {
                
User[playerid][P_ID] = db_get_field_assoc_int(Result"userid"P_IDsizeof P_ID);
                
User[playerid][P_RANK] = db_get_field_assoc_int(Result"admin"P_RANKsizeof P_RANK);
                
                
SendClientMessage(playerid, -1"{33CCCC}DreamLand:{FFFFFF} Welcome back and have fun!");
            }
            
db_free_result(Result);
        }
        default: return 
0;
    }
    return 
1;

Help please it's really important
Reply
#2

Please highlight the lines in which you are getting the errors.
Reply
#3

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[]) 

    switch (
dialogid
    { 
        case 
DIALOG_REGISTER
        { 
            if(!
response) return Kick(playerid); 
             
            if(!(
<= strlen(inputtext) <= 20)) 
            { 
                
SendClientMessage(playerid,0xFFFFFFFF"{33CCCC}DreamLand:{FFFFFF} Your password has to be between 5-20 characters"); 
                
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_PASSWORD"Register""Welcome to DreamLand!\n\nType your password below to register your account:""Register""Cancel"); 
                return 
1
            } 
             
            new 
                
q[208]; 
                 
            
WP_Hash(User[playerid][P_PASSWORD], 129inputtext); 
            
format(qsizeof(q),"INSERT INTO Accounts (username, password) VALUES ('%q', '%s')",User[playerid][P_NAME], User[playerid][P_PASSWORD]); 
            
db_query(Databaseq); 
             
            
SendClientMessage(playerid, -1"{33CCCC}DreamLand:{FFFFFF} Thank you for registering on the server! It means a lot to us!"); 
            
PlayerPlaySound(playerid,1057,0.0,0.0,0.0); 
             
            new 
                
DBResultResult
                 
            
Result db_query(Database"SELECT last_insert_rowid()"); 
            
User[playerid][P_ID] = db_get_field_assoc_int(Result); //Line 135
             
            
db_free_result(Result); 
        } 
        case 
DIALOG_LOGIN
        { 
            if(!
response) return Kick(playerid); 
             
            new 
                
buf[129]; 
                 
            
WP_Hash(buf129inputtext); 
             
            if(
strcmp(bufUser[playerid][P_PASSWORD])) 
            { 
                
SendClientMessage(playerid, -1"{33CCCC}DreamLand:{FFFFFF} Incorrect password, try again!"); 
                
ShowPlayerDialog(playeridDIALOG_LOGINDIALOG_STYLE_PASSWORD"Login""Welcome back!\n\nType your password below to login with your account:""Login""Cancel"); 
                return 
1
            } 
             
            new 
                
DBResultResult
                 
            
format(bufsizeof(buf), "SELECT * FROM Accounts WHERE username = '%q' LIMIT 1"User[playerid][P_NAME]); 
            
Result db_query(Databasebuf); 
             
            if(
db_num_rows(Result)) 
            { 
                
User[playerid][P_ID] = db_get_field_assoc_int(Result"userid"P_IDsizeof P_ID); //2 Errors on Line 163
                
User[playerid][P_RANK] = db_get_field_assoc_int(Result"admin"P_RANKsizeof P_RANK); //2 Errors on Line 164
                 
                
SendClientMessage(playerid, -1"{33CCCC}DreamLand:{FFFFFF} Welcome back and have fun!"); 
            } 
            
db_free_result(Result); 
        } 
        default: return 
0
    } 
    return 
1

Reply
#4

PHP код:
if(!(<= strlen(inputtext) <= 20)) 
thats incorrect man 5 is a constant you have to use &&
like this
PHP код:
if(strlen(inputtext)>=&& strlen(inputtext) <=20
Reply
#5

You have used "field_assoc", that means that the second parameter is the name of the field but you can retrieve the last inserted ID using the field functions. The second parameter is 0 (for fieldid) but since there are no more selected, it's 0 by default:
pawn Код:
User[playerid][P_ID] = db_get_field_int(Result);
---

pawn Код:
User[playerid][P_ID] = db_get_field_assoc_int(Result, "userid", P_ID, sizeof P_ID); //2 Errors on Line 163
User[playerid][P_RANK] = db_get_field_assoc_int(Result, "admin", P_RANK, sizeof P_RANK); //2 Errors on Line 164
P_ID and P_RANK are constants used in the enumerator and actually there's no reason to try get the size (which you would have to manually specify it) as they're not strings. That would be:
pawn Код:
User[playerid][P_ID] = db_get_field_assoc_int(Result, "userid");
User[playerid][P_RANK] = db_get_field_assoc_int(Result, "admin");
Quote:
Originally Posted by Sreyas
Посмотреть сообщение
PHP код:
if(!(<= strlen(inputtext) <= 20)) 
thats incorrect man 5 is a constant you have to use &&
like this
PHP код:
if(strlen(inputtext)>=&& strlen(inputtext) <=20
It's correct and it is used to avoid calling strlen twice.
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You have used "field_assoc", that means that the second parameter is the name of the field but you can retrieve the last inserted ID using the field functions. The second parameter is 0 (for fieldid) but since there are no more selected, it's 0 by default:
pawn Код:
User[playerid][P_ID] = db_get_field_int(Result);
---

pawn Код:
User[playerid][P_ID] = db_get_field_assoc_int(Result, "userid", P_ID, sizeof P_ID); //2 Errors on Line 163
User[playerid][P_RANK] = db_get_field_assoc_int(Result, "admin", P_RANK, sizeof P_RANK); //2 Errors on Line 164
P_ID and P_RANK are constants used in the enumerator and actually there's no reason to try get the size (which you would have to manually specify it) as they're not strings. That would be:
pawn Код:
User[playerid][P_ID] = db_get_field_assoc_int(Result, "userid");
User[playerid][P_RANK] = db_get_field_assoc_int(Result, "admin");


It's correct and it is used to avoid calling strlen twice.
Thank you sir. Fixed my errors! Much appreciated!
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
It's correct and it is used to avoid calling strlen twice.
but when i did the same way the output(in c++) was like this
PHP код:
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void main()
{
clrscr();
char i[90];
gest(i);
if(
5<=strlen(i)<=20)
cout<<"5-20";
else
cout<<'Not";
getch();

consider i input hi
it will print
5-20
even if the right answer is Not
??
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)