Author Topic: Scripting  (Read 1230 times)

Hey so im working on this script where you can disable some emotes for everybody on the server this is what i have so far:  
Code: [Select]
//Lights

 function serverCmdLight(%client)
 {
       if(%client.isAdmin)
       {
             if(%client.isLightPlayer)
             {
                   %client.isLightPlayer = 0;
                   messageClient(%client,'',"\c3Light is now\c6OFF");
                  
                   %client.updateLight();
      
             }
             eles
             {
                   %client.isLightPlayer = 1;
                   %client.oldLight = %client.light;
                   %client.light = "°";
                   messageClient(%client,''<"\c3 Light is now\c6ON");
 
                   %client.updateLight();
             }
        }
 }

you mispelt else, if that helps, in line 15

That doesn't look like "everybody" so much as it looks like "non-admins."
Unless you're trying to make it so admins can toggle it on and off, in which case you should be making a new function for the toggle. Either way, you'll need to utilize the package system.

Code: [Select]
package adminOnlyLight {
function serverCmdLight(%client) {
if(%client.isAdmin)
Parent::serverCmdLight(%client);
}
};
activatePackage(adminOnlyLight);

Majorly reduces code. Only thing is it doesn't tell you if the light is on or off...

Isn't there already a defult /light command.


you mispelt else, if that helps, in line 15
i know but it still works lol


Isn't there already a defult /light command.
Yes but this is to disable lights or enable all lights in the server

Yes but this is to disable lights or enable all lights in the server

What?


What?
if they are disabled then nobody can use their personal lights same with enabled but they can

...

Is true!!

Start a sev, the type /light, it turns on your light.

also, for the emotes, it's things like /alarm, /confusion or /confused, /love, /hate, /hug, and i think i might be forgetting one, /sit too if you want (to disable the sit and crouch glitch?)

Is true!!

Start a sev, the type /light, it turns on your light.
he's trying to disable it, i think he knows of that

Code: [Select]
package adminOnlyLight {
function serverCmdLight(%client) {
if(!$lightsOFF)
Parent::serverCmdLight(%client);
}
};
activatePackage(adminOnlyLight);

function serverCmdToggleLight(%client) {
if(%client.isAdmin) {
switch($lightsOFF) {
case 1:
$lightsOFF = 0;
messageAll(%client, '', "\c3Player Lights are now\c6ON\c3.");
default:
for(%c = 0; %c < ClientGroup.getCount(); %c++)
if(isObject((%client = ClientGroup.getObject(%c)).player.light))
serverCmdLight(%client);
$lightsOFF = 1;
messageAll(%client, '', "\c3Player Lights are now\c6OFF\c3.");
}
}
else
messageClient(%client, '', "\c3Admin Only.");
}
« Last Edit: November 17, 2010, 01:21:42 AM by MegaScientifical »