Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Port

Pages: 1 ... 1003 1004 1005 1006 1007 [1008] 1009 1010 1011 1012 1013 ... 1041
15106
Forum Games / Re: Fuse your name with the above poster!
« on: January 30, 2012, 05:29:18 AM »
MrMcPort.

15107
Forum Games / Re: Scrabble Slam
« on: January 30, 2012, 04:20:24 AM »
Duck.

15108
Forum Games / Re: Fuse your name with the above poster!
« on: January 30, 2012, 04:20:03 AM »
MrMcPort.

15109
Off Topic / Re: Would You Rather..?
« on: January 30, 2012, 04:04:06 AM »
Would you rather use SOPA/PIPA or ACTA?

15110
General Discussion / Re: Your dream addons or additons to the game.
« on: January 30, 2012, 04:00:26 AM »
Player shadows on bricks.
Player shadows on players.
Brick shadows on bricks.
Brick shadows on players.
Brick shadows on map.
Vehicle shadows on bricks.
Objects being able to "block sunlight" (build with bricks all around it, completely dark).
Realistic collision.
Shape-based bounding boxes.
SQLite interface.
Regular Expression interface.
Binary file reading.
Able to use \x00 in strings.

15111
Off Topic / Re: Would You Rather..?
« on: January 30, 2012, 03:29:23 AM »
Depends on the type of phone.

15112
Modification Help / Re: Points Value
« on: January 30, 2012, 02:50:41 AM »
This only gives me the value of the first player's score.

Yes, you forgot to change index.

"index" is a number from 0 - (playerCount - 1), not a name.

15113
Suggestions & Requests / Re: Better Centerprint
« on: January 30, 2012, 02:19:11 AM »
Just add <br> until you get the desired height.

15114
Modification Help / Re: BlokHeads
« on: January 29, 2012, 11:14:28 AM »
Bump.

15115
Off Topic / Re: Google Chrome crashes.
« on: January 29, 2012, 06:02:06 AM »
What version are you running? I have never seen this happen, ever.

15116
Modification Help / Re: BLG Development
« on: January 29, 2012, 02:26:55 AM »
Still can't log in. :c

15117
Modification Help / Re: Flexible permission system
« on: January 29, 2012, 02:24:42 AM »
That's strange. Five days before I saw this topic I wrote some really messy incomplete "matrix permissions" thing.

Code: [Select]
if ( !isObject( "roleManagerSO" ) )
{
new scriptObject( "roleManagerSO" );
}

if ( !isObject( "permManagerSO" ) )
{
new scriptObject( "permManagerSO" )
{
count = 0;
};
}

function gameConnection::perm( %this, %id )
{
if ( !isObject( %so = "permManagerSO" ) )
{
return false;
}

if ( !%so.isPerm( %id ) )
{
return false;
}

%accept = false;
%adminLvl = ( %this.bl_id == getNumKeyID ? 3 : ( %this.isSuperAdmin ? 2 : ( %this.isAdmin ? 1 : 0 ) ) );

if ( %adminLvl >= 3 && %so.permHost[ %id ] )
{
return true;
}

if ( %adminLvl >= %so.permDefault[ %id ] )
{
%accept = true;
}

for ( %i = 0 ; %i < %this.permCount ; %i++ )
{
if ( %this.permIndex[ %i ] $= %id )
{
if ( %this.permValue[ %id ] )
{
%accept = true;
}
else
{
return false;
}
}
}

for ( %i = 0 ; %i < %this.roleCount ; %i++ )
{
%obj = getRoleObjByID( %this.roleIndex[ %i ] );

if ( %obj.hasPerm( %id ) )
{
if ( %obj.permValue[ %id ] )
{
%accept = true;
}
else
{
return false;
}
}
}

return %accept;
}

function gameConnection::hasPerm( %this, %id )
{
for ( %i = 0 ; %i < %this.permCount ; %i++ )
{
if ( %this.permIndex[ %i ].id $= %id )
{
return true;
}
}

return false;
}

function getRoleObjByID( %id )
{
if ( !isObject( %so = "roleManagerSO" ) )
{
return -1;
}

%count = %so.getCount();

for ( %i = 0 ; %i < %count ; %i++ )
{
%obj = %so.getObject( %i );

if ( %obj.id $= %id )
{
return %obj;
}
}

return -1;
}

function gameConnection::removeNullPerms( %this )
{
if ( !isObject( %so = "permManagerSO" ) )
{
error( "ERROR: gameConnection::removeNullPerms() - unable to find permManagerSO!" );
return false;
}

%count = %this.permCount;

for ( %i = 0 ; %i < %count ; %i++ )
{
%perm = %this.permIndex[ %i ];

if ( !%so.isPerm( %perm ) )
{
%this.removePerm( %perm );
%i--;
}
}
}

function gameConnection::removeNullRoles( %this )
{
if ( !isObject( %so = "roleManagerSO" ) )
{
error( "ERROR: gameConnection::removeNullRoles() - unable to find roleManagerSO!" );
return false;
}

%count = %this.roleCount;

for ( %i = 0 ; %i < %count ; %i++ )
{
%role = %this.roleIndex[ %i ];

if ( !%so.isRole( %role ) )
{
%this.removeRole( %role );
%i--;
}
}
}

