Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Server (https://forums.graalonline.com/forums/forumdisplay.php?f=14)
-   -   Script Question (https://forums.graalonline.com/forums/showthread.php?t=6659)

RawPower 07-06-2001 07:52 AM

Script Question
 
Ok since Faheria is set in more of a modern day civilization, we are replacing the horses with cars that you can buy that last forever til you have to refill the fuel at a gas station. Anyways I dont think the NPC Server is supporting it, perhaps there is something wrong with this script that is not making it work online? Please help, thanks.


NPC Code:
if (created) {
message Car Key;
}
if (playertouchsme) {
toweapons Car Key;
setstring carfuel,100;
}
function HitCheck() {
for (this.p=1; this.p<playerscount; this.p++) {
if (abs((this.px)-(players[this.p].x+1.5))<=1 &&
abs((this.py)-(players[this.p].y+1.5))<=1.5){
hitplayer this.p,2,this.px,this.py;
}
}
}
if (weaponfired) {
disabledefmovement;
this.key4=0;
playerdir=2;
if (car1) {
setani INVsportscarin,;
}
if (suv1) {
setani INVsuvin,;
}
sleep .8;
this.fuel=strtofloat(#s(carfuel));
set caron;
timeout=.05;
}
if (caron) {
if (timeout) {
if (this.fuel>100) {
this.fuel=100;
}
this.key0=1;
this.key1=1;
this.key2=1;
this.key3=1;
if (car1) {
setani INVsportscar,;
}
if (suv1) {
setani INVsuv,;
}
if (this.skate=1.5) {
if (playerdir=0) {
this.px=playerx+1.5;
this.py=playery-2;
}
if (playerdir=1) {
this.px=playerx-2;
this.py=playery+1.5;
}
if (playerdir=2) {
this.px=playerx+1.5;
this.py=playery+5;
}
if (playerdir=3) {
this.px=playerx+5;
this.py=playery+1.5;
}
}
if (keydown(0)||keydown(1)||keydown(2)||keydown(3)) {
if (this.fueltime=0) {
this.fuel-=.05;
this.fueltime=8;
}
this.fueltime-=1;
if (this.skate<1.5) {
this.skate+=.05;
}
if (keydown(0)) {
if (onwall(playerx+1,playery-.5)||
onwall(playerx+2,playery-1.1)) {
this.key0=0;
}
}
if (keydown(2)) {
if (onwall(playerx+1,playery+3.5)||
onwall(playerx+2,playery+4.1)) {
this.key2=0;
}
}
if (keydown(1)) {
if (onwall(playerx-.5,playery+1)||
onwall(playerx-1.1,playery+2)) {
this.key1=0;
}
}
if (keydown(3)) {
if (onwall(playerx+3.5,playery+1)||
onwall(playerx+4.1,playery+2)) {
this.key3=0;
}
}
if (keydown(0)) {
if (this.key0=1) {
playery-=this.skate;
}
playerdir=0;
}
if (keydown(1)) {
if (this.key1=1) {
playerx-=this.skate;
}
playerdir=1;
}
if (keydown(2)) {
if (this.key2=1) {
playery+=this.skate;
}
playerdir=2;
}
if (keydown(3)) {
if (this.key3=1) {
playerx+=this.skate;
}
playerdir=3;
}
}
if (!keydown(0)&&!keydown(1)&&!keydown(2)&&!keydown(3 )) {
if (this.skate>0) {
this.skate-=.05;
}
if (playerdir=0) {
if (onwall(playerx+1,playery-.6)||
onwall(playerx+2,playery-1.1)) {
this.skate=0;
}
playery-=this.skate;
}
if (playerdir=1) {
if (onwall(playerx-.5,playery+1)||
onwall(playerx-1.1,playery+2)) {
this.skate=0;
}
playerx-=this.skate;
}
if (playerdir=2) {
if (onwall(playerx+1,playery+3.5)||
onwall(playerx+2,playery+4.1)) {
this.skate=0;
}
playery+=this.skate;
}
if (playerdir=3) {
if (onwall(playerx+3.5,playery+1)||
onwall(playerx+4.1,playery+2)) {
this.skate=0;
}
playerx+=this.skate;
}
}
HitCheck();
setstring carfuel,#v(this.fuel);
this.fuel=strtofloat(#s(carfuel));
showimg 555,sysfuel.gif,15,160;
showimg 556,carfuel.gif,17,170;
showimg 554,speedometer.gif,15+(this.skate*66),200;
changeimgpart 556,0,0,this.fuel+1,7;
changeimgvis 555,4;
changeimgvis 556,4;
changeimgvis 554,4;
if (this.fuel<=0) {
TurnOff();
}
if (playerhearts=0) {
TurnOff();
}
if (keydown(4)&&this.key4=1) {
TurnOff();
}
if (keydown(5)&&this.skate>.05) {
this.skate-=.1;
}
if (this.key4=0) {
this.key4wait+=.05;
if (this.key4wait=1) {
this.key4=1;
this.key4wait=0;
}
}
timeout=.05;
}
}

function TurnOff () {
hideimg 555;
hideimg 556;
hideimg 554;
playerdir=2;
if (car1) {
setani INVsportscarout,;
}
if (suv1) {
setani INVsuvout,;
}
unset caron;
freezeplayer .8;
enabledefmovement;
}



Yes I know it doesnt use arrays =\ but this is mainly a beta its just testing the movement and such.

Er1c 07-06-2001 08:46 AM

Use the "
NPC Code:
" and "

tags, cant see whats wrong when its all messed up.

Er1c 07-06-2001 08:47 AM

Ok, quotes didn't work... use the [ code ] and [/ code ] tags without the spaces.

Torankusu 07-06-2001 10:30 AM

NPC Code:
 if (strequals(#a,Torankusu)) {set leet;} 


grim_squeaker_x 07-06-2001 03:04 PM

I don't see a setshape 1,width,height; command in that script, and since it's on the NPC Server you'll need that.

RawPower 07-07-2001 04:28 AM

yes toweapons works, just playertouchsme sucks on npc server. Setshape doesnt matter with this script its just not working for some reason =\

Er1c 07-07-2001 04:53 AM

Quote:

Originally posted by Kaimetsu
But is it a database NPC? And, does toweapons even work on the NPC Server? Either way, addweapons would be preferable.
Thats not the kind of thing you use addweapon with... addweapon adds a weapon thats already in the weapons database, which got there from a separate NPC that used toweapons.

Brady2 07-07-2001 12:38 PM

I do not remember if it matters or not
but put == instead of = to check values

if (this.key0==1) ;

Brady2 07-07-2001 01:32 PM

-Posted by Jadis

Don't keydowns have to be under //#CLIENTSIDE ?

grim_squeaker_x 07-07-2001 03:46 PM

Quote:

Originally posted by Brady2
-Posted by Jadis

Don't keydowns have to be under //#CLIENTSIDE ?

It's a weapon, weapons are always clientside.

RawPower 07-07-2001 10:19 PM

This weapon works fine offline....Im trying to figure out why it dont work online. I've tried putting //#CLIENTSIDE and it said the server got illegal data from my connection and disconnected me =\

BocoC 07-08-2001 02:52 AM

That is because toweapons MUST be server side.

kyle0654 07-08-2001 04:08 AM

NPC Code:

setstring carfuel,#v(this.fuel);
set caron;


try
NPC Code:
setstring client.carfuel,#v(this.fuel);


and instead of set caron;, try:
NPC Code:
this.caron = true;


(do this.caron=false when you're done, and check with this.caron==true to see if it's on)

You can only set client.strings and flags from a clientside script, and I think a variable would do better for a temporary thing anyway (this.caron)

also, yah, these are all wrong:
NPC Code:

if (playerdir=0) {


they need to be
NPC Code:

if (playerdir==0) {



All times are GMT +2. The time now is 11:20 PM.

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