I need help in arrays - 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: I need help in arrays (
/showthread.php?tid=644755)
I need help in arrays -
Arbico - 13.11.2017
Guys, i'm trying to make RP test before registering but the 3 options is the same as the question itself
here is the code
PHP код:
new RQ = random(sizeof(Questions));
new Str[200], Str2[200];
format(Str, sizeof(Str), "%s", Questions[RQ][1]);
format(Str2, sizeof(Str2),
"%s\n\
%s\n\
%s\n", Questions[RQ][2], Questions[RQ][3], Questions[RQ][4]);
ShowPlayerDialog(playerid, Questions[RQ][0], DIALOG_STYLE_LIST, Str, Str2, "Choose", "Cancel");
Here is the array.
PHP код:
new Questions[][] = {
{QUESTION_ONE, "Q. How do you RP a car acccident?", "/me has an accident", "/me would slightly hit the steering wheel, and blood would start oozing out of his forhead", " /me pushes the other vehicle off and drives off"},
{QUESTION_TWO, "Q. How do you put an advertisement for selling a car?","Black Tampa with gold rings for sale", "I am selling my car", "Fuck the police! My sexy tampa on sale"},
{QUESTION_THREE, "What is KoS?", "Keyboard on Satalite", "Kill on Sight", "Kite on Sky"},
{QUESTION_FOUR, "What does SA:MP stand for?", "San Andreas Movie Player", "San Andreas Multiplayer", "San Andreas Microphone Pack"},
{QUESTION_FIVE, "What is the correct use of /ad?", "/ad any1 selling house", "/ad Come Come buy awesome house!", "/ad I'm selling my house with a backyard, call me"},
{QUESTION_SIX, "If someone offered to buy VIP for you for IG money, What should you do?", "Accept the deal", "Finish him in a world war way", "Screenshot it and head to the forums"},
{QUESTION_SEVEN, "What is MG?", "Meat Game: Cut Meat Into Pieces faster", "Meta Gaming: Mix OOC with IC", "Meet God: Meet the god and fight him till you win"}
};
Again, the problem is: The 3 options is same as the question itself.
What's the problem here?
Re: I need help in arrays -
BiosMarcel - 14.11.2017
you start at index 1 and go up to 4, arrays always start at 0, also you even used the wrong parameters for showplayerdialog
Can u even compile??
Also, no need to define unnecessary line breaks in your strings.
Anyways, look at this:
PHP код:
new index = random(sizeof(Questions));
new answers[CHECK HOW MUCH YOU NEED DAMN IT];
format(answers, sizeof(output), "%s\n%s\n%s", Questions[index][1], Questions[index][2],Questions[index][3]);
ShowPlayerDialog(playerid, DIALOG_ID, DIALOG_STYLE_LIST, Questions[index][0], answers, "Choose", "Cancel");