Author Topic: Toggle mode script giving errors  (Read 2335 times)

That's one way of doing it, yes.  But if you wanted to set some variables / perform other actions at the same time as the image unmount, I'd do it like this:

Code: [Select]
schedule(50,0,"performUnmount",%image,%player,%slot);
Code: [Select]
function performUnmount(%image,%player,%slot)
{
     %player.unmountImage(%image,%player,%slot);
     //perform other actions / set variables here
}

Btw, we can always refer to them as subroutines.

Even better way to do the whole don't mount if not admin thing would be to return and not perform the parent function if the client isn't admin.

Code: [Select]
function serverCmdtoggleStarMode(%client) {
if(!%client.smode){
%client.smode = true;
messageAll('', '\c3Star Gun is in \c0Destroy Mode');
} else {
%client.smode = false;
messageAll('', '\c3Star Gun is in \c0Normal Mode');
}
}

function starGunProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal) {
if(%col.getClassName() $= "fxDTSBrick" && %obj.client.smode) %col.killBrick();
else Parent::onCollision(%this, %obj, %col, %fade, %pos, %normal);
}

function starGunImage::onMount(%this, %obj) {
%client = %obj.client;
if(!%client.isAdmin || !%client.isSuperAdmin) return "";
else Parent::onMount(%this, %obj);
}

function serverCmdstarGun(%client) {
if(%client.isAdmin || %client.isSuperAdmin) {
%client.player.mountImage("starGunImage", 0);
%client.player.playThread(0, armreadyright);
}
}