SA-MP Forums Archive
Function crashing? - 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: Function crashing? (/showthread.php?tid=411227)



Function crashing? - jessejanssen - 28.01.2013

Hello SA-MP community,

I got this function I made to complete a registration, I made it a function because I use it on different parts of the script ( Depends which answers you give on the questions. ). Now the issue is that this code worked perfectly fine before and somehow while I didn't change anything it doesn't read more then "> Check 1"..

Here's the code:
pawn Код:
public RegisteredText(playerid)
{
    SCM(playerid, KLEUR_WIT, ">  Check 1");
    print(">  Check 1");
    new string[512], string2[512], esc[512], Nm[MAX_PLAYER_NAME], esc2[512], esc3[512], esc4[512], esc5[512];
    new esc6[512], TempPW[512], y, m, d, h, mi, s, time[128], esc7[512], date[128], esc8[512];
    SCM(playerid, KLEUR_WIT, ">  Check 2");
    print(">  Check 2");
    getdate(y, m, d);
    gettime(h, mi, s);
    SCM(playerid, KLEUR_WIT, ">  Check 3");
    print(">  Check 3");
    format(time, sizeof(time), "%d-%02d-%04d %02d:%02d", d, m, y, SetGMTClock(h), mi);
    format(date, sizeof(date), "%d-%02d-%04d", d, m, y);
    SCM(playerid, KLEUR_WIT, ">  Check 4");
    print(">  Check 4");
    strmid(Pinfo[playerid][File], date, 0, strlen(date), 20);
    strmid(Pinfo[playerid][LastLogin], time, 0, strlen(time), 64);
    SCM(playerid, KLEUR_WIT, ">  Check 5");
    print(">  Check 5");
    TempPW = Hash(Pinfo[playerid][Password]);
    mysql_real_escape_string(Pinfo[playerid][RegMail], esc);
    SCM(playerid, KLEUR_WIT, ">  Check 6");
    print(">  Check 6");
    GetPlayerName(playerid, Nm, sizeof(Nm));
    mysql_real_escape_string(Nm, esc2);
    SCM(playerid, KLEUR_WIT, ">  Check 7");
    print(">  Check 7");
    mysql_real_escape_string(TempPW, esc3);
    mysql_real_escape_string(Pinfo[playerid][Hobby], esc4);
    SCM(playerid, KLEUR_WIT, ">  Check 8");
    print(">  Check 8");
    mysql_real_escape_string(Pinfo[playerid][Country], esc5);
    mysql_real_escape_string(Pinfo[playerid][Sex], esc6);
    SCM(playerid, KLEUR_WIT, ">  Check 9");
    print(">  Check 9");
    mysql_real_escape_string(time, esc7);
    mysql_real_escape_string(date, esc8);
    SCM(playerid, KLEUR_WIT, ">  Check 10");
    print(">  Check 10");
    SCM(playerid, KLEUR_SAMP, string2);
    mysql_queryF("INSERT INTO `users`(Username, Password, Email, AboutMe, Country, Sex, Age, Skin, RegisterDate, LastLogin) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%s', '%s')", esc2, esc3, esc, esc4, esc5, esc6, Pinfo[playerid][Age], Pinfo[playerid][Skin], esc8, esc7);
    SCM(playerid, KLEUR_WIT, ">  Check 11");
    print(">  Check 11");
    Pinfo[playerid][Registered] = 1;
    if(Pinfo[playerid][WrongAnswers] == 1)
        {
        format(string2, sizeof(string2), "\
        Congratulations %s, you have successfully registered!\n\
        \n\
        You had %d wrong answer out of 16 questions!\n\
        You have set your character's aboutme to: '%s'.\n\
        You have set your character's origin to: '%s'.\n"
,\
        PlayerName(playerid), Pinfo[playerid][WrongAnswers], Pinfo[playerid][Hobby],\
        Pinfo[playerid][Country]);
        }
    else
        {
        format(string2, sizeof(string2), "\
        Congratulations %s, you have successfully registered!\n\
        \n\
        You had %d wrong answers out of 16 questions!\n\
        You have set your character's aboutme to: '%s'.\n\
        You have set your character's origin to: '%s'.\n"
,\
        PlayerName(playerid), Pinfo[playerid][WrongAnswers], Pinfo[playerid][Hobby],\
        Pinfo[playerid][Country]);
        }
    strcat(string, string2, sizeof(string));
    format(string2, sizeof(string), "\
    You have set your character's age to: '%d'.\n\
    You have set your character's gender to: '%s'.\n\
    You have informed us that your e-mail address is: '%s'.\n"
,\
    Pinfo[playerid][Age], Pinfo[playerid][Sex], Pinfo[playerid][RegMail]);
    strcat(string, string2, sizeof(string));
    format(string2, sizeof(string2), "\n\
    We want to welcome you to our community, we hope you will enjoy your stay.\n\
    \n\
    Best regards,\n\
    The management"
);
    strcat(string, string2, sizeof(string));
    ShowPlayerDialog(playerid, REGD24, 0, "Registered!", string, "Play", "");
    return 1;
}
I hope you can help me!

