Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   event script help! NEW! (https://forums.graalonline.com/forums/showthread.php?t=86885)

[email protected] 07-14-2009 02:23 AM

event script help! NEW!
 
hi, im making this event script, called trivia. Basically, the events team actiongrabs a block, Im using block.png, and when he grabs it, a gui pops up and he types any question he can think of in a textedit gui, and he has to put the answer in the textedit gui below that. For some reason, when he hits apply, the question doesnt appear above the block. And when the player says the right answer, it doesnt show that they said the right answer D;.

Heres the script, please help:

PHP Code:

//#CLIENTSIDE
function onCreated() {
function 
onActionGrab()
 {
if (
player.guild == "Events Team")
  {
MyGUI_Window1.visible=true;
 }
} 
  new 
GuiWindowCtrl("MyGUI_Window1") {
    
profile = GuiBlueWindowProfile;
    
clientrelative = true;
    
clientextent = "389,225";

    
canmove = true;
    
canresize = true;
    
closequery = false;
    
destroyonhide = false;
    
text = "                                                     Trivia!";
    
x = 274;
    
y = 224;

    new 
GuiTextCtrl("MyGUI_Text1") {
      
profile = GuiBlueTextProfile;
      
height = 20;
      
text = "What is your question?";
      
width = 111;
      
x = 136;
      
y = 16;
    }
    new 
GuiTextEditCtrl("MyGUI_TextEdit1") {
      
profile = GuiBlueTextEditProfile;
      
height = 20;
      
width = 304;
      
x = 34;
      
y = 53;
    }
    new 
GuiTextCtrl("MyGUI_Text2") {
      
profile = GuiBlueTextProfile;
      
height = 20;
      
text = "What is the answer to your question?";
      
width = 182;
      
x = 100;
      
y = 89;
    }
    new 
GuiTextEditCtrl("MyGUI_TextEdit2") {
      
profile = GuiBlueTextEditProfile;
      
height = 20;
      
width = 302;
      
x = 36;
      
y = 127;
    }
    new 
GuiButtonCtrl("MyGUI_Button1") {
      
profile = GuiBlueButtonProfile;
      
height = 37;
      
text = "Apply";
      
width = 80;
      
x = 151;
      
y = 169;
    }
  }
}

function 
MyGUI_Button1.onAction() {
  
// Button "Apply" has been pressed
MyGUI_Window1.visible=false;
message SPC "MyGUI_TextEdit1" SPC;
 }
function 
onPlayerChats()
{
if (
player.chat == "MyGUI_TextEdit1")
{
player.chat = "I got the answer right!";
 }
else
player.chat = "";
} 

THanks so much [;

-jamerson =]

fowlplay4 07-14-2009 02:37 AM

Well for starters, you shouldn't have functions in functions like that..

Also, you're mixing GS1 with GS2..

Instead of message you do..

this.chat = "a test message!";

And to reference TextEdit fields you have to use:

MyGUI_TextEdit1.text

So "message SPC "MyGUI_TextEdit1" SPC;"

Looks like:

this.chat = MyGUI_TextEdit1.text;

cbk1994 07-14-2009 03:16 AM

Your whole thing is clientside. Your best bet is to use a DB NPC (or local level NPC), trigger serverside, then tell that NPC what the question and answer are. That NPC would then have to listen for player's chat and decide the winner.

[email protected] 07-14-2009 04:01 AM

ok, the question appears on the block ok, but whats wrong with this?

if (player.chat == "MyGUI_TextEdit2")
{
player.chat = "I got the answer right!";
}

cbk1994 07-14-2009 04:08 AM

Quote:

Originally Posted by [email protected] (Post 1506872)
ok, the question appears on the block ok, but whats wrong with this?

if (player.chat == "MyGUI_TextEdit2")
{
player.chat = "I got the answer right!";
}

No, the question won't appear on the block correctly. Like I said, it's clientside (read that article), and will only show for you and no one else.

To get the text of an object, you need to pull it from the 'text' variable of the control.


All times are GMT +2. The time now is 05:44 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.