Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Server (https://forums.graalonline.com/forums/forumdisplay.php?f=14)
-   -   Scripting with NPC Server offline! (https://forums.graalonline.com/forums/showthread.php?t=22427)

Cyber-X 01-29-2002 06:46 AM

Scripting with NPC Server offline!
 
How can I script a NPC to a p2p server that is not up yet??? What are the basic commands??? Like this... I want to script these NPCs to work in a p2p server... How can I do???

// NPC Made by CyberX
if(playerenters){
this.power=0;
}
if (actionlumbing) {
message #v(this.power)% done;
lumbpower = strtofloat(#p(0));
this.power +=lumbpower;
sleep 0.05;
putleaps 3,x+2,y;
}
if (this.power=100) {
message 100% done.;
putleaps 3,x,y;
putleaps 3,x+1,y;
putleaps 3,x+2,y;
putleaps 3,x+3,y;
putleaps 3,x+4,y;
sleep 0.05;
this.plus=1+strtofloat(#s(client.lumber));
setstring client.lumber,#v(this.plus);
say2 Total of wood: #s(client.lumber);
destroy;
}




and




// NPC made by CyberX
if (strtofloat(#s(client.lumber))>19) {
set wood1;
}
if (playertouchsme&&!wood1) {
say2 Not enough wood!;
}
if (playertouchsme&&wood1&&money1) {
say2 You've already gotten a
#bwoodpack!
}
if (playertouchsme&&w1) {
say2 You've already gotten a
#bwoodpack!
}
if (playertouchsme&&wood1&&!w1&&!w2&&!money1&&!money2 ) {
timeout = 1;
putleaps 3,x+2,y;
this.less=strtofloat(#s(client.lumber))-20;
setstring client.lumber,#v(this.less);
set w1;
freezeplayer 3;
}
if (timeout) {
putleaps 3,x+2,y;
}

Faheria_GP2 01-29-2002 06:57 AM

Re: Scripting with NPC Server offline!
 
NPC Code:

// NPC Made by CyberX
if(playerenters){
this.power=0;
}
if (actionlumbing) {
message #v(this.power)% done;
lumbpower = strtofloat(#p(0)); //See line below
this.power +=lumbpower; //These two lines could be compacted into one
sleep 0.05; //Minimuim sleep/timeout is 0.1
putleaps 3,x+2,y;
}
if (this.power=100) { //this should be inside an event
message 100% done.;
putleaps 3,x,y;
putleaps 3,x+1,y;
putleaps 3,x+2,y;
putleaps 3,x+3,y;
putleaps 3,x+4,y;
sleep 0.05; //Minimum sleep/timeout is 0.1
this.plus=1+strtofloat(#s(client.lumber)); //This
setstring client.lumber,#v(this.plus); //and this could be compacted into one line
say2 Total of wood: #s(client.lumber);
destroy;
}


NPC Code:

// NPC made by CyberX
if (strtofloat(#s(client.lumber))>19) { //Should be inside an event
set wood1;
}
if (playertouchsme&&!wood1) {
say2 Not enough wood!;
}
if (playertouchsme&&wood1&&money1) {
say2 You've already gotten a
#bwoodpack!
}
if (playertouchsme&&w1) {
say2 You've already gotten a
#bwoodpack!
}
if (playertouchsme&&wood1&&!w1&&!w2&&!money1&&!money2 ) {
timeout = 1;
putleaps 3,x+2,y;
this.less=strtofloat(#s(client.lumber))-20; //See below
setstring client.lumber,#v(this.less); //These two could be compacted into one line
set w1;
freezeplayer 3;
}
if (timeout) {
putleaps 3,x+2,y;
}



there, I have added comments where corrections are necessary, fix that up, and it should work inside NPC-Server

Cyber-X 01-29-2002 07:25 AM

what do you mean with "should be inside an event"???

Faheria_GP2 01-29-2002 07:51 AM

events are things like

if (playerenters)
if (playertouchsme)

events are not things like

if (issparringzone)
if (keydown(i))

Saga2001 02-08-2002 01:08 AM

Quote:

Originally posted by Faheria_GP2
events are things like

if (playerenters)
if (playertouchsme)

events are not things like

if (issparringzone)
if (keydown(i))

actually keydown(i) is an event.

joseyisleet 02-08-2002 02:03 AM

-=Josey=-
Keydown is a function. It's called locally by the client's Graal.exe. An event is called by the NPC or a server. Correct me if I'm wrong here anyone.

joseyisleet 02-08-2002 03:08 AM

-=Josey=-
Heh, I wasn't looking for a "better word", I was looking for a correct answer.

TDK_RC6 02-08-2002 11:13 AM

i wish stefan would make keydown a event, instead of a function

BocoC 02-08-2002 12:13 PM

The problem most people don't understand is that NPCs don't run CONSTANTLY. They run only when they need to. So if you got a NPC with this code:
NPC Code:

if (created) showcharacter;
if (keydown(0)) say2 Blah;


The
if(keydown(0))
will ONLY work if the NPC is activated while the player is hold down the UP key. People put keydown() in loops because the script is ACTIVE and it will pick up the keydown. I hope somebody can help me on this. Wanna give it a try Kaimetsu?

Saga2001 02-09-2002 12:19 AM

Actually also you can do this i remember:
NPC Code:

if (created||playerenters) {
timeout=.05;
}
if (timeout) timeout=.05;
if (keydown(0)) message hi;


because it was activated and than it was continuing...right?

sorry about the keydown(i) i was kinda tired, now i realixe cause you can't call it alone.

BocoC 02-09-2002 07:02 AM

Quote:

Originally posted by Kaimetsu
Pretty much what Boco said, but reworded :)
Yes, thanks. I was having trouble wording it. XD


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

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