Jump to content

Anti Shouter ORB


JJValero Writer
 Share

You are about to reply to a thread that has been inactive for 3598 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

 This script return shouters to their owners. The main use is for malls. If a tenant rezz a lucky chair or any other object configured to shout, is returned.

This script know if any object is shouting if their distance is more of 20 m. They must be placed at strategic distances, for example 30 m above the mall.

If you are using this script in a place subsceptible of be attacked by grieffers, I recommend remove the line that starts with "llInstantMessage" near of the end of code.

 

The code is this:

 

key gkOwner = NULL_KEY;
float RADIUS = 20.0;
integer g_iReturnedObjects;
integer g_iErrors;

default {
    state_entry() {
        
        llSetMemoryLimit(4096 * 3);
        gkOwner = llGetOwner();
        
        list lDetails = llGetParcelDetails(llGetPos(), [ PARCEL_DETAILS_OWNER, PARCEL_DETAILS_GROUP]);
        key kParcelOwner = llList2Key(lDetails, 0);
        key kParcelGroup = llList2Key(lDetails, 1);
        
        if (kParcelOwner == gkOwner) {
            state GetPermissions;
        } else if (kParcelOwner == kParcelGroup) {
            llOwnerSay("Parcel is deeded to a group, you must deed this object in order to work.");
        } else {
            llOwnerSay("I can not work here, you are not the owner of this land.");
        }

    }
    
    on_rez(integer start_param) {
    
        llResetScript();
            
    }
    
    changed(integer change) {
        
        if ((change & CHANGED_OWNER) == CHANGED_OWNER) {
            
            key kNewOwner = llGetOwner();
            
            list lDetails = llGetParcelDetails(llGetPos(), [ PARCEL_DETAILS_OWNER, PARCEL_DETAILS_GROUP]);
            key kParcelOwner = llList2Key(lDetails, 0);
            key kParcelGroup = llList2Key(lDetails, 1);
            
            if (kNewOwner == kParcelGroup) {
                state GetPermissions;
            } else if (kNewOwner == kParcelOwner) {
                gkOwner = kNewOwner;
                state GetPermissions;
            }
            
        }
        
    }
    
}

state GetPermissions {
    
    state_entry() {
        
        llWhisper(0, "waiting for permissions.");
        llRequestPermissions(gkOwner, PERMISSION_RETURN_OBJECTS);
        
    }
    
    on_rez(integer start_param) {
    
        llResetScript();
            
    }
    
    run_time_permissions(integer value) {
        
        if (value & PERMISSION_RETURN_OBJECTS) {
            
            state Running;
            
        }
        
    }
    
}

state Running {
    
    state_entry() {
        
        g_iReturnedObjects = 0;
        g_iErrors = 0;
        
        llWhisper(0, "Ok, permissions given");
        llListen(0, "", NULL_KEY, "");
        
    }
    
    on_rez(integer start_param) {
    
        llResetScript();
            
    }
    
    changed(integer change) {
        
        if ((change & CHANGED_OWNER) == CHANGED_OWNER) {
            llResetScript();
        } // if
        
    }
    
    listen(integer channel, string name, key id, string message) {
        
        if (llOverMyLand(id) == FALSE) {
            return;
        }
        
        list lResults = llGetObjectDetails(id, [ OBJECT_POS, OBJECT_OWNER, OBJECT_ROOT ]);
        vector vObjPos = llList2Vector(lResults, 0);
        key kObjOwner = llList2Key(lResults, 1);
        key kRoot = llList2Key(lResults, 2);
        
        if (id == kObjOwner) {
            return; // is an avatar.
        }
        
        key kObjToReturn = id;
        if (kRoot != id) {
            kObjToReturn = kRoot;
        }
        
        float fDistance = llVecMag(vObjPos - llGetPos());
        
        if (fDistance > RADIUS) {
            
            llInstantMessage(gkOwner, "Returning object [" + name + "] from owner: " + (string) llGetOwnerKey(id));
            integer result = llReturnObjectsByID( [ kObjToReturn ]);
            if (result == 1) {
                g_iReturnedObjects++;
            } else {
                g_iErrors++;
                llSay(DEBUG_CHANNEL, "Value returned: " + (string) result);
            }
        }
        llSetText("Returned : " + (string) g_iReturnedObjects + "\nErrors : " + (string) g_iErrors, <1.0, 1.0, 1.0>, 1.0);
        
        
    }
    
}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3598 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...