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)

callimuc 08-31-2012 03:01 AM

Quote:

Posted by Johnaudi (Post 189567)
Next question is a stupid question but keeps getting around my mind, about NPC movements, I try to make it but it goes for a second then it stops, I remember tricxta teaching it to me on Skype but I probably forgot a thing.

you can use move(dx, dy, time, options)

dx: new x position from the current one (like 3 would move 3 tiles to the right from the current position)
dy: same as dy for the y
time: the time the whole moving should take
options: different stuff being called

for the options just check this link
http://forums.graalonline.com/forums...ad.php?t=85584

Kavan 08-31-2012 08:05 AM

Quote:

Posted by callimuc (Post 190004)
you can use move(dx, dy, time, options)

dx: new x position from the current one (like 3 would move 3 tiles to the right from the current position)
dy: same as dy for the y
time: the time the whole moving should take
options: different stuff being called

for the options just check this link
http://forums.graalonline.com/forums...ad.php?t=85584

As an extension, if you're trying to move it to a certain point in the level, you can calculate the delta:

PHP Code:

temp.origin = {player.xplayer.y};
temp.target = {3030};
temp.delta = {target[0] - origin[0], target[1] - origin[1]};

move(delta[0], delta[1], 1024); 


Johnaudi 08-31-2012 08:16 AM

I was most likely looming for the one that uses temp.i, something Tric thought me but I forgot... for() not move()...

callimuc 08-31-2012 03:09 PM

Quote:

Posted by Johnaudi (Post 190122)
I was most likely looming for the one that uses temp.i, something Tric thought me but I forgot... for() not move()...

PHP Code:

for (temp.i=player.xtemp.i<player.x+5temp.i++) {
  
this.temp.i;


something like that? i wouldnt suggest that, use move() instead

xXziroXx 08-31-2012 04:30 PM

move() is superior to manually updating the position since it gets synced to both the client and the server.

Johnaudi 09-01-2012 01:15 PM

Thanks guys :)
Okay one more, is there anywhere better to store sended pms,comments anything? And make it readable and writable, other than clientr. // also Will clientr.test= 1,2,3,4 be counted as an array? (clientr.test[0])

Emera 09-01-2012 01:42 PM

Quote:

Posted by Johnaudi (Post 190701)
Thanks guys :)
Okay one more, is there anywhere better to store sended pms,comments anything? And make it readable and writable, other than clientr. // also Will clientr.test= 1,2,3,4 be counted as an array? (clientr.test[0])

You'll have to have a custom PM system to log sent messages as there's no way to log messages sent using the default one. I'd personally store them in text files. Also, you can tokenize that clientr flag to treat it like an array like this: temp.test = player.clientr.test.tokenize(","); and then you can use temp.test[0].

Johnaudi 09-01-2012 01:59 PM

Quote:

Posted by Emera (Post 190726)
You'll have to have a custom PM system to log sent messages as there's no way to log messages sent using the default one. I'd personally store them in text files. Also, you can tokenize that clientr flag to treat it like an array like this: temp.test = player.clientr.test.tokenize(","); and then you can use temp.test[0].

I know that, most-likely that's why im asking this, because I need more space than clientr than spam it all.
I've bin working on an Assignment System, having to read two tokenizations and looking forward for any easier way?
PHP Code:

function onActionServerSide() {
  if (
params[0] == "done") {
    
temp.params[1];
    
temp.toks player.clientr.assignments.tokenize(";");
    
temp.temp.toks[temp.i].tokenize(",");
    
temp.py findplayerbycommunityname(temp.a[1]);
    
temp.int(params[3]);
    
temp.py.clientr.assignmentsIDD temp.py.clientr.assignmentsIDD ";" temp."," temp.py.account "," params[2];
  }
  if (
params[0] == "give") {
    if (
player.clientr.assignments == "") {
      
player.clientr.assignments "a";
    }
    
temp.pl findplayerbycommunityname(params[1]);
    
temp.pl.clientr.assignmentsID += 1;
    
temp.pl.clientr.assignments temp.pl.clientr.assignments ";" temp.pl.clientr.assignmentsID "," player.account "," params[2];
    
temp.pl.chat "I've received an assignment! :(";
    
printf("Assignment Sent: from %s to %s"player.accounttemp.pl.account);
  }
  if (
params[0] == "C") {
    
player.clientr.assignments "a";
    
player.clientr.assignmentsID 0;
    
player.clientr.assignmentsIDD "a";
  }
}

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat == "/assign") {
    
this.number 0;
    
onOpen();
  }
}

