Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

perms trouble Animation|Take Control

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
03-20-2008 00:13
have no idea what is with it, i have a custam animation that will triger when you sit in the car then at another part after you say start it will do the llTakeControl perms but the trouble is right after the perms event

CODE

changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if (agent)
{

llMessageLinked(LINK_ALL_CHILDREN , 0, "WHEEL_DRIVING", NULL_KEY);
llSleep(.4);
llSetStatus(STATUS_PHYSICS, TRUE);
llSleep(.1);
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION);
llSetTimerEvent(0.1);
llSleep(0.7);
driver = llListen(0,"",agent,"");
Linear = <0,0,-2>;
}
else
{
llSetTimerEvent(0);
llStopAnimation(DrivingAnim);
Active = 0;
llStopSound();
llSetStatus(STATUS_PHYSICS, FALSE);
llMessageLinked(LINK_ALL_CHILDREN , 0, "WHEEL_DEFAULT", NULL_KEY);
llReleaseControls();
}
}
}

run_time_permissions(integer perms)
{
if(perms == (PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS)

//ERROR
llStopAnimation("sit");
llStartAnimation(DrivingAnim);
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_DOWN | CONTROL_UP | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE);
}
}
listen( integer channel, string name, key id, string message )
{
key agent = llAvatarOnSitTarget();
if(message == "start")
{
llRequestPermissions(agent,PERMISSION_TAKE_CONTROLS);
llTriggerSound("car_start",1);
llSleep(3.0);
llLoopSound("car_idle",3);
llSetStatus(STATUS_PHYSICS,TRUE);
}
else if(message == "stop")
{
llStopSound();
llSetStatus(STATUS_PHYSICS,FALSE);
}
}
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
03-20-2008 00:33
I dunno if this is 'it', but you may need to grant both permissions at once--when PERMISSION_TAKE_CONTROLS gets granted it'll replace PERMISSION_TRIGGER_ANIMATION... the client says "change the permissions mask to *this*" instead of "add this permission to the permissions mask"
_____________________
Atashi Toshihiko
Frequently Befuddled
Join date: 7 Dec 2006
Posts: 1,423
03-20-2008 10:03
Definately request animation and controls permissions at the same time, do not do them in series or as Day Oh has pointed out, you lose the animation permissions.

Also, do not use == when evaluating the permissions parameter. Use the & operator.

In the changed event you want:
llRequestPermissions(agent, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION)

In the run time permissions event, I do something like this:
if(perms & PERMISSION_TRIGGER_ANIMATION) llStartAnimation("animation name";);
if(perms & PERMISSION_TAKE_CONTROLS) llTakeControls(controls_bitmask, TRUE, FALSE);

It might be a bit clunky but it works and doesn't throw errors.
As soon as the avatar is seated, they do the animation and the vehicle takes controls, you can then use their 'start' chat to activate the physics etc.

-Atashi
_____________________
Visit Atashi's Art and Oddities Store and the Waikiti Motor Works at beautiful Waikiti.