Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-14-2009, 02:23 AM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Post 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!";
    
274;
    
224;

    new 
GuiTextCtrl("MyGUI_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "What is your question?";
      
width 111;
      
136;
      
16;
    }
    new 
GuiTextEditCtrl("MyGUI_TextEdit1") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 304;
      
34;
      
53;
    }
    new 
GuiTextCtrl("MyGUI_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "What is the answer to your question?";
      
width 182;
      
100;
      
89;
    }
    new 
GuiTextEditCtrl("MyGUI_TextEdit2") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 302;
      
36;
      
127;
    }
    new 
GuiButtonCtrl("MyGUI_Button1") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "Apply";
      
width 80;
      
151;
      
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 =]
Reply With Quote
  #2  
Old 07-14-2009, 02:37 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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;
__________________
Quote:
Reply With Quote
  #3  
Old 07-14-2009, 03:16 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
  #4  
Old 07-14-2009, 04:01 AM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
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!";
}
Reply With Quote
  #5  
Old 07-14-2009, 04:08 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by [email protected] View Post
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.
__________________
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 06:06 AM.


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