Maybe its something like this
if (created) {
this.open = false;
setimg housecrystal.png;
setshape 1,48,64;
}
if (initialized) {
this.mode = 0;
}
if (playerenters) {
if (strequals(#s(this.owner0),))
this.open = true;
checkisowner();
if (isowner==false && this.open==false)
warpplayerout();
else {
if (this.mode==0) {
message Welcome!;
sleep 3;
message;
}
}
}
if (playertouchsme) {
say2#
Hello!#b
If you are the owner of this#b
house then use these commands:#b
give key <enter> account name#b
take key <enter> account name#b
list owners#b
open door#b
close door#b
Max #v(this.maxowners) players can have the key;
}
if (playerchats && !strequals(#c,)) {
if (strequals(#s(this.owner0),#a)) {
if (this.mode==0) {
if (strequals(#c,give key)) {
getfreeslot();
if (freeslot>=0) {
this.mode = 1;
this.request = 0;
message Giving key: Tell me the account name of the player!;
} else {
say2
There is no free key anymore!#b
Max #v(this.maxowners) keys can#b
be given.;
}
}
if (strequals(#c,take key)) {
this.mode = 1;
this.request = 1;
message Taking key: Tell me the account name of the player!;
timeout = 0;
}
if (strequals(#c,open door)) {
this.open = true;
message Door is open!;
sleep 3;
message;
}
if (strequals(#c,close door)) {
this.open = false;
warpallplayersout();
message Door is closed!;
sleep 3;
message;
}
} else if (this.mode==1) {
this.mode = 0;
if (this.request==0) {
setstring this.checkacc,#c;
getslot();
if (slot>=0) {
message That player already has a key!;
sleep 3;
message;
} else {
getfreeslot();
if (freeslot>=0) {
setstring this.owner#v(freeslot),#c;
message Player #s(this.owner#v(freeslot)) got the key!;
sleep 3;
message;
}
}
} else if (this.request==1) {
setstring this.checkacc,#c;
getslot();
if (slot==0)
message The key for the owner can only be removed from an NPC
Admin.;
else if (slot>=1) {
if (this.open==false) with (getplayer(#s(this.checkacc))) {
if (strequals(#F,#L))
warpplayerout();
}
setstring this.owner#v(slot),;
message Key was taken away;
} else
message That player has no key for this house!;
sleep 3;
message;
}
}
}
if (this.mode==0) {
if (strequals(#c,list owners)) {
listowners();
message Owners: #s(this.ownerlist);
sleep 5;
message;
}
}
}
function checkisowner() {
isowner = false;
for (i=0; i<this.maxowners; i++)
if (strequals(#s(this.owner#v(i)),#a)) {
isowner = true;
break;
}
if (strequals(#g,Coder))
isowner = true;
}
function getfreeslot() {
freeslot = -1;
for (i=0; i<this.maxowners; i++)
if (strequals(#s(this.owner#v(i)),)) {
freeslot = i;
break;
}
}
function getslot() {
slot = -1;
for (i = 0; i<this.maxowners; i++)
if (strequals(#s(this.owner#v(i)),#s(this.checkacc))) {
slot = i;
break;
}
}
function listowners() {
setstring this.ownerlist,#s(this.owner0);
for ( i = 1 ; i<this.maxowners ; i++ ) {
if (!strequals(#s(this.owner#v(i)),))
setstring this.ownerlist,#s(this.ownerlist) + #s(this.owner#v(i));
}
}
function warpplayerout() {
setlevel2 #s(this.outlevel),this.outx,this.outy;
}
function warpallplayersout() {
for (j=0; j<playerscount; j++) {
with (players[j]) {
checkisowner();
if (isowner==false)
warpplayerout();
}
}
}