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?

Projectshifter 04-13-2003 10:09 AM

Even if it IS a single command, if you add components as a method of building your scripts then you should put 99.9997% of single commands in brackets { and }. It means when you edit the script and add and test things you don't have to add them in. And actually it SLOWS the compilation process, if you can even call it that. You're talknig perhaps 10 nano's at best :P It's just like a text file (it is basically), where each space and return and } and { and such take up more space to store. But the amount doesn't matter when it's so trivial as that. A friend asked me to look at ascript of his that took up 15% CPU usage. I changed a few things to the way I format, and VOILA< it was 2% (still a lot but 2 > 15 when you're talking lag ;))
---Shifter

Pokilty 04-17-2003 04:31 AM

Kai is right... when the script is compiled it isn't fed into the engine exactly how you write it. It has to go through a process to determine how the script works and adding a { } wouldn't make it any faster. It doesn't take any more work for the compiler to recognize that whatever comes after the if statement is what the user wants to happen versus whatever is in the brackets is what the user wants to happen. To the computer it's all good :D

GoZelda 04-24-2003 11:22 AM

Quote:

Originally posted by Kaimetsu

You're either lying or drastically mistaken. A simple change of formatting will never account for such a drastic change, especially since all formatting is removed when the script is converted into bytecode.

Kaimetsu, wasn't something alike in your KSI-thing?
i mean if he typed all the time
if (playertouchsme){
if (strequals(#s(client.lives),true)){
say2 hey you live!;
}
}
if (playertouchsme){
if (strequals(#s(client.lives),false)){
say2 hey you are dead!;
}
}
and so on, instead of
if (playertouchsme){
if (strequals(#s(client.lives),false)){
say2 hey you are dead!l
}
if (strequals(#s(client.lives),true)){
say2 hey you live!;
}
and there could be much more things ya know.
You can easily make stuff easiers, shorter etc. by compiling.

adam 04-24-2003 04:51 PM

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

Originally posted by GoZelda
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){
// wont' work online, but fine for offline
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 the script worked it would always be set client.equipment=fists

becouse you change it to dagger then the next if statement checks if it's dagger and changes it back to fists.

You might try an elseif statement.

To busy arguing to catch that guys?

adam 04-24-2003 04:53 PM

Quote:

Originally posted by HoudiniMan
if (created) variable=5*5;

evaluation?


"5*5" evaluation if im not mistaken


"something = something else" assignment command.

HoudiniMan 04-25-2003 01:33 AM

It has to evaluate it before it can execute the command... thats my logic behind it

HoudiniMan 04-25-2003 09:22 AM

I just think it would still have to evaluate it first...

adam 04-25-2003 04:10 PM

And now the answer to the guys question is lost in the shuffle.

Now to get the mod to delete irrelevent posts. Like his own.

adam 04-25-2003 04:27 PM

Quote:

Originally posted by Kaimetsu


The thread has been alive for over two weeks. If he hasn't come to get his answer by now then he never will.

Don't be silly he checked back yesterday. You replied to him.

And none of you cought the serious problem I did and posted.

adam 04-25-2003 04:29 PM

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

Originally posted by adam



If the script worked it would always be set client.equipment=fists

becouse you change it to dagger then the next if statement checks if it's dagger and changes it back to fists.

You might try an elseif statement.

Bump the truth down to a place where it can be easily read....

HoudiniMan 04-25-2003 07:00 PM

Arguing about it is only going to drive the thread further off-topic...

GoZelda 04-27-2003 06:00 PM

I feel that someone or plural persons have not read this thread carefully, as i posted that if succeeded, thanks to Growlz.

HoudiniMan 04-27-2003 09:46 PM

They were just bickering... seemed to be stopped until you posted though ;(

It's all your fault!

GoZelda 04-30-2003 08:42 PM

Your fault!
Don't know why though ;P


All times are GMT +2. The time now is 01:33 PM.

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