function gameConnection::addRole( %this, %id )
{
if ( !isObject( %so = "roleManagerSO" ) )
{
error( "ERROR: gameConnection::addRole() - unable to find roleManagerSO!" );
return false;
}

if ( !%so.isRole( %id ) )
{
warn( "gameConnection::addRole() - role" SPC %id SPC "does not exist!" );
return false;
}

if ( %this.hasRole( %id ) )
{
warn( "gameConnection::addRole() - role" SPC %id SPC "is already present!" );
return false;
}

%this.roleIndex[ %this.roleCount ] = %id;
%this.roleCount++;
}

function gameConnection::removeRole( %this, %id )
{
if ( !isObject( %so = "roleManagerSO" ) )
{
error( "ERROR: gameConnection::removeRole() - unable to find roleManagerSO!" );
return false;
}

if ( !%this.hasRole( %id ) )
{
warn( "gameConnection::addRole() - role" SPC %id SPC "is not present!" );
return false;
}

%found = false;

for ( %i = 0 ; %i < %this.roleCount ; %i++ )
{
if ( %found )
{
%this.roleIndex[ %i ] = %this.roleIndex[ %i + 1 ];
}
else
{
if ( %this.roleIndex[ %i ] $= %id )
{
%found = true;
%i--;
continue;
}
}
}

%this.roleCount--;
return true;
}

function gameConnection::hasRole( %this, %id )
{
for ( %i = 0 ; %i < %this.roleCount ; %i++ )
{
if ( %this.roleIndex[ %i ] $= %id )
{
return true;
}
}

return false;
}

function gameConnection::setPerm( %this, %id, %value )
{
if ( !isObject( %so = "permManagerSO" ) )
{
error( "ERROR: gameConnection::setPerm() - unable to find permManagerSO!" );
return false;
}

if ( !strLen( %id ) )
{
warn( "gameConnection::setPerm( id, value ) - null is not a valid permission id!" );
return false;
}

if ( !%so.isPerm( %id ) )
{
warn( "gameConnection::setPerm() - perm" SPC %id SPC "does not exist!" );
return false;
}

if ( !%this.hasPerm( %id ) )
{
%this.permIndex[ %this.permCount ] = %id;
%this.permCount++;
}

%this.permValue[ %id ] = %value;
return true;
}

function gameConnection::removePerm( %this, %id )
{
if ( !isObject( %so = "permManagerSO" ) )
{
error( "ERROR: gameConnection::removePerm() - unable to find permManagerSO!" );
return false;
}

if ( !strLen( %id ) )
{
warn( "gameConnection::removePerm( id ) - null is not a valid permission id!" );
return false;
}

if ( !%this.hasPerm( %id ) )
{
warn( "gameConnection::removePerm() - perm" SPC %id SPC "has no value on this role!" );
return false;
}

%this.permValue[ %id ] = "";
%found = false;

for ( %i = 0 ; %i < %this.permCount ; %i++ )
{
if ( %found )
{
%this.permIndex[ %i ] = %this.permIndex[ %i + 1 ];
}
else
{
if ( %this.permIndex[ %i ] $= %id )
{
%found = true;
%i--;
continue;
}
}
}

%this.permCount--;
return true;
}

function permManagerSO::isPerm( %this, %id )
{
for ( %i = 0 ; %i < %this.count ; %i++ )
{
if ( %this.element[ %i ] $= %id )
{
return true;
}
}

return false;
}

function roleManagerSO::isRole( %this, %id )
{
%count = %this.getCount();

for ( %i = 0 ; %i < %count ; %i++ )
{
if ( %this.getObject( %i ).id $= %id )
{
return true;
}
}

return false;
}

function roleManagerSO::removeNullPerms( %this )
{
if ( !isObject( %so = "permManagerSO" ) )
{
error( "ERROR: roleManagerSO::removeNullPerms() - unable to find permManagerSO!" );
return false;
}

%count = %this.getCount();

for ( %i = 0 ; %i < %count ; %i++ )
{
%role = %this.getObject( %i );

for ( %x = 0 ; %x < %x.count ; %x++ )
{
%perm = %role.element[ %i ];

if ( !%so.isPerm( %perm ) )
{
%role.removePerm( %perm );
%x--;
}
}
}
}

function roleSO::setPerm( %this, %id, %value )
{
if ( !isObject( %so = "permManagerSO" ) )
{
error( "ERROR: roleSO::setPerm() - unable to find permManagerSO!" );
return false;
}

if ( !strLen( %id ) )
{
warn( "roleSO::setPerm( id, value ) - null is not a valid permission id!" );
return false;
}

if ( !%so.isPerm( %id ) )
{
warn( "roleSO::setPerm() - perm" SPC %id SPC "does not exist!" );
return false;
}

if ( !%this.hasPerm( %id ) )
{
%this.element[ %this.count ] = %id;
%this.count++;
}

%this.permValue[ %id ] = %value;
return true;
}

