[HELP] Dialog ( strcat bug )
#1

hey guys,

i have a little bit buggy on the strcat. here we are:

first time connection


second time connection


the code that may be bugged:

pawn Код:
stock ChooseDialog ( dialogid , playerid ) {
    switch ( dialogid ) {
        case DIALOG_REG: {
            strcat ( mstr , ""YELLOW"This server using MySQL Cookie System that "RED"made by Mubarrak48\n" ) ;
            strcat ( mstr , ""YELLOW"If you want to see more feature you can register on our "RED"database\n" ) ;
            strcat ( mstr , ""YELLOW"Click "RED"Yes "YELLOW"to register on ourdatabase or\n" ) ;
            strcat ( mstr , ""YELLOW"You can click "RED"No "YELLOW"to continue without registering\n" ) ;
           
            ShowPlayerDialog ( playerid , DIALOG_REG , DIALOG_STYLE_MSGBOX , DIALOG_TITLE , mstr , "Yes" , "No" ) ;
        }
    }
    return 1 ;
}
pawn Код:
public OnPlayerConnect ( playerid ) {
    GetPlayerName ( playerid , iName , sizeof ( iName ) ) ;
    mysql_real_escape_string ( iName , iName ) ;
    format ( Query , sizeof ( Query ) , "SELECT * FROM `users` WHERE `username` = '%s'" , iName ) ;
    mysql_query ( Query ) ;
    mysql_store_result ( ) ;
    if ( mysql_num_rows ( ) == 0 ) {
        ChooseDialog ( DIALOG_REG , playerid ) ;
    }
    else {
        new
            Cookies [ 1 ] ;
        if ( mysql_fetch_row ( Query ) ) {
            sscanf ( Query , "p<|>i" , Cookies [ 0 ] ) ;
            SetPVarInt ( playerid , "Cookies" , Cookies [ 0 ] ) ;
            SetPVarInt ( playerid , "Logged" , 1 ) ;
        }
        format ( str , sizeof ( str ) , ""YELLOW"Welcome back "RED"%s, "YELLOW"Your Amounts of "RED"cookies "YELLOW"are "RED"%i Cookie(s)" , iName , GetPVarInt ( playerid , "Cookies" ) ) ;
        SendClientMessage ( playerid , -1 , str ) ;
    }
    mysql_free_result ( ) ;
    return 1 ;
}
thats all the code i can give. Its only bugged on the connection part
Reply
#2

Код:
	format( mstr , ""YELLOW"This server using MySQL Cookie System that "RED"made by Mubarrak48\n" ) ;
will start a new string.
using strcat at start, then it adds the dialog-string to the (still filled) old string i guess (assuming the mstr is global, which is obviously the case )
Reply
#3

Quote:
Originally Posted by Babul
Посмотреть сообщение
Код:
	format( mstr , ""YELLOW"This server using MySQL Cookie System that "RED"made by Mubarrak48\n" ) ;
will start a new string.
using strcat at start, then it adds the dialog-string to the (still filled) old string i guess (assuming the mstr is global, which is obviously the case )
plz read the title and my question carefully plz format and strcat doesnt same
strcat = unlimited but needed new code after the one
format = may crash ur pawno if its had too much string

EDIT: and your not even sizeof the sweet string in it
Reply
#4

You have to empty the string before you add stuff to it

pawn Код:
stock ChooseDialog ( dialogid , playerid ) {
    switch ( dialogid ) {
        case DIALOG_REG: {
            mstr = "";
            strcat ( mstr , ""YELLOW"This server using MySQL Cookie System that "RED"made by Mubarrak48\n" ) ;
            strcat ( mstr , ""YELLOW"If you want to see more feature you can register on our "RED"database\n" ) ;
            strcat ( mstr , ""YELLOW"Click "RED"Yes "YELLOW"to register on ourdatabase or\n" ) ;
            strcat ( mstr , ""YELLOW"You can click "RED"No "YELLOW"to continue without registering\n" ) ;
           
            ShowPlayerDialog ( playerid , DIALOG_REG , DIALOG_STYLE_MSGBOX , DIALOG_TITLE , mstr , "Yes" , "No" ) ;
        }
    }
    return 1 ;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)