Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(fixed) RemoveTimer Problem! please help :(
bjaffedj Offline
Junior Member

Posts: 39
Threads: 8
Joined: Aug 2012
Reputation: 0
#1
(fixed) RemoveTimer Problem! please help :(

okay i have a map script. in the script i have a function which makes the player being pushed (AddPlayerBodyForce). but each time i try to remove the timer of the function it does not seem to work. the player still gets pushed :/ i have tried many things and hopefully you can help Smile


The scripting:


void OnStart()
{
SetMapDisplayNameEntry("Intro");
//User properties
SetPlayerActive(false);
SetSanityDrainDisabled(true);
SetInventoryDisabled(true);
SetPlayerCrouchDisabled(true);
SetPlayerJumpDisabled(true);
ShowPlayerCrossHairIcons(false);
SetPlayerLampOil(0.0f);

//Sound properties
PlayMusic("music/intro_bg.ogg", true, 0.5, 2, 0, true);

//Timers
AddTimer("Intro", 8, "Intro");

//Finally start
//Finally Start
FadeOut(0);
FadeIn(4);
StartPlayerLookAt("prodlook", 2.0f, 2.0f, "");

AddTimer("Debug", 1, "Debug");

}

void Debug(string &in asTimer)
{
AddLocalVarInt("aq", 1);
AddDebugMessage(" "+ GetLocalVarInt("aq"), false);
AddTimer("Debug", 1, "Debug");
}

void Intro(string &in asTimer)
{
AddLocalVarInt("IntroInt", 1);

switch( GetLocalVarInt("IntroInt") )
{
case 1:
FadeOut(2);
break;
case 4:
FadeIn(4);
TeleportPlayer("PlayerStartArea_2");
StartPlayerLookAt("titellook", 2.0f, 2.0f, "");
break;
case 12:
FadeOut(3);
break;
case 14:
FadeIn(4);
TeleportPlayer("PlayerStartArea_3");
AddTimer("PushPlayerStart1", 0.01, "PushPlayer1");
StartPlayerLookAt("halllook", 2.0f, 2.0f, "");
break;
case 15:
SetMessage("Messages", "Popup1", 5);
break;
case 22:
SetMessage("Messages", "Popup2", 5);
break;
case 29:
SetMessage("Messages", "Popup3", 5);
break;
case 36:
SetMessage("Messages", "Popup4", 5);
break;
case 43:
SetMessage("Messages", "Popup5", 5);
break;
case 50:
SetMessage("Messages", "Popup6", 5);
break;
case 57:
SetMessage("Messages", "Popup7", 5);
break;
case 62:
FadeOut(3);
break;
case 64:
SetMessage("Messages", "Popup8", 5);
break;
case 69:
FadeIn(4);
TeleportPlayer("PlayerStartArea_4");
SetPlayerActive(true);
SetInventoryDisabled(false);
SetPlayerCrouchDisabled(false);
SetPlayerJumpDisabled(false);
ShowPlayerCrossHairIcons(true);
StopPlayerLookAt();
StopMusic(3.0f , 0.0f);
RemoveTimer("PushPlayerLoop1");
break;
}
if( GetLocalVarInt("IntroInt") < 126)
AddTimer("blackout", 1, "Intro");
}

void PushPlayer1(string &in asTimer)
{
AddPlayerBodyForce(0, 0.0f, 435.1f, true);
AddTimer("PushPlayerLoop1", 0.012, "PushPlayer1");
}
(This post was last modified: 08-10-2012, 09:54 PM by bjaffedj.)
08-10-2012, 10:49 AM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#2
RE: RemoveTimer Problem! please help :(

It is possible it isn't working because the timer is too quick, but there may be a bug in your script i'm not seeing as I've only taken a quick glance. Either way, one solution would just be to not use RemoveTimer, and instead use a variable to mark when to no longer re-add the timer.
08-10-2012, 01:43 PM
Find
bjaffedj Offline
Junior Member

Posts: 39
Threads: 8
Joined: Aug 2012
Reputation: 0
#3
RE: RemoveTimer Problem! please help :(

(08-10-2012, 01:43 PM)Apjjm Wrote: It is possible it isn't working because the timer is too quick, but there may be a bug in your script i'm not seeing as I've only taken a quick glance. Either way, one solution would just be to not use RemoveTimer, and instead use a variable to mark when to no longer re-add the timer.
thanks for reply! Smile
im sorry to ask, since im new to scripting, but which variable is it you recommend i change Smile
08-10-2012, 01:58 PM
Find
Apjjm Offline
Is easy to say

Posts: 496
Threads: 18
Joined: Apr 2011
Reputation: 52
#4
RE: RemoveTimer Problem! please help :(

I would suggest trying the following:

in case 14, before starting the timer, we will need to allow the push loop to work
case 14:
FadeIn(4);
TeleportPlayer("PlayerStartArea_3");

SetLocalVarInt("AllowPlayerPushMove",1); //Say we are allowing the player to be pushed

AddTimer("PushPlayerStart1", 0.01, "PushPlayer1"); //Timer as normal here


StartPlayerLookAt("halllook", 2.0f, 2.0f, "");
break;

In case69, where you are using remove timer we will need to tell the pushing to stop:
case 69:
FadeIn(4);
TeleportPlayer("PlayerStartArea_4");
SetPlayerActive(true);
SetInventoryDisabled(false);
SetPlayerCrouchDisabled(false);
SetPlayerJumpDisabled(false);
ShowPlayerCrossHairIcons(true);
StopPlayerLookAt();
StopMusic(3.0f , 0.0f);

//Say we are no longer allowing the push timer
//instead of Removing the timer
SetLocalVarInt("AllowPlayerPushMove",0);

break;

And the timer method:
void PushPlayer1(string &in asTimer)
{
AddPlayerBodyForce(0, 0.0f, 435.1f, true);

//Only renew the push loop whilst we are allowing the player to be pushed.
if(GetLocalVarInt("AllowPlayerPushMove")==1)
  AddTimer("PushPlayerLoop1", 0.012, "PushPlayer1");

}
08-10-2012, 05:24 PM
Find
bjaffedj Offline
Junior Member

Posts: 39
Threads: 8
Joined: Aug 2012
Reputation: 0
#5
RE: RemoveTimer Problem! please help :(

You Sir... Are Truly AMAZING! it worked like a charm stright ahead, and you also made the scripting nice and easy to understand. you are a very good teacher and thanks man! i been trying to make this work for days and you just make it work in a matter of minutes! i will dedicate my life to you from now on! c:
08-10-2012, 09:53 PM
Find




Users browsing this thread: 2 Guest(s)