Code: Sales Sign

salessign.lsl
///////////////////////////////////////////////////////////////////////////
//  Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3      //
//  Please see: http://www.gnu.org/licenses/gpl.html for legal details,  //
//  rights of fair usage, the disclaimer and warranty conditions.        //
///////////////////////////////////////////////////////////////////////////
 
//////////////////////////////////////////////////////////
//                   CONFIGURATION                      //
//////////////////////////////////////////////////////////
// Permanent short URL map name using external database.
string SHORT_URL = "sales";
 
// API key - can be anything, used as a password.
string API_KEY = "A1364788-B702-4413-B937-7A57E32B43CE";
 
// Sleep, measured in seconds before paging an agent. 
integer SLEEP_DELAY = 10;
///////////////////////////////////////////////////////////////////////////
//                              INTERNALS                                //
///////////////////////////////////////////////////////////////////////////
 
key nQuery = NULL_KEY;
integer gItra = 0;
string llURL = "";
list blockList = [];
 
default
{
    state_entry() {
        blockList = [];
        nQuery = llHTTPRequest("http://server.tld:90/SIM/registerURL.php?action=retrieve&apiKey=" + API_KEY + "&shortURL=" + SHORT_URL, [HTTP_METHOD, "GET"], "");
        return;
    }
    http_response(key reqID, integer status, list metadata, string body) {
        if (nQuery != reqID) return;
        llHTTPResponse(nQuery, 200, "OK");
        llURL = body;
        state scan;
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
state scan {
    state_entry() {
        llSetText("Scanning...", <1,1,1>, 1);
        integer comChannel = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) & 0x3FFFFFFF + 41413) ^ 0xBFFFFFFF;
        llListen(comChannel, "[K] Sales Sign", "", "");
        llSensorRepeat("", "", AGENT, 5, TWO_PI, 1);
        llSetTimerEvent(300);
    }
    listen(integer channel, string name, key id, string messages) {
        list msg = llParseString2List(messages, ["="], []);
        if(llList2String(msg, 0) != "lock") return;
        if(~llListFindList(blockList, (list)llList2Key(msg, 1))) return;
        blockList += llList2String(msg, 1);
    }
    timer() {
        llSetTimerEvent(0);
        blockList = [];
        llHTTPRequest(llURL, [HTTP_METHOD, "POST"], "ping");
        llSetTimerEvent(300);
    }
    http_response(key id, integer status, list metadata, string body) {
        if(status == 499 || body == "pong") return;
        llResetScript();
    }
    sensor(integer num) {
        nQuery = llDetectedKey(0);
        if(~llListFindList(blockList, (list)nQuery)) return;
        llSetTimerEvent(0);
        llSensorRemove();
        state detected;
    }
    on_rez(integer num) {
        llResetScript();
    }
}
 
state detected  {
 
    state_entry() {
        llSetText("Detected agent, sleeping...", <1,1,1>, 1);
        llSensorRepeat("", nQuery, gItra=AGENT, 5, TWO_PI, SLEEP_DELAY);
    }
 
    sensor(integer num) {
        if(gItra--) return;
        if(llSubStringIndex(llURL, "http://") == -1) llResetScript();
        llSetText("Paging...", <1,1,1>, 1);
        integer comChannel = ((integer)("0x"+llGetSubString((string)llGetOwner(),-8,-1)) & 0x3FFFFFFF + 41413) ^ 0xBFFFFFFF;
        if(llListFindList(blockList, (list)nQuery) == -1) blockList += nQuery;
        llRegionSay(comChannel, "lock=" + (string)nQuery); 
        llHTTPRequest(llURL, [HTTP_METHOD, "POST"], "visitor=" + (string)nQuery + "|" + llKey2Name(nQuery) + "|" + "secondlife:///app/parcel/" + llList2String(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_ID]), 0) + "/about");
    }
    no_sensor() {
        state scan;
    }
    on_rez(integer num) {
        llResetScript();
    }
}

secondlife/sales_agent_tool/sales_sign/core.txt ยท Last modified: 2022/11/24 07:46 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.