Pay Roll Tool

Written by: Headmaster
//Here's a handy little script I wrote up to exchange money with people who are either far away or offline. Since the only other way to pay someone is in person by the pie chart, this can come in very handy. Especially for payroll of employees, hence the name.
 
//The only catch is you need the persons key but this can be acquired several different ways; make them touch a scripted object and log it, use a sensor on them, use a sensor on their in world objects if they're offline, etc. I can post several scripts to get keys if people need.
 
//IM me in game if you'd like a copy of the script without having to cut and paste it.
 
// payroll.ll by Rathe Underthorn "00aa39a8-f6a4-45be-991e-b1e1fca8fe5b"
// say @pay   to pay a user on your payroll list.
 
float fVersion = 1.0;
 
list lsPeople =
[
// ADD PEOPLE HERE AS "NICKNAME", "KEY",
 
"Arthur", "62091005-826d-44cd-ab80-0a6b96915b44", // Arthur Money
"Carrera", "e6b0b6e9-0dee-4e6e-bfb9-c725d0db3f01", // Carrera LeFay
"Darwin", "3e722bd8-028c-713f-e4f7-2e9b680855c8", // Darwin Appleby
"Kaylis", "16f627e1-ab89-4b1f-827f-63bd7bd3a7b9", // Kaylis LeFay
"Rathe", "00aa39a8-f6a4-45be-991e-b1e1fca8fe5b", // Rathe Underthorn
"Si", "117274fd-3902-4a07-b411-09bdc79f0fad", // Si Money
"Yuki", "3e8a2608-661d-ca16-0492-9233c77d3d1c", // Yuki Sunshine
 
// DO NOT REMOVE THIS END ROW
 
"END", "END"
];
 
integer nPublicChannel = 0;
integer nPublicId = 0;
string szTarget = "";
integer nAmount = 0;
key kTarget = NULL_KEY;
 
init_listen()
{
llListenRemove(nPublicId);
nPublicId = llListen(nPublicChannel, "", NULL_KEY, "");
}
 
key target_to_key(string szTarget)
{
integer i;
integer nListSize = llGetListLength(lsPeople) - 2;
 
for (i = 0; i < nListSize; i += 2)
{
if (llToLower(llList2String(lsPeople, i)) == llToLower(szTarget))
{
return llList2Key(lsPeople, i + 1);
}
}
 
return NULL_KEY;
}
 
default
{
state_entry()
{
szTarget = "";
nAmount = 0;
kTarget = NULL_KEY;
init_listen();
}
 
on_rez(integer nStartParam)
{
szTarget = "";
nAmount = 0;
kTarget = NULL_KEY;
init_listen();
}
 
listen(integer nChannel, string szName, key kId, string szMessage)
{
if (nChannel == nPublicChannel)
{
if (kId == llGetOwner())
{
if (llGetSubString(llToLower(szMessage), 0, 4) == "@pay ")
{
integer nCmdLen = llStringLength(szMessage);
string szTokens = llGetSubString(szMessage, 5, nCmdLen);
 
integer nTokenPos = llSubStringIndex(szTokens, " ");
integer nTokenLen = llStringLength(szTokens);
 
szTarget = llGetSubString(szTokens, 0, nTokenPos - 1);
nAmount = (integer)llGetSubString(szTokens, nTokenPos + 1, nTokenLen);
 
kTarget = target_to_key(szTarget);
 
if (kTarget != NULL_KEY)
{
integer nPerm = llGetPermissions();
 
if (!(nPerm & PERMISSION_DEBIT))
{
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
else
{
llWhisper(0, "Paying " + szTarget + " $" + (string)nAmount);
llGiveMoney(kTarget, nAmount);
}
}
}
}
}
}
 
run_time_permissions(integer nPermissions)
{
if (nPermissions) // permission granted
{
if (kTarget != NULL_KEY)
{
llWhisper(0, "Paying " + szTarget + " $" + (string)nAmount);
llGiveMoney(kTarget, nAmount);
}
}
else
{
llWhisper(0, "You denied debit permission, payments will not work, try again...");
}
}
}

 

Category: