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 08-02-2011, 10:07 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Feedback System

Before anyone posts this.
Yes you could ordinarily do it with buttons and alot easier too.
BUT i chose to tempt it with a checkbox as a challenge for my self.
anyway here is what i have done, feel free to use as you wish.
Feedback on the script or improvements are welcomed
PHP Code:
function onActionServerSidecmd ){
  if ( 
cmd == "SendFeedback" ) {
  
clientr.feedbacked=1;
  if(
server.checkbox == 1){
  echo(
"Feedback: "@player.nick@" Likes The Server!");
  
server.feedback.yes += 1;
  
server.feedback.votes += 1;
  }
  if(
server.checkbox == 0){
  echo(
"Feedback: "@player.nick@" Doesnt Like The Server!");
  
server.feedback.no +=1;
  
server.feedback.votes += 1;
  }
  }
    if ( 
cmd == "Setcheckbox1Yes" ) {
    
server.checkbox=1;
  }
      if ( 
cmd == "Setcheckbox1No" ) {
    
server.checkbox=0;
  }
  }
//#CLIENTSIDE
function onCreated() {
sleep 100;
if(
clientr.feedbacked == 1){
return;
}
  new 
GuiWindowCtrl("Feedback_Test_Window2") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "172,53";

    
canclose false;
    
canmaximize false;
    
canminimize false;
    
canmove false;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "             Feedback";
    
610;
    
261;

    new 
GuiCheckBoxCtrl("Feedback_Test_CheckBox1") {
      
profile GuiBlueCheckBoxProfile;
      
height 20;
      
width 100;
      
5;
      
5;
      
checked false;
    }
    new 
GuiTextCtrl("Feedback_Test_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Do You Like This Server?";
      
width 225;
      
23;
      
5;
    }
    new 
GuiButtonCtrl("Feedback_Test_Button1") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "Done";
      
width 57;
      
116;
      
30;
    }
    new 
GuiButtonCtrl("Feedback_Test_Button2") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "Cancel";
      
width 57;
      
30;
    }
  }
}

function 
Feedback_Test_Button1.onAction() {
Feedback_Test_Window2.hide();
Feedback_Test_CheckBox1.hide();
Feedback_Test_Text1.hide();
Feedback_Test_Text2.hide();
Feedback_Test_Text3.hide();
Feedback_Test_Button1.hide();
Feedback_Test_Button2.hide();
say2("Thankyou For Your Feedback!");
if(
Feedback_Test_CheckBox1.checked == true){
triggerserver"gui"name"Setcheckbox1Yes" );
triggerserver"gui"name"SendFeedback" );
}
if(
Feedback_Test_CheckBox1.checked == false){
triggerserver"gui"name"Setcheckbox1No" );
triggerserver"gui"name"SendFeedback" );
}
}
function 
Feedback_Test_Button2.onAction() {
Feedback_Test_Window2.hide();
Feedback_Test_CheckBox1.hide();
Feedback_Test_Text1.hide();
Feedback_Test_Text2.hide();
Feedback_Test_Text3.hide();
Feedback_Test_Button1.hide();
Feedback_Test_Button2.hide();

__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 08-02-2011 at 10:19 AM.. Reason: Fixed error in the script.
Reply With Quote
  #2  
Old 08-02-2011, 12:07 PM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is just really niceTricxta is just really nice
You could definitely clean this script up a bit

The following code:
PHP Code:
Feedback_Test_Window2.hide();
Feedback_Test_CheckBox1.hide();
Feedback_Test_Text1.hide();
Feedback_Test_Text2.hide();
Feedback_Test_Text3.hide();
Feedback_Test_Button1.hide();
Feedback_Test_Button2.hide(); 
Should be put in its own function since I can see it occur twice.

Also the use of 2 server strings isn't needed since you can just tally the yes and no votes together. The overall flow of the program isn't too shabby. Im not to familiar with GS2 so I can't really make any more comments.
__________________
Quote:
Originally Posted by Crono View Post
No look at it, Stefan is totally trolling Thor. Calling Classic a "playerworld" (something it's not supposed to be) is the ultimate subtle insult to a true fan.

It's genius.
Reply With Quote
  #3  
Old 08-02-2011, 12:15 PM
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
The biggest problem with your script is that it's not formatted consistently. The second biggest is that you're using a checkbox instead of a button (I understand you want to 'challenge' yourself, but it's terrible to do that from a UI perspective).

Also note:
  • There's no reason to hide every object since they're all children of the window. Feedback_Test_Window2.hide(); will suffice.
  • There's no reason to send two triggers. Just send the value (whether they liked it or not) as a parameter.
  • I'm not quite sure why you're using a server variable at all. Even if you do it with two triggers, a player. or player.clientr. variable would work fine.
  • Make sure that the player has not already sent feedback on serverside to prevent hackers from voting infinite times.
  • Not sure why you have sleep 100;, but that should be sleep(100);
  • Give your GUI objects meaningful names. Feedback_Cancel is a better name than Feedback_Test_Button2.
__________________
Reply With Quote
  #4  
Old 08-02-2011, 04:21 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
sleep 100 is so the player gets time to have a look at the server.
a feedback option as soon as you log in is a bit stupid.
and as for the hide things. wow i never knew that. il be sure to remember that from now on.
and i want them to be server side so that it saves them to the server.
for future reference xD
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #5  
Old 08-02-2011, 05:29 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Gunderak View Post
sleep 100 is so the player gets time to have a look at the server.
Your syntax is wrong, though. You got:
PHP Code:
sleep 100
When it should be:
PHP Code:
sleep(100); 
Reply With Quote
  #6  
Old 08-02-2011, 05:58 PM
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 Gunderak View Post
i want them to be server side so that it saves them to the server.
for future reference xD
You don't need to store it in a server. variable for it to be accessed serverside . You don't even need to store how the client voted in a variable if you combine the two triggers.
__________________
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 01:23 AM.


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