I'm in the process of developing a trivia system, but please excuse my bad code. I am very new to GS2.
PHP Code:
//#CLIENTSIDE
function onCreated() {
this.x += 0.5;
}
function showTriviaGUI() {
new GuiWindowCtrl("EventTrivia_Window1") {
profile = GuiBlueWindowProfile;
style = $pref::Video::defaultguistyle;
clientrelative = true;
clientextent = "384,164";
canmaximize = false;
canminimize = false;
canmove = true;
canclose = false;
canresize = true;
closequery = false;
destroyonhide = false;
text = "Trivia";
x = 288;
y = 173;
new GuiTextCtrl("EventTrivia_Text1") {
profile = GuiBlueTextProfile;
height = 20;
text = "Please fill out the text boxes.";
width = 167;
x = 7;
}
new GuiTextEditCtrl("EventTrivia_TextEdit1") {
profile = GuiBlueTextEditProfile;
height = 20;
width = 300;
x = 84;
y = 37;
}
new GuiTextCtrl("EventTrivia_Text2") {
profile = GuiBlueTextProfile;
height = 20;
text = "Question";
width = 53;
y = 34;
}
new GuiTextCtrl("EventTrivia_Text3") {
profile = GuiBlueTextProfile;
height = 20;
text = "Answer";
width = 42;
y = 74;
}
new GuiTextEditCtrl("EventTrivia_TextEdit2") {
profile = GuiBlueTextEditProfile;
height = 20;
width = 300;
x = 84;
y = 77;
}
new GuiButtonCtrl("EventTrivia_Button1") {
profile = GuiBlueButtonProfile;
text = "Submit Quesiton";
width = 385;
y = 134;
}
}
}
function onPlayerChats() {
if (player.chat=="/trivia" && player.guild=="Events Team") {
showTriviaGUI();
}
}
function EventTrivia_Button1.onAction() {
temp.question = EventTrivia_TextEdit1.text;
temp.answer = EventTrivia_TextEdit2.text;
showtext(201, 29.5, 11, "Arial", "","Last Winner");
setimgpart("head207.png",0,60,32,32);
changeimgzoom 201,.7;
}
Here are my questions as followed:
- I have a variable for the answer (temp.answer) already. I don't know how to do the rest, for finding the player's answer.
- I'm trying to find a way to make a string into an array, like you can in PHP with explode();. Is there a GS2 alternative?
- How do I set an image part, but place the image part in a certain location on the level? setimgpart() will just set the NPC's picture to the image, which I don't want.
Thanks in advanced.