Graalians

Graalians (https://www.graalians.com/forums/index.php)
-   Creative Corner (https://www.graalians.com/forums/forumdisplay.php?f=17)
-   -   John's Scripts (https://www.graalians.com/forums/showthread.php?t=9528)

BboyEatsbacon 10-07-2012 06:10 PM

Quote:

Posted by callimuc (Post 208169)
An example for using vecx() and vecy():
http://forums.graalonline.com/forums...hp?t=134263215

This is exactly why I wish my school didn't have No Child Left Behind. I'm in need of taking a Geometry course due to the fact it's needed for programming, but I'm not allowed to...

Johnaudi 10-16-2012 08:01 PM

After training a bit with vecx and vecy, still understand nothing :/ I'd really appreciate someone teaching it for me more in an "easy" way. I'm trying to start making the melee system for the server, but it's really annoying setting coordinates so I thought vecx and vecy would help.

BboyEatsbacon 10-16-2012 08:26 PM

Quote:

Posted by Johnaudi (Post 214848)
After training a bit with vecx and vecy, still understand nothing :/ I'd really appreciate someone teaching it for me more in an "easy" way. I'm trying to start making the melee system for the server, but it's really annoying setting coordinates so I thought vecx and vecy would help.

Just think of it like this:
http://i.imgur.com/fabW6.png

callimuc 10-16-2012 08:43 PM

Quote:

Posted by BboyEatsbacon (Post 214859)
Just think of it like this:
http://i.imgur.com/fabW6.png

y u fastr dan i?! D: D; ): D;

Johnaudi 10-16-2012 09:43 PM

I still don't see how to use it, or rather where to use it. Is it like player.dir? Why not just set player.dir = 1;?

callimuc 10-16-2012 11:18 PM

Quote:

Posted by Johnaudi (Post 214909)
I still don't see how to use it, or rather where to use it. Is it like player.dir? Why not just set player.dir = 1;?

PHP Code:

for (k=0;k<4;k++) {
  if (
keydown(k)) {
    
player.dir k;
    
player.+= vecx(k);
    
player.+= vecy(k);
  }


if the players dir is 0: x will raise by 0, y will lower by -1 (player walks up)
if the players dir is 1: x will lower by -1, y will raise by 0 (player walks to the left)
if the players dir is 2: x will raise by 0, y will raise by 1 (player walks down)
if the players dir is 3: x will raise by 1, y will raise by 0 (player walks to the right)

Johnaudi 10-17-2012 01:41 PM

Quote:

Posted by callimuc (Post 215012)
PHP Code:

for (k=0;k<4;k++) {
  if (
keydown(k)) {
    
player.dir k;
    
player.+= vecx(k);
    
player.+= vecy(k);
  }


if the players dir is 0: x will raise by 0, y will lower by -1 (player walks up)
if the players dir is 1: x will lower by -1, y will raise by 0 (player walks to the left)
if the players dir is 2: x will raise by 0, y will raise by 1 (player walks down)
if the players dir is 3: x will raise by 1, y will raise by 0 (player walks to the right)

Oh I see now, but would it be helpful in a melee system?

callimuc 10-17-2012 06:44 PM

Quote:

Posted by Johnaudi (Post 215404)
Oh I see now, but would it be helpful in a melee system?

could make it easier for you to check the hitbox/trigger an function

Johnaudi 10-17-2012 08:02 PM

Quote:

Posted by callimuc (Post 215458)
could make it easier for you to check the hitbox/trigger an function

Not sure if there is a custom command for that, but, can I set a limit for a bullet using shoot() params? Like I want it to end at 2 tiles infront of the player, and make the bullet invisible this way it would be easier to make it similar to my gun system.

Kiko 10-17-2012 08:11 PM

I really want to learn to script but It's so confusing, I just can't focus.

callimuc 10-17-2012 09:16 PM

Quote:

Posted by Johnaudi (Post 215500)
Not sure if there is a custom command for that, but, can I set a limit for a bullet using shoot() params? Like I want it to end at 2 tiles infront of the player, and make the bullet invisible this way it would be easier to make it similar to my gun system.

dont think so. you can change the power though to have it drop earlier

Striker 11-23-2012 08:55 PM

Quote:

Posted by Johnaudi (Post 182303)
Hey,
Got bored a bit, and don't know what to add to the scripts I made a while back. so having you guys give me an opinion would help. Also, I'm still at a learning stage to any developer feel free to correct me/teach me anything new or give me idea's or other ways to do the certain thing.
Echo from NC (Made while learning triggerserver)
  • Current usage by saying "/echo TextGoesHere"
  • Can echo from the player's chat to RC
  • Anti-Spam built (yes, I know timevar2 but I have thought of a different way)
Spoiler

PHP Code:

function onActionServerSide() {
  if (
params[0] == "cmd") {
    
this.toks player.chat.substring(6);
    echo(
player.nick " [" player.account "] : " this.toks);
  }
}

//#CLIENTSIDE
function onCreated() {
  
this.num 1;
}

function 
onPlayerChats() {
  if (
player.chat.starts("/echo")) {
    if (
this.num == 1) {
      
this.toks player.chat.substring(6);
      
triggerserver("gui"name"cmd");
      
sleep(0.1);
      
this.num 0;
      
setTimer(0.01);
      
player.chat "Echo'ed : " player.chat.substring(6);
    } else 
player.chat "Please wait 5 seconds before sending another Echo!";
  }
}

function 
onTimeOut() {
  if (
this.num == 0) {
    
sleep(5);
    
this.num 1;
  }
  
setTimer(0.1);



Level Warper (GUI)
  • Current usage by saying "openwarper"
  • Simple GUI with the default interface
  • Option to warp to players / or level's using correct coordinates
  • Can stick the player("/stick Graal######") which can keep him on track and stop tracing too ("/unstick")
  • Some minor Errors on warping to 0,0 (x,y)
Spoiler

PHP Code:

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat == "openwarper") {
    
drawGUI();
    
LevWarps_Window2.visible true;
  }
}

function 
drawGUI() {
  new 
GuiWindowCtrl("LevWarps_Window2") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,189";
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Level Warper";
    
486;
    
272;
    new 
GuiButtonCtrl("LevWarps_Button2") {
      
profile GuiBlueButtonProfile;
      
height 35;
      
text "Warp";
      
width 131;
      
97;
      
135;
    }
    new 
GuiTextCtrl("LevWarps_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "X";
      
width 8;
      
38;
      
29;
    }
    new 
GuiTextCtrl("LevWarps_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Y";
      
width 9;
      
107;
      
29;
    }
    new 
GuiTextCtrl("LevWarps_Text3") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Level Name";
      
width 67;
      
171;
      
29;
    }
    new 
GuiTextEditCtrl("LevWarps_TextEdit1") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 34;
      
34;
      
50;
    }
    new 
GuiTextEditCtrl("LevWarps_TextEdit2") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 34;
      
105;
      
50;
    }
    new 
