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 10-14-2005, 08:08 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Plane

Back by request, the thread I deleted! XD Feel free to respond =D (still having trouble with signs and x y in level, but i decided to work on it alone, help wouldn't hurt though , especially with teh signs)
Quote:
Okay, I'm making a plane for playeruse, only problem is that while flying the player can read signs, and enter buildings(warp out of buildings isn't working right, only for x and y)here's my script, suggestions?
NPC Code:
if (actionserverside) {
if (strequals(#p(0),warp)) {
setlevel2 #s(client.planelevel),#s(client.planex),#s(client. planey);
}
}
//#CLIENTSIDE
// NPC made by Excaliber&&Shadox
if (keypressed&&strequals(#p(1),C)) {
if (this.inuse == 0) {
this.inuse=1;
enableweapons;
setstring client.planespeed,1.25;
timeout=.05
}
else {
timeout = 0;
enabledefmovement;
setstring client.planespeed,0;
this.inuse=0;
hideimg 747;
enableweapons;
}
}

if(timeout&&this.inuse==1&&!isonmap){
triggeraction 0,0,serverside,Plane,warp;
enabledefmovement;
hideimg 747;
this.inuse=0;
}
if (timeout && this.inuse == 1&&isonmap) {
setani idle,;
disabledefmovement;
this.planex=#v(playerx);
this.planey=#v(playery);
setstring client.planex,#v(playerx);
setstring client.planey,#v(playery);
setstring client.planelevel,#L;
if(playerdir==0){
showimg 747,dr-planeN.png,playerx-1,playery-1.5;
}
if(playerdir==2){
showimg 747,dr-planeS.png,playerx-1,playery-1.5;
}
if(playerdir==1){
showimg 747,dr-planeW.png,playerx-1,playery-1.5;
}
if(playerdir==3){
showimg 747,dr-planeE.png,playerx-1,playery-1.5;
}
hideplayer .05;
if (keydown(0)) {
hideimg 747;
showimg 747,dr-planeN.png,playerx-1,playery-1.5;
playerdir = 0;
playery-=strtofloat(#s(client.planespeed));
}
if (keydown(1)) {
hideimg 747;
showimg 747,dr-planeW.png,playerx-1,playery-1.5;
playerdir = 1;
playerx-=strtofloat(#s(client.planespeed));
}
if (keydown(2)) {
hideimg 747;
showimg 747,dr-planeS.png,playerx-1,playery-1.5;
playerdir = 2;
playery+=strtofloat(#s(client.planespeed));
}
if (keydown(3)) {
hideimg 747;
showimg 747,dr-planeE.png,playerx-1,playery-1.5;
playerdir = 3;
playerx+=strtofloat(#s(client.planespeed));
}
if (keydown(0)&&keydown(3)) {
hideimg 747;
showimg 747,dr-planeNE.png,playerx-1,playery-1.5;
}
if (keydown(0)&&keydown(1)) {
hideimg 747;
showimg 747,dr-planeNW.png,playerx-1,playery-1.5;
}
if (keydown(2)&&keydown(3)) {
hideimg 747;
showimg 747,dr-planeSE.png,playerx-1,playery-1.5;
}
if (keydown(2)&&keydown(1)) {
hideimg 747;
showimg 747,dr-planeSW.png,playerx-1,playery-1.5;
}
changeimgzoom 747,1.5;
changeimgvis 747,2;
timeout=.05;
}

if (weaponfired) {
say2 Plane:#b
Press C to take off#b
then, C to land.#b
}


Last edited by excaliber7388; 10-14-2005 at 08:39 PM.. Reason: formatted a wee bit better :)
Reply With Quote
  #2  
Old 10-14-2005, 08:28 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
I didn't request that you spam the forums with threads you already made, I was simply mentioning it for future reference.

A quick glance at that script and I have noticed very poor scripting habits, aswell as syntax errors (I see a few missing semi-colons.) Please do not try to distribute scripts for other people to use unless they are, by standards, scripted decently. Poorly written scripts can be very misleading to beginners.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #3  
Old 10-14-2005, 08:33 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Well, it wasn't formatted in anyway (I can already hear Skyld scolding me XD) but it does work, except for the reading thing and the x y in the warp, i know thats far off
Reply With Quote
  #4  
Old 10-14-2005, 08:35 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by excaliber7388
Well, it wasn't formatted in anyway (I can already hear Skyld scolding me XD) but it does work, except for the reading thing and the x y in the warp, i know thats far off
I wasn't referring to the formatting. But just out of curiosity, if you know Skyld is going to scold you for it, why do you continue to not format your scripts?
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #5  
Old 10-14-2005, 08:37 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
i scripted it quick, didn't feal like wasting time, ill format it now x_X anyway, suggestions for the reading and x y part of the warp?
Reply With Quote
  #6  
Old 10-14-2005, 08:46 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by excaliber7388
i scripted it quick, didn't feal like wasting time, ill format it now x_X anyway, suggestions for the reading and x y part of the warp?
Why would other people waste their time trying to help you, if you don't want to waste your time formatting it so they can read it?

anyway, for the x,y warping, you have to use strtofloat.

NPC Code:
setlevel2 #s(client.planelevel),strtofloat(#s(client.planex)  ),strtofloat(#s(client.planey));



Another thing, client. variables are very insecure, people will be able to abuse this script to make it warp them to wherever they want on your server.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #7  
Old 10-14-2005, 08:55 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by excaliber7388
(I can already hear Skyld scolding me XD)
Nice to know you are beginning to take what I say on board. Now you just need to do as other nice forum users say and actually format your scripting nicely.
Quote:
Originally Posted by ApothiX
NPC Code:
setlevel2 #s(client.planelevel),strtofloat(#s(client.planex)  ),strtofloat(#s(client.planey));



Another thing, client. variables are very insecure, people will be able to abuse this script to make it warp them to wherever they want on your server.
A string list may be better suited to your needs.

NPC Code:
setstring clientr.plane,<level>,<x>,<y>; // Set the level, x and y
replacestring clientr.plane,0,<newlevel>; // Want to replace just the level?
replacestring clientr.plane,1,<newx>; // Or just the x?
setlevel2 #I(clientr.plane,0),strtofloat(#I(clientr.plane,1) ),strtofloat(#I(clientr.plane,2)); // And warp the player

__________________
Skyld
Reply With Quote
  #8  
Old 10-14-2005, 09:08 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
like this? Because I'm having trouble getting this to work (other way was better, that warped me to the level, but not X+Y, this does nothing x_X)
NPC Code:
setlevel2 #I(clientr.plane,0),strtofloat(#I(clientr.plane,1)  ),strtofloat(#I(clientr.plane,2));
//#CLIENTSIDE
setstring clientr.plane,<#L>,<#v(playerx)>,<#v(playery)>;

Reply With Quote
  #9  
Old 10-14-2005, 08:48 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
ill switch to clientr. :/
Reply With Quote
  #10  
Old 10-14-2005, 09:12 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
You can't set clientr. strings clientside.
__________________
Skyld
Reply With Quote
  #11  
Old 10-14-2005, 09:14 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
i changed it to clientside, just for testing, but now it just says 'Failed' in the corner
Reply With Quote
  #12  
Old 10-14-2005, 09:15 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by excaliber7388
i changed it to clientside, just for testing, but now it just says 'Failed' in the corner
Sounds like a problem with the setlevel2. 'Failed' usually appears when a warp has, well, failed.

Still, you can not write to clientr. strings clientside. You'd have to play with this serverside.
__________________
Skyld
Reply With Quote
  #13  
Old 10-14-2005, 09:22 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
here's what I'm currently using (triggeraction under #CLIENTSIDE line)
NPC Code:
if (actionserverside) {
if (strequals(#p(0),fly)&&isonmap) {
setstring clientr.plane,#L,#v(playerx),#v(playery);
}
}
if (actionserverside) {
if (strequals(#p(0),warp)) {
setlevel2 #I(clientr.plane,0),strtofloat(#I(clientr.plane,1) ),strtofloat(#I(clientr.plane,2));
}
}

Reply With Quote
  #14  
Old 10-14-2005, 09:25 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
You should really put if(isonmap) before the triggeraction, helps filter out unnessesary lag.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #15  
Old 10-14-2005, 09:31 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
It is, but still wont warp ;(
Reply With Quote
  #16  
Old 10-14-2005, 09:50 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
I don't believe that isonmap works serverside.
__________________
Skyld
Reply With Quote
  #17  
Old 10-14-2005, 10:00 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Ha, it warps now, but it keeps the player inside, it detects the player's possition to late if isonmap worked serverside the script would work x_X
Reply With Quote
  #18  
Old 10-14-2005, 10:02 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by excaliber7388
Ha, it warps now, but it keeps the player inside, it detects the player's possition to late if isonmap worked serverside the script would work x_X
Well, you could always make constructive use of triggeractions to the clientside to check if the player is on a map.

Hell, if you're originating your triggeraction from the clientside, then just check it before you send the triggeraction.
__________________
Skyld
Reply With Quote
  #19  
Old 10-14-2005, 10:05 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
I did, somehow it checks too late X_X its not after a sleep command or a timeout
Reply With Quote
  #20  
Old 10-14-2005, 10:08 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by excaliber7388
I did, somehow it checks too late X_X its not after a sleep command or a timeout
NPC Code:
//#CLIENTSIDE
if (event) {
if (isonmap) // or if (!isonmap), whichever you need
{
triggeraction ...;
}
}


Something like that should be reasonable.
__________________
Skyld
Reply With Quote
  #21  
Old 10-14-2005, 10:14 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
yup, thats what I have, this bugs me
NPC Code:
if (timeout && this.inuse == 1 && isonmap) {
setani idle,;
disabledefmovement;
triggeraction 0,0,serverside,Plane,fly;//records current x,y, and level

more script;
}
if(timeou t&& this.inuse==1 && !isonmap){
triggeraction 0,0,serverside,Plane,warp;
}

Reply With Quote
  #22  
Old 10-14-2005, 10:17 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by excaliber7388
yup, thats what I have, this bugs me
NPC Code:
if (timeout && this.inuse == 1 && isonmap) {
setani idle,;
disabledefmovement;
triggeraction 0,0,serverside,Plane,fly;//records current x,y, and level

more script;
}
if(timeou t&& this.inuse==1 && !isonmap){
triggeraction 0,0,serverside,Plane,warp;
}

For one, you could condense both your timeout (and your timeou t) into one check.

Two, you only need to check this.inuse == 1 once.
NPC Code:
if (timeout)
{
if (this.inuse == 1)
{
if (isonmap)
{
setani idle,;
disabledefmovement;
triggeraction 0,0,serverside,Plane,fly; //records current x,y, and level

//more script;
}
else
{
triggeraction 0,0,serverside,Plane,warp;
}
}
}



Also, bear in mind that a timeout only occurs once unless you set it again.
__________________
Skyld
Reply With Quote
  #23  
Old 10-14-2005, 10:21 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
would this fix my problem?
Reply With Quote
  #24  
Old 10-14-2005, 10:25 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by excaliber7388
would this fix my problem?
I suggest you try it!
__________________
Skyld
Reply With Quote
  #25  
Old 10-14-2005, 10:25 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
XD k lol
Reply With Quote
  #26  
Old 10-14-2005, 10:28 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
Nope x_X
Reply With Quote
  #27  
Old 10-14-2005, 10:30 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Please edit your posts instead of double-posting.
There's a nice button on your recent posts that you can use to do so.

Also, I'd check the serverside portion of your script now. Is the action being received? Is it being handled effectively?
__________________
Skyld
Reply With Quote
  #28  
Old 10-14-2005, 10:37 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
It's warping the player, but it warps them to the point they came in at (inside)
Reply With Quote
  #29  
Old 10-14-2005, 10:41 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
I'd check that you're setting the clientr.plane flag at the correct times.

After all, your warp depends upon it.
__________________
Skyld
Reply With Quote
  #30  
Old 10-14-2005, 10:47 PM
excaliber7388 excaliber7388 is offline
Banned
excaliber7388's Avatar
Join Date: Jul 2005
Location: US
Posts: 5,229
excaliber7388 can only hope to improve
Send a message via AIM to excaliber7388
;( yeah. man this bites
Reply With Quote
  #31  
Old 10-14-2005, 11:07 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by excaliber7388
;( yeah. man this bites
Well, it only bites because you haven't solved the problem.

Think about it.
__________________
Skyld
Reply With Quote
  #32  
Old 10-14-2005, 11:08 PM
Knuckles Knuckles is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 580
Knuckles is on a distinguished road
Send a message via AIM to Knuckles
NPC Code:

for (i = 0; i < 4; i ++) {
if(keydown(i)) {
this.x += vecx(i);
this.y += vecy(i);
break;
}
}



instead of 900 lines of key detection...you can do the same for playerdir detection.
learn vectorx, vectory. think of it as an array.

vecx = {0,1,0,1}
vecy = {1,0,1,0}

so vecx(0) would = 0;
vecx(1) would = 1;
vecx(2) would = 0;
vecx(3) would = 1;
__________________
Knuckles
"They say 60% of the time, it works everytime!"

Last edited by Knuckles; 10-14-2005 at 11:45 PM..
Reply With Quote
  #33  
Old 10-14-2005, 11:44 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Knuckles
NPC Code:

for (i = 0; i < 4; i ++) {
if(keydown(i)) {
this.x += vecx(this.x);
this.y += vecy(this.y);
break;
}
}



instead of 900 lines of key detection...you can do the same for playerdir detection.
learn vectorx, vectory. think of it as an array.

vecx = {0,1,0,1}
vecy = {1,0,1,0}

so vecx(0) would = 0;
vecx(1) would = 1;
vecx(2) would = 0;
vecx(3) would = 1;
I think you mean vecx(i) and vecy(i), not vecx(this.x), vecy(this.y).
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #34  
Old 10-14-2005, 11:45 PM
Knuckles Knuckles is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 580
Knuckles is on a distinguished road
Send a message via AIM to Knuckles
yes. my mistake.
__________________
Knuckles
"They say 60% of the time, it works everytime!"
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 12:16 AM.


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