Quote:
Originally Posted by cbk1994
You don't need any clientside code here, just use onActionDoubleMouse, which is sent by the client without you doing anything.
What if my account was "Stef"? I could lock gralats in Stefan's house.
Once again, stop using 0 and 1 as booleans. Use true and false instead. It's much clearer for anyone reading the code.
I'm almost certain that setshape should have '1' as its first parameter (at least according to the wiki—but I've never seen it used any other way).
Where is onUpdateGani being triggered from?
Indent code properly and use whitespace consistently. It's unacceptable not to.
|
That's alot, But I will fix it up and re post later.
and why use true or false? 0 and 1 are true and false in binary..
I was in the middle of editing it and it popped up that I can only edit it 1440 minutes after it was created, so here is the new code.
PHP Code:
function onCreated() {
this.setshape(0, 32, 32);
dontblock();
showcharacter();
updategani();
}
function onUpdategani() {
updategani();
}
function updategani() {
temp.type = 1;
if (rupees >= 100) temp.type = 4;
else if (rupees >= 30) temp.type = 3;
else if (rupees >= 5) temp.type = 2;
setcharani("gralats", temp.type);
}
function onPlayerTouchsMe() {
if (this.locked == 0) {
player.rupees += rupees;
rupees = 0;
destroy();
} else {
this.chat = "(Locked)";
sleep(2);
this.chat = "";
}
}
function onActionLeftMouse() {
if (this.locked == true) {
this.chat = rupees @ " (Locked)";
sleep(2);
this.chat = "";
} else {
this.chat = rupees;
sleep(2);
this.chat = "";
}
}
function onActionDoubleMouse() {
temp.lname = player.level.name.substring(6);
temp.lname = lname.substring(0, lname.pos(".nw").trim());
//had to use it twice, I tried player.level.name.substring(6, lname.pos(".nw").trim()); with no luck.
if (player.account == lname) {
this.locked = !this.locked;
if (this.locked == true) {
this.chat = "Locked!";
sleep(2);
this.chat = "";
} else {
this.chat = "Unlocked!";
sleep(2);
this.chat = "";
}
}
}