21.08.2012, 00:51
Hello you guys, this is my first tutorial, so excuse me if there are some errors.
INFO: So today, I finally found a solution to my dreaded problem, https://sampforum.blast.hk/showthread.php?tid=369745, and I'd like to share to you my solution to "Using variables in dialogs, using strcat".
TUTORIAL: STEP 1
Always! and I mean Always! First start with adding a string size, depending on how many chars you use, you don't have to be exact, but don't go crazy and type 2000 chars.
STEP 2
The next step is to add the "baby strings".
These strings are created and it can be whatever you like, it can be words or whatever. In this tutorial though, we will learn how to use variables within a dialog with longer chars and no longer receive this error.
STEP 3:
So let's add those strings!
So at this point, it should look like this!
STEP 4:
We are almost done! Next up we will format the strings, and by formatting strings, I mean "string1, string2, string3, and string4" aka the baby strings!
Let's say you want to use a players name.
NOTE: THIS IS AN EXAMPLE, DO NOT USE THE SAME VARIABLES I TYPE, USE YOUR OWN VARIABLES.
That's string1! Obviously my chars are short in this format, but this is just an example and you may edit the number of chars per string if needed.
Here is string2!
The cool part about this is, you may now add as much data in this format as needed, as long as you don't exceed the input line. Whenever you run out of space, that's where string3 comes in!
Here is string3! Once again, you made add as much as you want.
...and for the final touch on our baby strings..
So once you are done with this, it should like this
so now that we formatted our baby strings, here comes the end.
STEP 5:
This is where catstring[800]; comes to play!
MORE INFO on strcats! https://sampwiki.blast.hk/wiki/Strcat
FINAL STEP:
Now we add our dialog, and place "catstring" here.
In the end.. It should look like this..
catstring[800] has 4 child strings, these are stored in strcat, and joins together into the reference.
Congrats! You now know how to add variables and add as many words and references as you like without getting an input error.
This is my first tutorial, If I made any mistakes, please let me know!
INFO: So today, I finally found a solution to my dreaded problem, https://sampforum.blast.hk/showthread.php?tid=369745, and I'd like to share to you my solution to "Using variables in dialogs, using strcat".
TUTORIAL: STEP 1
Always! and I mean Always! First start with adding a string size, depending on how many chars you use, you don't have to be exact, but don't go crazy and type 2000 chars.
pawn Code:
new catstring[800],
The next step is to add the "baby strings".
These strings are created and it can be whatever you like, it can be words or whatever. In this tutorial though, we will learn how to use variables within a dialog with longer chars and no longer receive this error.
pawn Code:
error 075: input line too long (after substitutions)
So let's add those strings!
pawn Code:
new string1[200];
new string2[200];
new string3[200];
new string4[200];
pawn Code:
new catstring[800];
new string1[200];
new string2[200];
new string3[200];
new string4[200];
We are almost done! Next up we will format the strings, and by formatting strings, I mean "string1, string2, string3, and string4" aka the baby strings!
Let's say you want to use a players name.
NOTE: THIS IS AN EXAMPLE, DO NOT USE THE SAME VARIABLES I TYPE, USE YOUR OWN VARIABLES.
pawn Code:
format(string1,sizeof(string1),"%s's {FFFFFF}stats",GetName(clickedplayerid));
Here is string2!
pawn Code:
format(string2, sizeof(string2),"{FFFFFF}%s has {33FF00}%d{FFFFFF} kills and {FF0000}%d{FFFFFF} deaths. \nHe averages {FFFF66}%0.2f {FFFFFF}Kills per Death.", GetName(clickedplayerid),kills,deaths, Float:ratio);
pawn Code:
format(string3,sizeof(string3),"\n\n\tAdmin Status: %s{FFFFFF}\n\tAccount Type: %s{FFFFFF}\n\t",AdmRank,AccType);
...and for the final touch on our baby strings..
pawn Code:
format(string4,sizeof(string4),"He has {336600}$%d{FFFFFF}.\n\tHe has %d points.\n\tHe also has %d experience points, and %d cookies.\n\tPing: %d ms\n\n%s\n%s\n%s\nIf he is in the cage, he is in for %i seconds.",cash,score,xp,cookies,GetPlayerPing(clickedplayerid), Jailed, Muted, Caged, time);
pawn Code:
new catstring[800];
new string1[200];
new string2[200];
new string3[200];
new string4[200];
format(string1,sizeof(string1),"%s's {FFFFFF}stats",GetName(clickedplayerid));
format(string2, sizeof(string2),"{FFFFFF}%s has {33FF00}%d{FFFFFF} kills and {FF0000}%d{FFFFFF} deaths. \nHe averages {FFFF66}%0.2f {FFFFFF}Kills per Death.", GetName(clickedplayerid),kills,deaths, Float:ratio);
format(string3,sizeof(string3),"\n\n\tAdmin Status: %s{FFFFFF}\n\tAccount Type: %s{FFFFFF}\n\t",AdmRank,AccType);
format(string4,sizeof(string4),"He has {336600}$%d{FFFFFF}.\n\tHe has %d points.\n\tHe also has %d experience points, and %d cookies.\n\tPing: %d ms\n\n%s\n%s\n%s\nIf he is in the cage, he is in for %i seconds.",cash,score,xp,cookies,GetPlayerPing(clickedplayerid), Jailed, Muted, Caged, time);
STEP 5:
This is where catstring[800]; comes to play!
pawn Code:
strcat(catstring, string1);
strcat(catstring, string2);
strcat(catstring, string3);
strcat(catstring, string4);
FINAL STEP:
Now we add our dialog, and place "catstring" here.
pawn Code:
ShowPlayerDialog(playerid, DIALOGNAMEHERE, DIALOG_STYLE_MSGBOX, "Title", catstring, "Close", "");
pawn Code:
new catstring[800];
new string1[200];
new string2[200];
new string3[200];
new string4[200];
format(string1,sizeof(string1),"%s's {FFFFFF}stats",GetName(clickedplayerid));
format(string2, sizeof(string2),"{FFFFFF}%s has {33FF00}%d{FFFFFF} kills and {FF0000}%d{FFFFFF} deaths. \nHe averages {FFFF66}%0.2f {FFFFFF}Kills per Death.", GetName(clickedplayerid),kills,deaths, Float:ratio);
format(string3,sizeof(string3),"\n\n\tAdmin Status: %s{FFFFFF}\n\tAccount Type: %s{FFFFFF}\n\t",AdmRank,AccType);
format(string4,sizeof(string4),"He has {336600}$%d{FFFFFF}.\n\tHe has %d points.\n\tHe also has %d experience points, and %d cookies.\n\tPing: %d ms\n\n%s\n%s\n%s\nIf he is in the cage, he is in for %i seconds.",cash,score,xp,cookies,GetPlayerPing(clickedplayerid), Jailed, Muted, Caged, time);
ShowPlayerDialog(playerid, DIALOGNAMEHERE, DIALOG_STYLE_MSGBOX, "Title", catstring, "Close", "");
catstring[800] has 4 child strings, these are stored in strcat, and joins together into the reference.
Congrats! You now know how to add variables and add as many words and references as you like without getting an input error.
This is my first tutorial, If I made any mistakes, please let me know!