weapon_control:
PHP Code:
function onCreated()
{
this.helper = "weapon2"; // weapon2, changes alpha on clientside
this.db = "boolean"; // define npc to store exceptions
}
function onActionServerSide(temp.cmd, temp.alpha, temp.user)
{
if(temp.cmd == "set")
{
for(temp.pl : players)
{
if(temp.pl == player)
continue;
temp.pl.addWeapon(this.helper);
temp.exists = !(temp.pl.account in ( @ this.db ).exceptions);
temp.pl.triggerClient("gui", this.helper, player.account, temp.exists ? temp.alpha : temp.alpha == 0 ? 0.5 : 1);
}
}
if(temp.cmd == "add" || temp.cmd == "remove")
{
temp.exists = temp.user in ( @ this.db ).exceptions;
if(temp.user == NULL || !temp.exists && temp.cmd == "remove" || temp.exists && temp.cmd == "add" || temp.user == player.account)
{
player.chat = "Error!";
return;
}
if(temp.cmd == "add")
( @ this.db ).exceptions.add(temp.user);
else
( @ this.db ).exceptions.remove(temp.user);
player.chat = temp.user @ " was " @ ( temp.cmd == "add" ? "added" : "removed" ) @ "!";
}
if(temp.cmd == "view")
{
for(temp.pla : ( @ this.db ).exceptions)
{
temp.total = @ temp.total @ ( temp.total != NULL ? ", " : "" ) @ temp.pla;
}
if(temp.total != NULL)
player.chat = temp.total;
}
}
//#CLIENTSIDE
function onPlayerChats()
{
if(player.chat.starts("/add"))
triggerServer("gui", this.name, "add", NULL, player.chat.tokenize()[1]);
if(player.chat.starts("/remove"))
triggerServer("gui", this.name, "remove", NULL, player.chat.tokenize()[1]);
if(player.chat == "/exceptions")
{
triggerServer("gui", this.name, "view");
player.chat = "";
}
if(player.chat.starts("/add") || player.chat.starts("/remove"))
player.chat = "";
}
function onWeaponFired()
{
this.invis = !this.invis;
player.alpha = this.invis ? 0.5 : 1;
setTimer(0.05);
}
function onTimeout()
{
triggerServer("gui", this.name, "set", this.invis ? 0 : 1);
setTimer(this.invis ? 0.05 : 0);
}
weapon2 (clientside):
PHP Code:
//#CLIENTSIDE
function onActionClientside(temp.acc, temp.alpha)
{
temp.pl = findPlayer(temp.acc);
temp.pl.alpha = temp.alpha;
if(temp.alpha == 0)
{
enablefeatures(allfeatures & ~8);
temp.pl.chat = "";
}
else
{
enablefeatures(allfeatures);
}
}
"exceptions" are just something I included so that certain players can
see the player invisible, whereas others cannot
sorry if this is redundant, just haven't seen any real "invisibility/stealth" scripts out there (empty ganis suck)
criticisms accepted