Best regards,
Jesse


Re: Function crashing? - mamorunl - 28.01.2013

new esc6[512]
You didn't close the first line, you just put a comma. So you have to continue without the 'new' keyword


Re: Function crashing? - jessejanssen - 28.01.2013

Quote:
Originally Posted by mamorunl
Посмотреть сообщение
new esc6[512]
You didn't close the first line, you just put a comma. So you have to continue without the 'new' keyword
I don't go from 4 to 6, there's a "esc5[512];" after the comma after esc4[512] :P. Anyhow, thanks for looking, still stuck!

Best regards,
Jesse


Re: Function crashing? - mamorunl - 28.01.2013

Oh, right.. I didn't see it scroll horizontal


Re: Function crashing? - BlackBank - 28.01.2013

pawn Код:
public RegisteredText(playerid)
{
    SCM(playerid, KLEUR_WIT, ">  Check 1");
    print(">  Check 1");
   
    new
        string[512],
        Nm[MAX_PLAYER_NAME];   
        TempPW[512],
        y, m, d, //Date
        h, mi, s //Time
    ;
   
    SCM(playerid, KLEUR_WIT, ">  Check 2");
    print(">  Check 2");
    getdate(y, m, d);
    gettime(h, mi, s);
   
    SCM(playerid, KLEUR_WIT, ">  Check 3");
    print(">  Check 3");
    format(Pinfo[playerid][File], 64, "%d-%02d-%04d", d, m, y);
    format(Pinfo[playerid][LastLogin], 64, "%d-%02d-%04d %02d:%02d", d, m, y, SetGMTClock(h), mi);
   
    SCM(playerid, KLEUR_WIT, ">  Check 4");
    print(">  Check 4");
    format(TempPW, sizeof(TempPW), "%s", Hash(Pinfo[playerid][Password]));
    mysql_real_escape_string(Pinfo[playerid][RegMail], Pinfo[playerid][RegMail]);
    mysql_real_escape_string(Pinfo[playerid][Hobby], Pinfo[playerid][Hobby]);
    mysql_real_escape_string(Pinfo[playerid][Country], Pinfo[playerid][Country]);
    mysql_real_escape_string(Pinfo[playerid][Sex], Pinfo[playerid][Sex]);  
   
    SCM(playerid, KLEUR_WIT, ">  Check 5");
    print(">  Check 5");
    GetPlayerName(playerid, Nm, sizeof(Nm));
    mysql_real_escape_string(Nm, Nm);
   
    SCM(playerid, KLEUR_WIT, ">  Check 6");
    print(">  Check 6");
    mysql_queryF("INSERT INTO `users`(Username, Password, Email, AboutMe, Country, Sex, Age, Skin, RegisterDate, LastLogin) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%s', '%s')",
    Nm, TempPW, Pinfo[playerid][RegMail], Pinfo[playerid][Hobby], Pinfo[playerid][Country], Pinfo[playerid][Sex], Pinfo[playerid][Age], Pinfo[playerid][Skin], Pinfo[playerid][File], Pinfo[playerid][LastLogin]);
 
    SCM(playerid, KLEUR_WIT, ">  Check 7");
    print(">  Check 7");
    Pinfo[playerid][Registered] = 1;
    if(Pinfo[playerid][WrongAnswers] == 1)
    {
        format(string2, sizeof(string2), "\
        Congratulations %s, you have successfully registered!\n\
        \n\
        You had %d wrong answer out of 16 questions!\n\
        You have set your character's aboutme to: '%s'.\n\
        You have set your character's origin to: '%s'.\n"
,\
        PlayerName(playerid), Pinfo[playerid][WrongAnswers], Pinfo[playerid][Hobby],\
        Pinfo[playerid][Country]);
    }
    else
    {
        format(string2, sizeof(string2), "\
        Congratulations %s, you have successfully registered!\n\
        \n\
        You had %d wrong answers out of 16 questions!\n\
        You have set your character's aboutme to: '%s'.\n\
        You have set your character's origin to: '%s'.\n"
,\
        PlayerName(playerid), Pinfo[playerid][WrongAnswers], Pinfo[playerid][Hobby],\
        Pinfo[playerid][Country]);
    }
    strcat(string, string2, sizeof(string));
    format(string2, sizeof(string), "\
    You have set your character's age to: '%d'.\n\
    You have set your character's gender to: '%s'.\n\
    You have informed us that your e-mail address is: '%s'.\n"
,\
    Pinfo[playerid][Age], Pinfo[playerid][Sex], Pinfo[playerid][RegMail]);
    strcat(string, string2, sizeof(string));
    format(string2, sizeof(string2), "\n\
    We want to welcome you to our community, we hope you will enjoy your stay.\n\
    \n\
    Best regards,\n\
    The management"
);
    strcat(string, string2, sizeof(string));
    ShowPlayerDialog(playerid, REGD24, 0, "Registered!", string, "Play", "");
    return 1;
}
Ik heb heel je code opgeschoond.
Je kunt variablen meerdere keren gebruiken...


