Author Topic: Environment Control ~ Won't work with host no matter what  (Read 336 times)

Alright this is acting weird, basically the method I used to detect the host was not working so I changed the code to this

Code: [Select]
if(isFile("Add-Ons/System_ReturnToBlockland/server.cs"))
{
        if(!$RTB::RTBR_ServerControl_Hook)
exec("Add-Ons/System_ReturnToBlockland/RTBR_ServerControl_Hook.cs");
RTB_registerPref("Can Change Environment","Environment Control","ECP","list Host 1 SuperAdmin 2 Admin 3","Script_EnvironmentControl",3,0,1);
}
else
{
$ECP = 3;
}

package EnvironmentControl
{
function serverCmdEnvGui_SetVar(%object,%var,%value)
{
switch($ECP)
{
case 1:
if(!%object.isServerHost)
{
commandtoclient(%object,'MessageBoxOK',"Environment","You do not have permission to change the Environment");
return;
}
case 2:
if(!%object.isSuperAdmin)
{
commandtoclient(%object,'MessageBoxOK',"Environment","You do not have permission to change the Environment");
return;
}
case 3:
if(!%object.isAdmin)
{
return;
}
}
Parent::ServerCmdEnvGui_SetVar(%object,%var,%value);
}

function serverCmdEnvGui_RequestCurrentVars(%object)
{
switch($ECP)
{
case 1:
if(!%object.isServerHost)
{
commandtoclient(%object,'MessageBoxOK',"Environment","You do not have permission to change the Environment");
return;
}
case 2:
if(!%object.isSuperAdmin)
{
commandtoclient(%object,'MessageBoxOK',"Environment","You do not have permission to change the Environment");
return;
}
case 3:
if(!%object.isAdmin)
{
return;
}
}
Parent::serverCmdEnvGui_RequestCurrentVars(%object);
}

function GameConnection::AutoAdminCheck(%client)
{
%client.isServerHost = %client.bl_id == getnumkeyid())
Parent::AutoAdminCheck(%client);
}

//Server command if you prefer them over RTB prefs
function serverCmdEnvironmentpermission(%client, %mode, %mode2)
{
if(%client.bl_id == getnumkeyid())
{
if(%mode $= "host")
{
if($ECP == 1)
MessageClient(%client,'',"\c6Environment permission is already set to Host");
else
{
$ECP = 1;
MessageAll('',"\c6Environment permission has been set to \c2Host");
}
}
else if(%mode $= "super" && %mode2 $= "admin")
{
if($ECP == 2)
MessageClient(%client,'',"\c6Environment permission is already set to Super Admin");
else
{
$ECP = 2;
MessageAll('',"\c6Environment permission has been set to \c2Super Admin");
}
}
else if(%mode $= "admin")
{
if($ECP == 3)
MessageClient(%client,'',"\c6Environment permission is already set to Admin");
else
{
$ECP = 3;
MessageAll('',"\c6Environment permission has been set to \c2Admin");
}
}
}
}
};
activatepackage(EnvironmentControl);
As you can see I have an autoAdminCheck in there that when the host connects it will set the value of isServerHost to 1. That part works fine but for some reason whenever I do if(!%object.isServerHost) which is suppose to stop everyone except the host from changing the environment the permission popup still appears.

Am I missing something stupid?


Well there's a syntax error right there...

Well there's a syntax error right there...
I know I saw it literally 5 seconds after I hit post.