Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   I need some help with this... (https://forums.graalonline.com/forums/showthread.php?t=44181)

GoZelda 04-11-2003 05:40 PM

I need some help with this...
 
I'm having some problems with the following script, i don't see what's wrong, please help me...

// NPC made by Cyrin
setimg beer.png
if (playertouchsme) toweapons Dagger;
if (weaponfired) {
if (strequals(#s(client.equipment),fists)){
setstring client.equipment,dagger;
setplayerprop #c,Equipped Dagger;
setstring client.weaponpower,2;}
if (strequals(#s(client.equipment),dagger)){
setstring client.equipment,fists;
setplayerprop #c,Unequipped Dagger;
setstring client.weaponpower,1;}}

The beer stuff isn't in th original script >.>
And you also need to set a flag "client.equipment=fists".

Dach 04-11-2003 08:13 PM

you don't need those "#s()"s around the string, I don't remember if that'll kill the script or not, but don't use them there

CheeToS2 04-11-2003 08:56 PM

Re: I need some help with this...
 
Quote:

Originally posted by GoZelda
setimg beer.png

missing a ;

Quote:

Originally posted by Dach
you don't need those "#s()"s around the string, I don't remember if that'll kill the script or not, but don't use them there
yes you do :x (last time I checked at least)

GoZelda 04-11-2003 09:37 PM

That didn't help, it even stopped the script from working :o

GrowlZ1010 04-11-2003 10:04 PM

Nobody else spotted this?

NPC Code:

if (weaponfired) {
if (strequals(#s(client.equipment),fists)){
setstring client.equipment,dagger;
setplayerprop #c,Equipped Dagger;
setstring client.weaponpower,2;
}
// Hey, look! client.equipment, at this point, equals dagger!
if (strequals(#s(client.equipment),dagger)){
// So let's get rid of the dagger and bring the fists back,
// despite the fact that we've just got rid of the fists!
setstring client.equipment,fists;
setplayerprop #c,Unequipped Dagger;
setstring client.weaponpower,1;
}
}



Use some kind of small modification like this to check whether or not the equipment has already been changed. Oh, and have the default weapon set automatically.
NPC Code:

if (weaponfired) {
this.check=0;
if (strequals(#s(client.equipment),fists)){
this.check=1;
// dagger equip stuff..
}
if (strequals(#s(client.equipment),dagger) && this.check=0){
// fist equip stuff..
}
if (strequals(#s(client.equipment),)){
// default weapon setting stuff..
}
}


Projectshifter 04-12-2003 09:57 AM

OMG, other than the two obvious facts:
(1) You didn't even put if (created). That is like a BIG no-no to put just setimg like that x-x
(2) It's a flat out bish to read, you didnt' really use any formatting! x-x

But other than that, I thought it would be obvious. If you tell it if you are using fists, then it switches to a dagger, but then directly underneath it checks it to switch a dagger to a fist. It changes it to a dagger, but then right back. There is a little thing known as return; that is very helpful x-x
---Shifter

Dude6252000 04-12-2003 04:21 PM

Re: I need some help with this...
 
Quote:

Originally posted by GoZelda
// NPC made by Cyrin
setimg beer.png
if (playertouchsme) toweapons Dagger;
if (weaponfired) {
if (strequals(#s(client.equipment),fists)){
setstring client.equipment,dagger;
setplayerprop #c,Equipped Dagger;
setstring client.weaponpower,2;}
if (strequals(#s(client.equipment),dagger)){
setstring client.equipment,fists;
setplayerprop #c,Unequipped Dagger;
setstring client.weaponpower,1;}}

if (playertouchsme) { toweapons Dagger; }

Ningnong 04-12-2003 05:29 PM

Re: Re: I need some help with this...
 
Quote:

Originally posted by Dude6252000

if (playertouchsme) { toweapons Dagger; }

You don't need brackets for a single command.

GoZelda 04-12-2003 06:19 PM

I followed the aid of Growlz and... succeeded! :)

Dach 04-13-2003 01:57 AM

Re: Re: I need some help with this...
 
Quote:

Originally posted by CheeToS2

yes you do :x (last time I checked at least)

HOLY CRAP!!
I just realized I have not once had to check my own strings in any script I have ever made!!! Gyayayaya, and to think I've scripted for almost 3 years now!

CheeToS2 04-13-2003 02:12 AM

Re: Re: Re: I need some help with this...
 
Quote:

Originally posted by Dach


HOLY CRAP!!
I just realized I have not once had to check my own strings in any script I have ever made!!! Gyayayaya, and to think I've scripted for almost 3 years now!

maybe its time you did.. doesn't work without the #s

Dude6252000 04-13-2003 02:16 AM

Re: Re: Re: I need some help with this...
 
Quote:

Originally posted by Ningnong


You don't need brackets for a single command.

Er, oh. This is what I get for trying to correct people, when I can barely script myself :(

CheeToS2 04-13-2003 02:18 AM

Re: Re: Re: Re: I need some help with this...
 
Quote:

Originally posted by Dude6252000

Er, oh. This is what I get for trying to correct people, when I can barely script myself :(

It doesn't hurt to have them, & putting brackets around stuff (not sure if this holds true in gscript or not) speeds up processing of the script (barely, but still :P)

CheeToS2 04-13-2003 02:36 AM

Re: Re: Re: Re: Re: Re: I need some help with this...
 
Quote:

Originally posted by Kaimetsu
I don't see why it would speed up the compilation?
its easier for it to determine what is being typed is (a command/evaluation/etc).. again, i'm not saying it holds true for gscript, because I wouldn't know :P

HoudiniMan 04-13-2003 08:30 AM

if (created) variable=5*5;

evaluation?


All times are GMT +2. The time now is 09:47 AM.

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