function 
onOpen() {
  
drawGUI();
  
Assgn_Window3.visible false;
  
Assgn_Window2.visible false;
  
Assgn_Window1.visible true;
  
onGetFresh();
}

function 
drawGUI() {
  new 
GuiWindowCtrl("Assgn_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "550,225";
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Assignments";
    
= (screenwidth width) / 2;
    
= (screenheight height) / 2;
    new 
GuiScrollCtrl("Assgn_MultiLine1_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 82;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 460;
      
40;
      
36;
      new 
GuiMLTextCtrl("Assgn_MultiLine1") {
        
profile GuiBlueMLTextProfile;
        
height 17;
        
horizsizing "width";
        
htmlcompatibility false;
        
htmllinks true;
        
plaintext "You have no Assignments! Yay!";
        
width 185;
        
wordwrap false;
      }
    }
    new 
GuiButtonCtrl("Assgn_Give") {
      
profile GuiBlueButtonProfile;
      
height 45;
      
text "Give Assignment";
      
width 130;
      
40;
      
150;
    }
    new 
GuiButtonCtrl("Assgn_Done") {
      
profile GuiBlueButtonProfile;
      
height 45;
      
text "Finished Assignment";
      
width 130;
      
200;
      
150;
    }
    new 
GuiButtonCtrl("Assgn_Refr") {
      
profile GuiBlueButtonProfile;
      
height 45;
      
text "Refresh";
      
width 130;
      
370;
      
150;
    }
    new 
GuiButtonCtrl("Assgn_C") {
      
profile GuiBlueButtonProfile;
      
height 45;
      
text "C";
      
width 45;
      
503;
      
150;
    }
    new 
GuiTextCtrl("Assgn_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "| Date |";
      
width 39;
      
109;
      
15;
    }
    new 
GuiTextCtrl("Assgn_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "| From |";
      
width 42;
      
204;
      
15;
    }
    new 
GuiTextCtrl("Assgn_Text3") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "| Description |";
      
width 78;
      
308;
      
15;
    }
    new 
GuiTextCtrl("Assgn_Text6") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "| ID |";
      
width 24;
      
48;
      
15;
    }
  }
  new 
GuiWindowCtrl("Assgn_Window2") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "293,190";
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Finished Assignment";
    
300;
    
100;
    new 
GuiTextCtrl("Assgn_Text4") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Message :";
      
width 58;
      
33;
      
73;
    }
    new 
GuiTextEditCtrl("Assgn_CommenttoDone") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
text "I have finished my Assignment.";
      
width 200;
      
90;
      
75;
    }
    new 
GuiTextCtrl("Assgn_Text5") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "ID :";
      
width 18;
      
31;
      
33;
    }
    new 
GuiTextEditCtrl("Assgn_IDtoDone") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 146;
      
60;
      
34;
    }
    new 
GuiButtonCtrl("Assgn_Done2") {
      
profile GuiBlueButtonProfile;
      
height 45;
      
text "Checked";
      
width 112;
      
85;
      
136;
    }
  }
  new 
GuiWindowCtrl("Assgn_Window3") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "293,190";
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Give Assignment";
    
300;
    
100;
    new 
GuiTextCtrl("Assgn_Text8") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Comment :";
      
width 60;
      
10;
      
73;
    }
    new 
GuiTextCtrl("Assgn_Text14") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Prevent using html or ;";
      
width 150;
      
10;
      
100;
    }
    new 
GuiTextEditCtrl("Assgn_CommenttoGive") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
text "I want you to";
      
width 200;
      
90;
      
75;
    }
    new 
GuiTextCtrl("Assgn_Text9") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Account :";
      
width 60;
      
10;
      
33;
    }
    new 
GuiTextEditCtrl("Assgn_IDtoGive") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 146;
      
90;
      
34;
    }
    new 
GuiButtonCtrl("Assgn_Given") {
      
profile GuiBlueButtonProfile;
      
height 45;
      
text "Give";
      
width 112;
      
85;
      
136;
    }
  }
}

