Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Feedback System (https://forums.graalonline.com/forums/showthread.php?t=134264060)

Gunderak 08-02-2011 10:07 AM

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();



Tricxta 08-02-2011 12:07 PM

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.

cbk1994 08-02-2011 12:15 PM

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.

Gunderak 08-02-2011 04:21 PM

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

Crow 08-02-2011 05:29 PM

Quote:

Originally Posted by Gunderak (Post 1661215)
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); 


cbk1994 08-02-2011 05:58 PM

Quote:

Originally Posted by Gunderak (Post 1661215)
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 :oo:. You don't even need to store how the client voted in a variable if you combine the two triggers.


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

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