function roleSO::removePerm( %this, %id )
{
if ( !isObject( %so = "permManagerSO" ) )
{
error( "ERROR: roleSO::removePerm() - unable to find permManagerSO!" );
return false;
}

if ( !strLen( %id ) )
{
warn( "roleSO::removePerm( id ) - null is not a valid permission id!" );
return false;
}

if ( !%this.hasPerm( %id ) )
{
warn( "roleSO::removePerm() - perm" SPC %id SPC "has no value on this role!" );
return false;
}

%this.permValue[ %id ] = "";
%found = false;

for ( %i = 0 ; %i < %this.count ; %i++ )
{
if ( %found )
{
%this.element[ %i ] = %this.element[ %i + 1 ];
}
else
{
if ( %this.element[ %i ] $= %id )
{
%found = true;
%i--;
continue;
}
}
}

%this.count--;
return true;
}

function roleSO::hasPerm( %this, %id )
{
for ( %i = 0 ; %i < %this.count ; %i++ )
{
if ( %this.element[ %id ] $= %id )
{
return true;
}
}

return false;
}

function createRole( %id, %name )
{
if ( !isObject( %so = "roleManagerSO" ) )
{
error( "ERROR: createRole() - unable to find roleManagerSO!" );
return false;
}

%obj = new scriptObject()
{
className = "roleSO";
parent = %so;

id = %id;
name = %name;
count = 0;
};

%obj.setName( "roleSO_" @ %id );
%so.add( %obj );

return %obj;
}

function deleteRole( %id )
{
if ( !isObject( %so = "roleManagerSO" ) )
{
error( "ERROR: deleteRole() - unable to find roleManagerSO!" );
return false;
}

if ( !%so.isRole( %id ) )
{
error( "ERROR: deleteRole() - role" SPC %id SPC "does not exist!" );
return false;
}

%count = %so.getCount();

for ( %i = 0 ; %i < %count ; %i++ )
{
%obj = %so.getObject( %i );

if ( %obj.id $= %id )
{
%obj.delete();
}
}

return true;
}

function registerPerm( %id, %name, %default, %host )
{
if ( !isObject( %so = "permManagerSO" ) )
{
error( "ERROR: registerPerm() - unable to find permManagerSO!" );
return false;
}

if ( !strLen( %default ) )
{
%default = 4;
}

if ( !strLen( %id ) )
{
warn( "registerPerm( id, name, default ) - null is not a valid permission id!" );
return false;
}

if ( %so.isPerm( %id ) )
{
warn( "registerPerm() - perm" SPC %id SPC "already exists, overwriting!" );
%so.permName[ %id ] = %name;
%so.permDefault[ %id ] = %default;
%so.permHost[ %id ] = %host;

return true;
}

%so.element[ %so.count ] = %id;
%so.permName[ %id ] = %name;
%so.permDefault[ %id ] = %default;
%so.permHost[ %id ] = %host;
%so.count++;

return true;
}

function unRegisterPerm( %id )
{
if ( !isObject( %so = "permManagerSO" ) )
{
error( "ERROR: registerPerm() - unable to find permManagerSO!" );
return false;
}

if ( !strLen( %id ) )
{
warn( "unRegisterPerm( id ) - null is not a valid permission id!" );
return false;
}

if ( !%so.isPerm( %id ) )
{
warn( "unRegisterPerm( id ) - permission '" @ %id @ "' does not exist!" );
return false;
}

%so.permName[ %id ] = "";
%so.permDefault[ %id ] = "";
%so.permHost[ %id ] = "";
%found = false;

for ( %i = 0 ; %i < %so.count ; %i++ )
{
if ( %found )
{
%so.element[ %i ] = %so.element[ %i + 1 ];
}
else
{
if ( %so.element[ %i ] $= %id )
{
%found = true;
%i--;
continue;
}
}
}

%so.count--;

if ( isObject( %so = "roleManagerSO" ) )
{
%so.removeNullPerms();
}

%count = clientGroup.getCount();

for ( %i = 0 ; %i < %count ; %i++ )
{
clientGroup.getObject( %i ).removeNullPerms();
}

return true;
}

registerPerm( "perms.role.create", "Create Role", 3, true );
registerPerm( "perms.role.assign", "Assign Permission to Role", 3, true );
registerPerm( "perms.role.revoke", "Revoke Permission from Role", 3, true );
registerPerm( "perms.role.delete", "Delete Role", 3, true );
registerPerm( "perms.perm.assign", "Assign Permission to Player", 3, true );
registerPerm( "perms.perm.revoke", "Revoke Permission from Player", 3, true );

15118
Modification Help / Re: finding stats to do with the server
« on: January 29, 2012, 02:18:40 AM »
You can also use getSubStr($ServerInfo::Name, 0, strStr($ServerInfo::Name, "\'")); to get the Host's name if you like.

You don't need to escape ' unless if it's in a tagged string.

15119
Port still has an invite, lynch him instead.

Uh oh.

15120
Modification Help / Re: finding stats to do with the server
« on: January 28, 2012, 01:50:43 PM »
$ServerInfo::Name

Changed the code now.

Pages: 1 ... 1003 1004 1005 1006 1007 [1008] 1009 1010 1011 1012 1013 ... 1041