function 
Assgn_Done.onAction() {
  
Assgn_Window2.visible true;
}

function 
Assgn_Done2.onAction() {
  if (
Assgn_IDtoDone.text != NULL && Assgn_CommenttoDone.text != NULL) {
    
triggerserver("gui"name"done"Assgn_IDtoDone.textAssgn_CommenttoDone.textAssgn_IDtoDone.text);
    
Assgn_Window2.visible false;
  }
}

function 
Assgn_Give.onAction() {
  
Assgn_Window3.visible true;
}

function 
Assgn_Given.onAction() {
  if (
Assgn_IDtoGive.text != NULL && Assgn_CommenttoGive.text != NULL) {
    
triggerserver("gui"name"give"Assgn_IDtoGive.textAssgn_CommenttoGive.text);
    
Assgn_Window3.visible false;
  }
}

function 
Assgn_Refr.onAction() {
  
onGetFresh();
}

function 
Assgn_C.onAction() {
  
triggerserver("gui"name"C");
  
onOpen();
}

function 
onGetFresh() {
  if (
player.clientr.assignments != "a") {
    
Assgn_MultiLine1.text "";
    
temp.toks player.clientr.assignments.tokenize(";");
    
temp.player.clientr.assignmentsID;
    
temp.tokn player.clientr.assignmentsIDD.tokenize(";");
    for (
temp.1temp.<= temp.etemp.i++) {
      
temp.temp.toks[temp.i].tokenize(",");
      if (
temp.!= temp.s[0]) {
        
Assgn_MultiLine1.text Assgn_MultiLine1.text "   |" temp.a[0] @ "|                                 |" temp.a[1] @ "|                     |" temp.a[2] @ "|" "<br>";
      }
      
sleep(0.1);
    }
  }
  if (
player.clientr.assignmentsIDD != "a") {
    
temp.tokn player.clientr.assignmentsIDD.tokenize(";");
    for (
temp.0temp.<= 10temp.o++) {
      
temp.temp.tokn[temp.o].tokenize(",");
      if (
temp.s[0] != "" && temp.s[0] != "a" && temp.s[0] != 0) {
        
Assgn_MultiLine1.text "<font color=darkred>" temp.s[0] @ " Has Finished his Assignment!  |" temp.s[2] @ "|<br></font>" Assgn_MultiLine1.text;
      }
    }
  }
  
this.number += 1;
  if (
this.number 3) {
    
player.clientr.assignmentsIDD "a";
  }



Johnaudi 09-03-2012 09:59 AM

Question : how to use and give a "public function"?

Emera 09-03-2012 11:20 AM

Quote:

Posted by Johnaudi (Post 192151)
Question : how to use and give a "public function"?

Public functions are functions that other scripts can access via other scripts, level NPCs, classes and w/e.

PHP Code:

public function cheeseIsCool() {
  echo(
"Cheese is cool, pepper is not!");


PHP Code:

(@"-Weapon/Name").cheeseIsCool(); 


Johnaudi 09-04-2012 12:10 AM

Thanks about this :) stupid question : break; would stop the switch();?

PerfectDark 09-04-2012 12:37 AM

Yes.(Depending on where you put it).

break; stops the whole function and would be used after every case "putcasehere": script.

Example on the useage:
PHP Code:

function onActionServerside() {
  switch (
params[0]) {
  case 
"Var1":
    {
      
player.chat "Woot I triggered this case!";
      break;
    }
  case 
"Var2":
    {
      if (
clientr.banned != NULL
    {
      
player.chat "I have been banned from using this function :(";
    } else {
      
player.chat "Woot I triggered another case, I am on fire!";
    }
    break;
  }


Hope this helps, and don't do what i did by checking if a clientr function to check if someone is banned from a function unless you have a way to prevent the flag from being altered by a memory editor, or something like that. (you already know that)

Johnaudi 09-04-2012 10:36 AM

So if I don't include break; the script would keep on running to the second case?

knuckles 09-08-2012 06:26 PM

`I have no idea what scripts are, but let me say this.... why so complicated :0?

Johnaudi 09-08-2012 08:00 PM

Quote:

Posted by knuckles (Post 194927)
`I have no idea what scripts are, but let me say this.... why so complicated :0?

I suppose those are the basics...


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

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