Re: Function crashing? - jessejanssen - 29.01.2013

Quote:
Originally Posted by BlackBank3
Посмотреть сообщение
pawn Код:
public RegisteredText(playerid)
{
    SCM(playerid, KLEUR_WIT, ">  Check 1");
    print(">  Check 1");
   
    new
        string[512],
        Nm[MAX_PLAYER_NAME];   
        TempPW[512],
        y, m, d, //Date
        h, mi, s //Time
    ;
   
    SCM(playerid, KLEUR_WIT, ">  Check 2");
    print(">  Check 2");
    getdate(y, m, d);
    gettime(h, mi, s);
   
    SCM(playerid, KLEUR_WIT, ">  Check 3");
    print(">  Check 3");
    format(Pinfo[playerid][File], 64, "%d-%02d-%04d", d, m, y);
    format(Pinfo[playerid][LastLogin], 64, "%d-%02d-%04d %02d:%02d", d, m, y, SetGMTClock(h), mi);
   
    SCM(playerid, KLEUR_WIT, ">  Check 4");
    print(">  Check 4");
    format(TempPW, sizeof(TempPW), "%s", Hash(Pinfo[playerid][Password]));
    mysql_real_escape_string(Pinfo[playerid][RegMail], Pinfo[playerid][RegMail]);
    mysql_real_escape_string(Pinfo[playerid][Hobby], Pinfo[playerid][Hobby]);
    mysql_real_escape_string(Pinfo[playerid][Country], Pinfo[playerid][Country]);
    mysql_real_escape_string(Pinfo[playerid][Sex], Pinfo[playerid][Sex]);  
   
    SCM(playerid, KLEUR_WIT, ">  Check 5");
    print(">  Check 5");
    GetPlayerName(playerid, Nm, sizeof(Nm));
    mysql_real_escape_string(Nm, Nm);
   
    SCM(playerid, KLEUR_WIT, ">  Check 6");
    print(">  Check 6");
    mysql_queryF("INSERT INTO `users`(Username, Password, Email, AboutMe, Country, Sex, Age, Skin, RegisterDate, LastLogin) VALUES('%s', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%s', '%s')",
    Nm, TempPW, Pinfo[playerid][RegMail], Pinfo[playerid][Hobby], Pinfo[playerid][Country], Pinfo[playerid][Sex], Pinfo[playerid][Age], Pinfo[playerid][Skin], Pinfo[playerid][File], Pinfo[playerid][LastLogin]);
 
    SCM(playerid, KLEUR_WIT, ">  Check 7");
    print(">  Check 7");
    Pinfo[playerid][Registered] = 1;
    if(Pinfo[playerid][WrongAnswers] == 1)
    {
        format(string2, sizeof(string2), "\
        Congratulations %s, you have successfully registered!\n\
        \n\
        You had %d wrong answer out of 16 questions!\n\
        You have set your character's aboutme to: '%s'.\n\
        You have set your character's origin to: '%s'.\n"
,\
        PlayerName(playerid), Pinfo[playerid][WrongAnswers], Pinfo[playerid][Hobby],\
        Pinfo[playerid][Country]);
    }
    else
    {
        format(string2, sizeof(string2), "\
        Congratulations %s, you have successfully registered!\n\
        \n\
        You had %d wrong answers out of 16 questions!\n\
        You have set your character's aboutme to: '%s'.\n\
        You have set your character's origin to: '%s'.\n"
,\
        PlayerName(playerid), Pinfo[playerid][WrongAnswers], Pinfo[playerid][Hobby],\
        Pinfo[playerid][Country]);
    }
    strcat(string, string2, sizeof(string));
    format(string2, sizeof(string), "\
    You have set your character's age to: '%d'.\n\
    You have set your character's gender to: '%s'.\n\
    You have informed us that your e-mail address is: '%s'.\n"
,\
    Pinfo[playerid][Age], Pinfo[playerid][Sex], Pinfo[playerid][RegMail]);
    strcat(string, string2, sizeof(string));
    format(string2, sizeof(string2), "\n\
    We want to welcome you to our community, we hope you will enjoy your stay.\n\
    \n\
    Best regards,\n\
    The management"
);
    strcat(string, string2, sizeof(string));
    ShowPlayerDialog(playerid, REGD24, 0, "Registered!", string, "Play", "");
    return 1;
}
Ik heb heel je code opgeschoond.
Je kunt variablen meerdere keren gebruiken...
Thanks, I didn't really use your code as I didn't want to use the escaped strings in the script but your input at least helped me at fixing it!

Best regards,
Jesse