Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Little Problem! (https://forums.graalonline.com/forums/showthread.php?t=29603)

Spark910 05-21-2002 03:34 AM

Little Problem!
 
NPC Code:
if (playertouchsme&&strequals(#s(eventtoken)&&strtofl  oat(#s(eventtoken)>=strtofloat(1)){
setlevel2 level2.graal,30,30;
}
else
if (Playertouchsme) {
say2 #bTokens needed;
}



The idea is, if you have more than ONE eventtoken then it warps you! Its on NONE NPC Server, anyone know prob?

flagitsets (Of Course) is:
eventtoken=xx *xx=Number!

ive tried a few thanks but none seem to work, I am none the wiser, anyone can help?

-Spark911

screen_name 05-21-2002 06:02 AM

Re: Little Problem!
 
NPC Code:

if (playertouchsme&&strequals(#s(eventtoken)&&strtofloat(#s(eventtoken)>=strtofloat(1)){
setlevel2 level2.graal,30,30;
} elseif (playertouchsme) {
say2 #bTokens needed;
}



first bold - no end part of srequals
second bold - forgot the ending ) around strtofloat

mikepg 05-21-2002 06:38 AM

if statement should look like this:














if (playertouchsme&&strtofloat(#s(eventtoken))>=1) {
stuff here;
}
else if (playertouchsme) stuff here;

Despo1 05-21-2002 08:04 AM

NPC Code:

if(playertouchsme){
this.testvar = strtofloat(#s(eventtoken));
if(this.testvar > 0)
setlevel2 level2.graal,30,30;
else
say2
#b
Tokens needed;
}


Saga2001 05-21-2002 10:46 PM

I wouldn't have either. Also a note to screen name, its else if not elseif, though I am not sure it matters...
Also you should try to only test something once in a script, unless you have statements where you test if its not true and playertouchsme and you test if it is true and playertouchs me, otherwise both or one probably not the one you want will be executed.
For example:
NPC Code:

// way one:
if (playertouchsme && thisistrue) unset thisistrue;
if (playertouchsme && !thisistrue) set thisistrue;
sleep .05;
// way two:
if (playertouchsme) {
if (thisistrue) unset thisistrue;
else set thisistrue;
sleep .05;
}
// way three:
if (playertouchsme) {
if (thisistrue) unset thisistrue;
if (!thisistrue) set thisistrue;
sleep .05;
}
// way four and the most complicated way:
if (created)
setstring this.displays,"Hello Message A","Hello Message B";
if (playertouchsme) {
this.disp = (thisistrue ? 1 : 0);
showMessage();
sleep .05;
}
function showMessage()
say2 #I(this.displays, this.disp);



See there are many sides of one coin.

Spark910 05-22-2002 12:34 AM

Thankyou People!

BBflat 05-23-2002 08:08 PM

Quote:

Originally posted by Kaimetsu
This is part of the reason why people should NEST IF STATEMENTS MORE.
=)


All times are GMT +2. The time now is 05:29 PM.

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