Thanks to everyone who contributed this is what I Have in the sorta final.
I liked the switch idea by Rolig Loon because it allowed reusing the timer since you can only have one timer in a state. Although I still get errors it might be due to the error checking. I am rethinking the are where Lucia Nightfire posted about.
Lines: 60 61 and 62:
} else if (reason = XP_ERROR_REQUEST_PERM_TIMEOUT || reason = XP_ERROR_NOT_PERMITTED || reason = XP_ERROR_NOT_FOUND) {
llInstantMessage(agent, "Please accept the experience or bad things may happen!");
}
Might be something there...
Here is the final code so far it's working Try it out or post your comments below if you have better ways. There might be a way to make a separate function for the switch and teleports.
vector teleportme = <212,150,1000>;
string MyObjectName;
string textdefault = "Teleport to platform!";
//Begin code
string theerror;
integer error;
key agent;
integer type;
//this is for the function added to switch on or off globally
//this float is needed for the fuction contributed by Rolig Loon
float iTouched;
default
{
state_entry()
{
iTouched = FALSE;
MyObjectName = llGetObjectName();
//llVolumeDetect(TRUE); Removed because testing timer instead of using volume detect
llSetText(textdefault, <1.0, 1.0, 1.0>, 1.0);
}
collision_start(integer num)
{
agent = llDetectedKey(0); type = llDetectedType(0);
if (type == (AGENT | ACTIVE) ) // 1 + 2
{
llRequestExperiencePermissions(agent, "");
}
}
//Timer added by Rolig Loon https://community.secondlife.com/profile/796876-rolig-loon/
timer()
{
llSetTimerEvent(0.0);
iTouched = FALSE;
}
experience_permissions(key agent) {
//touch function added and contributed by Rolig Loon https://community.secondlife.com/profile/796876-rolig-loon/ with some tweaks
if (iTouched = TRUE)
{
// Do your TP stuff
llSetText(llKey2Name(agent) + " is using the teleporter please wait...", <1.0, 1.0, 1.0>, 1.0);
llTeleportAgent(agent, "", teleportme, teleportme);
llSetTimerEvent(2.0); // Here's your substitute for a llSleep contributed by Rolig Loon
}
llSetText(textdefault, <1.0, 1.0, 1.0>, 1.0);
}
experience_permissions_denied(key agent, integer reason){
string theerror = llGetExperienceErrorMessage((integer)reason);
if(reason = XP_ERROR_THROTTLED) {
//touch function added and contributed by Rolig Loon https://community.secondlife.com/profile/796876-rolig-loon/
//with some tweaks
if (iTouched = TRUE)
{
llSetTimerEvent(4.0); // Here's your substitute for a llSleep contributed by Rolig Loon
}
} else if (reason = XP_ERROR_REQUEST_PERM_TIMEOUT || reason = XP_ERROR_NOT_PERMITTED || reason = XP_ERROR_NOT_FOUND) {
llInstantMessage(agent, "Please accept the experience or bad things may happen!");
}
if(!llAgentInExperience(agent)) {
llRequestExperiencePermissions(agent, "");
//llRequestExperiencePermissions(llDetectedKey(0), "");
}
}
touch_start(integer total_number)
{
iTouched = TRUE;
agent = llDetectedKey(0); type = llDetectedType(0);
if (type == (AGENT | ACTIVE) ) // 1 + 2
{
llRequestExperiencePermissions(agent, "");
}
}
}