POL 096, Help with a custom script.

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

POL 096, Help with a custom script.

Post by Poi »

Ok, so I'm having some difficulties.


I have two edits....ish..

I have a bankstone and I am trying to make it so I can set the owner, and only he or a staff member can open that bank stone, while if there is no owner set, anyone can open the bankstone...

Here are my two scripts...

setowner.src: Needs to set a property on the bank with the same value as the owners name.

Code: Select all

use uo;

program textcmd_setowner( who, text )
SendSysMessage( who, "Target the bank stone" );
var bankstone := TargetCoordinates( who );
  SendSysMessage( who, "Target the new owner" );
  var newowner := TargetCoordinates( who );
SetObjProperty(bankstone, "owner", newowner.name); 
SendSysMessage( who, "New owner set!" );
endprogram
bankstone.src: needs to look for an owner, if it has one, block everyone else's access except the owner and staff. If it doesn't allow everyone access

Code: Select all

var owner := GetObjProperty(item, "owner");

if (owner && owner != who.name && who.cmdlevel < 2 )
SendSysMessage( who, "This is not your bankstone!" );
return;
endif
That is at the beginning of the function, if someone can get past this they can open the bank, if they can't it tells them This is not your bankstone! and ends the script...

My problem is that at the moment everyone can open it, weather it has an owner set or not..

Any issues that are obvious?
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

Yes very obvious. Use Target, not TargetCoordinates. You're using TargetCorrdinates and getting a coordinate return instead of a mobile object.

Also as a suggestion, use owner.serial instead of owner.name. This avoids any possible future conflicts.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Awesome, thanks :)
Post Reply