|
Ok. Also, I am having trouble with this.variables. In my person, this is his code:
// Graal2001 NPC by Stefan Knorr
if (created) {
// Initialize the attributes
showcharacter;
setcharprop #3,head0.gif;
setcharprop #C0,orange;
setcharprop #C1,white;
setcharprop #C2,blue;
setcharprop #C3,red;
setcharprop #C4,black;
setcharprop #n,Bug Collector;
setcharprop #2,shield1.gif;
shieldpower = 1;
dir = 2;
x+=0.5;
setcharani sit,;
}
if (playerchats && strequals(#c,sell bugs)) {
this.BugRemainderCount=client.BugCount%10; //How much bugs are left if uneven amount
this.BugGive=client.BugCount-this.BugRemainderCount;
this.BugMoney=int(this.BugGive/10); //How much bugs to give
this.BugLeft=10-client.BugCount; //How many bugs are left until jar full
if (client.BugCount>0) { //If has more than 1 bug
if (client.BugCount>=10) { //If has enough to get money
playerrupees+=this.BugMoney; //Give money
say2
You gave me #v(this.BugGive) bugs.#b
You still have #v(this.BugRemainderCount) bugs left.;
} else { //Else not enough to give money
say2
You only have #v(client.BugCount) bugs!#b
You still need #v(this.BugLeft) more bugs!;
}
} else {
say2
You don't have any bugs!;
}
}
if (playertouchsme) {
say2
Hi! I am collecting bugs. If#b
you catch any bugs, will you#b
sell them to me? I will pay#b
you 1 Gralat for every 10 bugs#b
you give me. Bees are special.#b
If you capture a bee, it will#b
count towards 2 bugs! I will#b
also sell you some supplies#b
to catch bugs. Just say,#b
"buy" then the itemname.;
}
In this script, the this.variables don't work right. The weird thing is, they don't even work in offline mode... I catch a bug, and it sets client.BugCount to 1. Notice this portion:
You only have #v(client.BugCount) bugs!#b
You still need #v(this.BugLeft) more bugs!;
this.BugLeft is set by:
this.BugLeft=10-client.BugCount;
In the debugger, this.BugLeft is equal to 9. But, in the textbox, it says:
You only have 1 bugs!
You still need 0 more bugs!
It should read:
You still need 9 more bugs!
Can you guys please explain to me what I am doing wrong? this.BugLeft is 9 in the debugger, but it display's zero in the sign... |