GuiTextEditCtrl("LevWarps_TextEdit3") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 106;
      
167;
      
50;
    }
    new 
GuiCheckBoxCtrl("LevWarps_CheckBox1") {
      
profile GuiBlueCheckBoxProfile;
      
height 20;
      
text "Player Warp  :";
      
width 100;
      
69;
      
85;
    }
    new 
GuiTextEditCtrl("LevWarps_TextEdit4") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 106;
      
167;
      
85;
    }
  }
}

function 
LevWarps_Button2.onAction() {
  if (
LevWarps_CheckBox1.checked && LevWarps_TextEdit4.text != "") {
    
toks LevWarps_TextEdit4.text.tokenize(" ");
    if (
LevWarps_TextEdit4.text.starts("/stick")) {
      
pl findplayerbycommunityname(toks[1]);
      
this.number 1;
      
settimer(0.01);
      return;
    }
    if (
LevWarps_TextEdit4.text == "/unstick") {
      
this.number 0;
      return;
    }
    
temp.pl findplayerbycommunityname(LevWarps_TextEdit4.text);
    
player.temp.pl.x;
    
player.temp.pl.y;
    
player.level temp.pl.level;
    
LevWarps_TextEdit1.text temp.pl.x;
    
LevWarps_TextEdit2.text temp.pl.y;
    
LevWarps_TextEdit3.text temp.pl.level;
    
player.chat "x: " player." y: " player." level: " player.level;
  } else {
    if (
LevWarps_TextEdit1 != "") {
      
player.LevWarps_TextEdit1.text;
    }
    if (
LevWarps_TextEdit2 != "") {
      
player.LevWarps_TextEdit2.text;
    }
    if (
LevWarps_TextEdit3 != "") {
      
player.level LevWarps_TextEdit3.text;
    }
  }
}

