![]() |
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". |
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
|
Re: I need some help with this...
Quote:
Quote:
|
That didn't help, it even stopped the script from working :o
|
Nobody else spotted this?
NPC Code: 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: |
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 |
Re: I need some help with this...
Quote:
|
Re: Re: I need some help with this...
Quote:
|
I followed the aid of Growlz and... succeeded! :)
|
Re: Re: I need some help with this...
Quote:
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! |
Re: Re: Re: I need some help with this...
Quote:
|
Re: Re: Re: I need some help with this...
Quote:
|
Re: Re: Re: Re: I need some help with this...
Quote:
|
Re: Re: Re: Re: Re: Re: I need some help with this...
Quote:
|
if (created) variable=5*5;
evaluation? |
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 |
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
|
Quote:
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. |
Re: I need some help with this...
Quote:
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? |
Quote:
"5*5" evaluation if im not mistaken "something = something else" assignment command. |
It has to evaluate it before it can execute the command... thats my logic behind it
|
I just think it would still have to evaluate it first...
|
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. |
Quote:
And none of you cought the serious problem I did and posted. |
Re: Re: I need some help with this...
Quote:
|
Arguing about it is only going to drive the thread further off-topic...
|
I feel that someone or plural persons have not read this thread carefully, as i posted that if succeeded, thanks to Growlz.
|
They were just bickering... seemed to be stopped until you posted though ;(
It's all your fault! |
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.