Graal Forums

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

excaliber7388 10-14-2005 08:08 PM

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
}



ApothiX 10-14-2005 08:28 PM

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.

excaliber7388 10-14-2005 08:33 PM

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

ApothiX 10-14-2005 08:35 PM

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?

excaliber7388 10-14-2005 08:37 PM

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?

ApothiX 10-14-2005 08:46 PM

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.

excaliber7388 10-14-2005 08:48 PM

ill switch to clientr. :/

Skyld 10-14-2005 08:55 PM

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


excaliber7388 10-14-2005 09:08 PM

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


Skyld 10-14-2005 09:12 PM

You can't set clientr. strings clientside.

excaliber7388 10-14-2005 09:14 PM

i changed it to clientside, just for testing, but now it just says 'Failed' in the corner

Skyld 10-14-2005 09:15 PM

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.

excaliber7388 10-14-2005 09:22 PM

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


ApothiX 10-14-2005 09:25 PM

You should really put if(isonmap) before the triggeraction, helps filter out unnessesary lag.

excaliber7388 10-14-2005 09:31 PM

It is, but still wont warp ;(


All times are GMT +2. The time now is 03:34 PM.

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