Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Limited amount of payment per day.

Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
11-29-2008 22:27
Hello again...

i've made a script that pays the person who touches X amount of money based on his/her selection... but.. i have been trying for days to solve an issue that's been bugging me.. i'd appreciate the help

i wanna know if it is possible to make the script pays only for example (1000L$ per 24 hrs) and after he's got the 1000L$ he wont be able to withdraw any more money until 24hrs has passed.

i think i'll have to use the script memory, and users key to work this.. maybe store the info in a website and retrieve upon transactions.

Thank you so much for your help..
Yingzi Xue
Registered User
Join date: 11 Jun 2008
Posts: 144
11-30-2008 04:48
What I would do is record the date and time (llGetTimestamp) that the avatar hits the 1000 Linden mark and their avatar key (from the touch event; llDetectedOwner(0). Each time an avatar clicks on the object their key can be compared with the list and new data is stored--number of clicks (for instance), amount of money given to them, date/time they hit their limit, etc. I would store the user info in a list, one element per user with separated data.

Example: userkey@1000@11:03 AM 11/29/08

Then just store the list element into a temporary string (llList2String) and parse the data using llParseString2List (@ is the separator) into temporary list. Evaluate the data from there. Since you're using avatar keys you always know you have the right data for the right user. You can store all the information you need and just parse it out into a temporary list, then stuff the new data right back into the list.

You should be able to find everything you need on the wiki's for this.

EDIT: Doh! Corrections. Thanks HTH.
Wouter Hobble
Registered User
Join date: 25 Mar 2008
Posts: 21
11-30-2008 05:59
From: Yingzi Xue
What I would do is record the date and time that the avatar hits the 1000 Linden mark and their avatar key. Each time an avatar clicks on the object their key can be compared with the list and new data stored--number of clicks, amount of money given to them, date/time they hit their limit, etc. I would store the user info in a list, one element per user with separated data.

Example: userkey@1000@11:03 AM 11/29/08

Then just parse the list data using llParseList2String looking for the @ separator. Evaluate the data from there. Since you're using avatar keys you always know you have the right data for the right user. You can store all the information you need and just parse it out into a temporary list, then stuff the new data right back into the list.

You should be able to find everything you need on the wiki's for this.

Agreed, but store it in a string first, then use llParseString2List and use llDumpList2String to put it back into the main list using llListReplaceList

You can get the date and time using llGetTimestamp

HTH
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
11-30-2008 08:53
I use a limited payment system with the timeclock script I sell ... though the way I do it is by recording a timestamp when the employee clocks in to a web database ... and then a timestamp when they clock-out. The webpage figures time worked vs. max-time paid for in the day and pays the employee whichever is lesser.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
11-30-2008 16:40
Here's a snippet that may be useful for checking the SL day number...

CODE

integer SECONDS_IN_HOUR = 3600;
integer SECONDS_IN_DAY = 86400;

integer GetDayNumber() {
integer time = llGetUnixTime();
integer day = time / SECONDS_IN_DAY;
integer utc_hours = (time % SECONDS_IN_DAY) / SECONDS_IN_HOUR;
integer pst_hours = (integer)llGetWallclock() / SECONDS_IN_HOUR;

// previous day heuristic
if (pst_hours > utc_hours) {
--day;
}
return day;
}
_____________________
http://slurl.com/secondlife/Together
Gordon Wendt
404 - User not found
Join date: 10 May 2006
Posts: 1,024
11-30-2008 17:01
One suggestion I would add to that idea is use a check in state_entry that requires an owner touch and possibly a dialog agreement before it starts paying out. The upside to doing that is that it prevents abuse in case of a sim crash or restart and guarantees that you know that the script is working whenever the sim crashes or restarts. The downside of course is slightly increased script size and it means that you'll have to activate it manually after each sim crash/restart and pay out manually for the time between the crash/restart and you reactivating it.

An alternative to this of course is have a second object in another sim, or more ideally objects in multiple sims, that your main payer device messages each time the device pays out and that will record the information so you have a backup record. This of course would be less ideal than the website idea but cheaper.
_____________________
Twitter: http://www.twitter.com/GWendt
Plurk: http://www.plurk.com/GordonWendt

GW Designs: XStreetSL

Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
11-30-2008 21:08
Thank you all for your efforts.. but i'm stuck.... i cant do it.. it's just to complicated for me atm... and i have the script in different sims and regions.. and i cant connect them so when i update one.. they all do.. ugh

i'm a just a noob for now..
i'll keep trying tho... hopefully one day....

thank you again for your help.. and i'm sorry to bother you.
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
11-30-2008 21:31
Abdullah - post us the code that you do have and are having troubles with? We can try to help - that's what this board is about. Can't script something for you ... but can sure put effort into helping you learn what to do.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
11-30-2008 21:52
From: Kenn Nilsson
Abdullah - post us....


Ok Kenn, this is my script..

From: MY SCRIPT

list amount = ["1", "2", "3", "5", "10", "15", "20"];
string msg = "Please select how many you need.";
string str_url = "http://www.website.com/test.php?";
integer crate_amount = 599;
string body = "crate";

key ToucherID;
integer channel;
integer listen_id;
default{
state_entry() {
channel = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
}

on_rez(integer start_param)
{
llResetScript();//added this so it resets the script on rez
}

touch_start(integer total_number) {
if(llSameGroup(llDetectedKey(0))){
llSay(0,"Please note that you have 30 seconds to make your selection!";);
ToucherID = llDetectedKey(0);
llDialog(ToucherID, msg,amount, channel);
listen_id = llListen( channel, "", ToucherID, "";);
llSetTimerEvent(30);
}else{
llSay(0, "Sorry, you dont have the right to access this script";);
}
}


listen(integer channel, string name, key id, string message) {
if (message == "1";) {
integer payed_amount = 1 * crate_amount;
llGiveMoney(id, payed_amount);
llInstantMessage(id, "Thank you " + name +", you've been payed '" + payed_amount + "'.";);
llInstantMessage(id, "Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance";);
llHTTPRequest(str_url+"aviName="+llEscapeURL(name)+"&objName="+llEscapeURL(body)+"&objKey="+(string)id+"&regName=test",[],"";);
}else if (message == "2";) {
integer payed_amount = 2 * crate_amount;
llGiveMoney(id, payed_amount);
llInstantMessage(id, "Thank you " + name +", you've been payed '" + payed_amount + "'.";);
llInstantMessage(id, "Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance";);
llHTTPRequest(str_url+"aviName="+llEscapeURL(name)+"&objName="+llEscapeURL(body)+"&objKey="+(string)id+"&regName=test",[],"";);
}else if (message == "3";) {
integer payed_amount = 3 * crate_amount;
llGiveMoney(id, payed_amount);
llInstantMessage(id, "Thank you " + name +", you've been payed '" + payed_amount + "'.";);
llInstantMessage(id, "Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance";);
llHTTPRequest(str_url+"aviName="+llEscapeURL(name)+"&objName="+llEscapeURL(body)+"&objKey="+(string)id+"&regName=test",[],"";);
}else if (message == "4";) {
integer payed_amount = 4 * crate_amount;
llGiveMoney(id, payed_amount);
llInstantMessage(id, "Thank you " + name +", you've been payed '" + payed_amount + "'.";);
llInstantMessage(id, "Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance";);
llHTTPRequest(str_url+"aviName="+llEscapeURL(name)+"&objName="+llEscapeURL(body)+"&objKey="+(string)id+"&regName=test",[],"";);
}else if (message == "5";) {
integer payed_amount = 5 * crate_amount;
llGiveMoney(id, payed_amount);
llInstantMessage(id, "Thank you " + name +", you've been payed '" + payed_amount + "'.";);
llInstantMessage(id, "Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance";);
llHTTPRequest(str_url+"aviName="+llEscapeURL(name)+"&objName="+llEscapeURL(body)+"&objKey="+(string)id+"&regName=test",[],"";);
}else if (message == "10";) {
integer payed_amount = 10 * crate_amount;
llGiveMoney(id, payed_amount);
llInstantMessage(id, "Thank you " + name +", you've been payed '" + payed_amount + "'.";);
llInstantMessage(id, "Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance";);
llHTTPRequest(str_url+"aviName="+llEscapeURL(name)+"&objName="+llEscapeURL(body)+"&objKey="+(string)id+"&regName=test",[],"";);
}else if (message == "15";) {
integer payed_amount = 15 * crate_amount;
llGiveMoney(id, payed_amount);
llInstantMessage(id, "Thank you " + name +", you've been payed '" + payed_amount + "'.";);
llInstantMessage(id, "Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance";);
llHTTPRequest(str_url+"aviName="+llEscapeURL(name)+"&objName="+llEscapeURL(body)+"&objKey="+(string)id+"&regName=test",[],"";);
}else {
integer payed_amount = 20 * crate_amount;
llGiveMoney(id, payed_amount);
llInstantMessage(id, "Thank you " + name +", you've been payed '" + payed_amount + "'.";);
llInstantMessage(id, "Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance";);
llHTTPRequest(str_url+"aviName="+llEscapeURL(name)+"&objName="+llEscapeURL(body)+"&objKey="+(string)id+"&regName=test",[],"";);
}

llListenRemove(listen_id);
llResetScript();
}


timer() { //TIME!
llListenRemove(listen_id);
llWhisper(0,"Sorry, The payment failed. Please try again";);
llResetScript();
}
}


and this is my debug info

From: someone

#ON REZ#
*** state_entry()
GetKey()=00000000-0000-0000-0000-000000000000
GetSubString("00000000-0000-0000-0000-000000000000",-5,-1)="00000"

/---------------------------------------------------------------/

#ON TOUCH --> IF NOT IN THE SAME GROUP#
*** touch_start(1)
DetectedKey(0)=78f132b6-2b1f-a6b6-db13-1a75ecbb5751
SameGroup(78f132b6-2b1f-a6b6-db13-1a75ecbb5751)

OUTPUT: new: Sorry, you dont have the right to access this script

/---------------------------------------------------------------/

#ON TOUCH --> IF IN THE SAME GROUP#
*** touch_start(1)
DetectedKey(0)=78f132b6-2b1f-a6b6-db13-1a75ecbb5751
SameGroup(78f132b6-2b1f-a6b6-db13-1a75ecbb5751)
DetectedKey(0)=78f132b6-2b1f-a6b6-db13-1a75ecbb5751
Dialog(78f132b6-2b1f-a6b6-db13-1a75ecbb5751,Please select how many you need.,1235101520,0)
GetOwner()=78f132b6-2b1f-a6b6-db13-1a75ecbb5751
Listen(0,"",78f132b6-2b1f-a6b6-db13-1a75ecbb5751,"";)=71262156
SetTimerEvent(30.000000)

**SHOW MENU

OUTPUT:
new: Please note that you have 30 seconds to make your selection!

/---------------------------------------------------------------/

#ON MENU SELECTION#

*** listen(0,Abdullah Lemon,78f132b6-2b1f-a6b6-db13-1a75ecbb5751,1)
GiveMoney(78f132b6-2b1f-a6b6-db13-1a75ecbb5751,599)
InstantMessage(78f132b6-2b1f-a6b6-db13-1a75ecbb5751,Thank you Abdullah Lemon, you've been payed '599'.)
InstantMessage(78f132b6-2b1f-a6b6-db13-1a75ecbb5751,Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance)
EscapeURL("Abdullah Lemon";)="Abdullah%20Lemon"
EscapeURL("crate";)="crate"
HTTPRequest("http://www.website.com/test.php?aviName=Abdullah%20Lemon&objName=crate&objKey=78f132b6-2b1f-a6b6-db13-1a75ecbb5751&regName=test",[],"";)="551ba1fb-0d5f-413b-8ea0-05718c898a1d"
ListenRemove(71262156)
ResetScript()
*** state_entry()
GetKey()=00000000-0000-0000-0000-000000000000
GetSubString("00000000-0000-0000-0000-000000000000",-5,-1)="00000"



that's about it.. i hope you can help me learn how to do it.... i know my script probably suck real bad.. lol.. but i'm in the learning stage.. so.. :D
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
12-01-2008 07:02
Well Abdullah, for starters ... I did do a little bit of cleanup on the script you currently have:

CODE


list amount = ["1", "2", "3", "5", "10", "15", "20"];
string msg = "Please select how many you need.";
string str_url = "http://www.website.com/test.php?";
integer crate_amount = 599;
string body = "crate";

key ToucherID;
integer channel;
integer listen_id;

default{
state_entry() {
channel = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
}
on_rez(integer start_param) {
llResetScript();//added this so it resets the script on rez
}
touch_start(integer total_number) {
if(llSameGroup(llDetectedKey(0))){
llSay(0,"Please note that you have 30 seconds to make your selection!");
ToucherID = llDetectedKey(0);
llDialog(ToucherID, msg,amount, channel);
listen_id = llListen( channel, "", ToucherID, "");
llSetTimerEvent(30.0); //Added .0 to float value for efficiency
}else{
llSay(0, "Sorry, you dont have the right to access this script");
}
}

listen(integer channel, string name, key id, string message) {
//All of your message responses were redundant - can be done with one iteration of them
llSetTimerEvent(0.0);
llListenRemove(listen_id);
payed_amount = (integer)message * crate_amount;
llGiveMoney(id, payed_amount);
llInstantMessage(id, "Thank you " + name +", you've been payed '" + payed_amount + "'.");
llInstantMessage(id, "Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance");
llHTTPRequest(str_url+"aviName="+llEscapeURL(name)+"&regName=test",[],"");
}

timer() { //TIME!
llSetTimerEvent(0.0);
llListenRemove(listen_id);
llWhisper(0,"Sorry, The payment failed. Please try again");
//No need to reset script at timer() expire
}
}



Now ... from there what I'd do is change your listen code so that it simply makes the llHTTPRequest, does not pay out. Then add an http_response event that will pay out if and only if the avatar has not yet reached their daily limit as determined by your webpage.

Do you have web-end programming experience? Ability to store things on a database?

The new code would look like:

CODE


list amount = ["1", "2", "3", "5", "10", "15", "20"];
string msg = "Please select how many you need.";
string str_url = "http://www.website.com/test.php?";
integer crate_amount = 599;
string body = "crate";

key ToucherID;
key req;
integer channel;
integer listen_id;

default{
state_entry() {
channel = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
}
on_rez(integer start_param) {
llResetScript();//added this so it resets the script on rez
}
touch_start(integer total_number) {
if(llSameGroup(llDetectedKey(0))){
llSay(0,"Please note that you have 30 seconds to make your selection!");
ToucherID = llDetectedKey(0);
llDialog(ToucherID, msg,amount, channel);
listen_id = llListen( channel, "", ToucherID, "");
llSetTimerEvent(30.0); //Added .0 to float value for efficiency
}else{
llSay(0, "Sorry, you dont have the right to access this script");
}
}

listen(integer channel, string name, key id, string message) {
//All of your message responses were redundant - can be done with one iteration of them
llSetTimerEvent(0.0);
llListenRemove(listen_id);
req = llHTTPRequest(str_url+"aviName="+llEscapeURL(name)+"&regName=test",[],"");
}

http_response(key id, integer status, list meta, string body)
{
if(id != req) return;
if(status == 499) llSay(0, "Request time out. Please try again later.");
else if(status != 200) llSay(0, "An unknown error occured.");
else if(body != "authorized") llSay(0, "You have already been paid your maximum daily amount.");
else
{
payed_amount = (integer)body;
llGiveMoney(id, payed_amount);
llInstantMessage(id, "Thank you " + name +", you've been payed '" + payed_amount + "'.");
llInstantMessage(id, "Please contact Abdullah Lemon on IMs or abdullah.lemon[AT]gmail.com for any assistance");
}
}

timer() { //TIME!
llSetTimerEvent(0.0);
llListenRemove(listen_id);
llWhisper(0,"Sorry, The payment failed. Please try again");
//No need to reset script at timer() expire
}
}



Additionally - you don't need to send the object name or object key as variables in your URL-string ... they are already sent by default as headers.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
12-01-2008 20:58
From: Kenn Nilsson
Well Abdullah, for starters ....


Thank you sir, your help is appreciated. :)

i know a little PHP and i can make it work..

i'll get the request from llHTTPRequest analyze it,, and see if the amount is greater than the allowed daily limit and make the response from there..

Thank you that should work perfectly :)

i cant thank you enough for all your help