function 
onTimeout() {
  if (
this.number == 1) {
    
player.= (pl.2);
    
player.= (pl.1);
    
setTimer(0.2);
  } else return;



Calculator (GUI)
  • Current usage by saying "/calc"
  • Quick calculation tool with both "buttons" and "text" (Sadly' I don't know how to limit the text by numbers only)
  • Works with addition, subtraction , multiplication and division
  • Auto closing parentheses (kinda useless atm)
Spoiler

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
n1.value 1;
  
n2.value 2;
  
n3.value 3;
  
n4.value 4;
  
n5.value 5;
  
n6.value 6;
  
n7.value 7;
  
n8.value 8;
  
n9.value 9;
  
n0.value 0;
  
nP.value ".";
  
nPar.value1 "(";
  
nPar.value2 ")";
  
this.mode NULL;
  
this.started true;
  
Calculator_Tb1.text "";
  
Calculator_Tb2.text "";
  
Calculator_Result.text "";
  
Calculator_mode.text "";
  
nPar.stated false;
}

function 
onPlayerChats() {
  if (
player.chat == "/calc") {
    
drawGUI();
    
Calculator_Window1.visible true;
    
onCreated();
  }
}

function 
drawGUI() {
  new 
GuiWindowCtrl("Calculator_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "271,268";
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
text "Calculator";
    
541;
    
255;
    new 
GuiButtonCtrl("Calculator_nP") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text ".";
      
width 39;
      
130;
      
220;
    }
    new 
GuiButtonCtrl("Calculator_nPar") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "( )";
      
width 39;
      
30;
      
220;
    }
    new 
GuiButtonCtrl("Calculator_n0") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "0";
      
width 39;
      
80;
      
220;
    }
    new 
GuiButtonCtrl("Calculator_n1") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "1";
      
width 39;
      
30;
      
177;
    }
    new 
GuiButtonCtrl("Calculator_n2") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "2";
      
width 39;
      
80;
      
177;
    }
    new 
GuiButtonCtrl("Calculator_n3") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "3";
      
width 39;
      
130;
      
177;
    }
    new 
GuiButtonCtrl("Calculator_n4") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "4";
      
width 39;
      
30;
      
130;
    }
    new 
GuiButtonCtrl("Calculator_n5") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "5";
      
width 39;
      
80;
      
130;
    }
    new 
GuiButtonCtrl("Calculator_n6") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "6";
      
width 39;
      
130;
      
130;
    }
    new 
GuiButtonCtrl("Calculator_n7") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "7";
      
width 39;
      
30;
      
83;
    }
    new 
GuiButtonCtrl("Calculator_n8") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "8";
      
width 39;
      
80;
      
83;
    }
    new 
GuiButtonCtrl("Calculator_n9") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "9";
      
width 39;
      
130;
      
83;
    }
    new 
GuiButtonCtrl("Calculator_add") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "+";
      
width 25;
      
180;
      
130;
    }
    new 
GuiButtonCtrl("Calculator_min") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "-";
      
width 25;
      
215;
      
130;
    }
    new 
GuiButtonCtrl("Calculator_tim") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "X";
      
width 25;
      
180;
      
177;
    }
    new 
GuiButtonCtrl("Calculator_div") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "/";
      
width 25;
      
215;
      
177;
    }
    new 
GuiButtonCtrl("Calculator_equ") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "=";
      
width 60;
      
180;
      
220;
    }
    new 
GuiButtonCtrl("Calculator_C") {
      
profile GuiBlueButtonProfile;
      
height 37;
      
text "Clear";
      
width 60;
      
180;
      
83;
    }
    new 
GuiTextEditCtrl("Calculator_Tb1") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 36;
      
31;
      
34;
    }
    new 
GuiTextCtrl("Calculator_mode") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "";
      
width 8;
      
88;
      
32;
    }
    new 
GuiTextEditCtrl("Calculator_Tb2") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 36;
      
114;
      
34;
    }
    new 
GuiTextCtrl("Calculator_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "=";
      
width 8;
      
162;
      
33;
    }
    new 
GuiTextCtrl("Calculator_Result") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "";
      
width 36;
      
186;
      
30;
    }
  }
}

function 
Calculator_nPar.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "" && nPar.stated == false) {
      
Calculator_Tb1.text nPar.value1;
      
nPar.stated true;
    } else if (
nPar.stated == false) {
      
Calculator_Tb1.text Calculator_Tb1.text nPar.value1;
      
nPar.stated true;
    } else if (
nPar.stated == true) {
      
Calculator_Tb1.text Calculator_Tb1.text nPar.value2;
      
nPar.stated false;
    }
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "" && nPar.stated == false) {
      
Calculator_Tb2.text nPar.value1;
      
nPar.stated true;
    } else if (
nPar.stated == false) {
      
Calculator_Tb2.text Calculator_Tb2.text nPar.value1;
      
nPar.stated true;
    } else if (
nPar.stated == true) {
      
Calculator_Tb2.text Calculator_Tb2.text nPar.value2;
      
nPar.stated false;
    }
  }
}

function 
Calculator_nP.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text nP.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text nP.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text nP.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text nP.value;
  }
}

function 
Calculator_n0.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text n0.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text n0.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text n0.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text n0.value;
  }
}

function 
Calculator_n1.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text n1.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text n1.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text n1.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text n1.value;
  }
}

function 
Calculator_n2.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text n2.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text n2.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text n2.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text n2.value;
  }
}

function 
Calculator_n3.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text n3.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text n3.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text n3.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text n3.value;
  }
}

function 
Calculator_n4.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text n4.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text n4.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text n4.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text n4.value;
  }
}

function 
Calculator_n5.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text n5.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text n5.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text n5.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text n5.value;
  }
}

function 
Calculator_n6.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text n6.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text n6.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text n6.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text n6.value;
  }
}

function 
Calculator_n7.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text n7.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text n7.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text n7.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text n7.value;
  }
}

function 
Calculator_n8.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text n8.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text n8.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text n8.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text n8.value;
  }
}

function 
Calculator_n9.onAction() {
  if (
this.started == true) {
    if (
Calculator_Tb1.text == "") {
      
Calculator_Tb1.text n9.value;
    } else 
Calculator_Tb1.text Calculator_Tb1.text n9.value;
  }
  if (
this.started == false) {
    if (
Calculator_Tb2.text == "") {
      
Calculator_Tb2.text n9.value;
    } else 
Calculator_Tb2.text Calculator_Tb2.text n9.value;
  }
}

function 
Calculator_add.onAction() {
  if (
this.started == true) {
    
this.started false;
    
this.mode "+";
    
nPar.stated false;
    
Calculator_mode.text this.mode;
  }
}

function 
Calculator_min.onAction() {
  if (
this.started == true) {
    
this.started false;
    
this.mode "-";
    
nPar.stated false;
    
Calculator_mode.text this.mode;
  }
}

function 
Calculator_tim.onAction() {
  if (
this.started == true) {
    
this.started false;
    
this.mode "X";
    
nPar.stated false;
    
Calculator_mode.text this.mode;
  }
}

function 
Calculator_div.onAction() {
  if (
this.started == true) {
    
this.started false;
    
this.mode "/";
    
nPar.stated false;
    
Calculator_mode.text this.mode;
  }
}

function 
Calculator_C.onAction() {
  
this.mode NULL;
  
nPar.stated false;
  
this.started true;
  
Calculator_Tb1.text "";
  
Calculator_Tb2.text "";
  
Calculator_Result.text "";
  
Calculator_mode.text "";
}

function 
Calculator_equ.onAction() {
  if (
Calculator_Tb1.text == "" || Calculator_Tb2.text == "") {
    return;
  }
  if (
this.mode == "+") {
    
Calculator_Result.text Calculator_Tb1.text Calculator_Tb2.text;
  }
  if (
this.mode == "-") {
    
Calculator_Result.text Calculator_Tb1.text Calculator_Tb2.text;
  }
  if (
this.mode == "X") {
    
Calculator_Result.text Calculator_Tb1.text Calculator_Tb2.text;
  }
  if (
this.mode == "/") {
    
Calculator_Result.text Calculator_Tb1.text Calculator_Tb2.text;
  }



-------------------------------------------------
Any errors? Please tell me so I can learn. I'd Like to Thank Emera and Callimuc for all the effort they put into teaching me those. Can't thank you enough guys :)

hey wait!
i will also be thanking you john and emera after teaching me gs2 like you currently are!
ill create my own thread and do like john :3

callimuc 11-23-2012 09:02 PM

Quote:

Posted by Striker (Post 238957)
hey wait!
i will also be thanking you john and emera after teaching me gs2 like you currently are!
ill create my own thread and do like john :3

yea im doing nothing >:

and maybe you should go on learning before creating such a thread ;) for the help you already got one ^^

Striker 11-29-2012 02:24 PM

nuuu callimuc u and emera help i was just commenting on the thread!

i said "u john and emera" i meant u callimuc and emera, u know i always respect every one thats nice/kind!

BboyEatsbacon 02-06-2013 02:32 AM

Math.sin(float) - returns float
Math.cos(float) - returns float
Math.tan(float) - returns float

You should add these to the calculator :)


All times are GMT. The time now is 12:32 AM.

Powered by vBulletin/Copyright ©2000 - 2025, vBulletin Solutions Inc.