Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Timer_Expired
Timer_Expired [message #371542] Wed, 11 February 2009 04:18 Go to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
Is there a way to use the Timer_Expired inside the Enter part of a script??
small sample of what i mean:
void MyScript::Enter
{
  Commands->Start_Timer();
  Timer_Expired //want to call it here
  {
    //rest of code
  }
}


Instead of
void MyScript::Enter
{
  Commands->Start_Timer();
}
void MyScript::Timer_Expired
{
  //rest of code
}


EDIT: Now im already asking would this:
Kill_Enemy_Buildings_By_Team(0)

Be a better solution than:
ConsoleInput("win 0")


Guess this would also work if you don't run a Dedicated Server


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Wed, 11 February 2009 04:21]

Report message to a moderator

Re: Timer_Expired [message #371554 is a reply to message #371542] Wed, 11 February 2009 06:13 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
Quote:


void MyScript::Enter(GameObject *o, GameObject *e)
{
Commands->Start_Timer();
Timer_Expired //want to call it here
{
//rest of code
}
}



No, not possible.

You can do this, however:

Quote:


void MyScript::Enter(GameObject *o, GameObject *e)
{
Commands->Start_Timer(o, this, 123.123, 10);
}

void MyScript::Timer_Expired(GameObject *o, int number)
{
if(number == 10)
{
//do your stuff here
}
}



As for the other thing;

Kill_Enemy_Buildings_By_Team(0)


Is much better, if your server is setup for it.
Re: Timer_Expired [message #371565 is a reply to message #371554] Wed, 11 February 2009 06:58 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
RoShamBo wrote on Wed, 11 February 2009 14:13


You can do this, however:

Quote:


void MyScript::Enter(GameObject *o, GameObject *e)
{
Commands->Start_Timer(o, this, 123.123, 10);
}

void MyScript::Timer_Expired(GameObject *o, int number)
{
if(number == 10)
{
//rest of code
}
}





Yea the problem of this is that after the Timer_Start i use receive info of the user that entered the zone. Can i call this in this part like this than??:
void MyScript::Timer_Expired(GameObject *obj, GameObject *enter, int number)
{
   if(number == Get_Int_Parameter("TimerNumber"))
   {
         playerid = Get_ID(enter)
         //rest of code
   }
}


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Wed, 11 February 2009 07:01]

Report message to a moderator

Re: Timer_Expired [message #371572 is a reply to message #371565] Wed, 11 February 2009 07:32 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3813
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
void MyScript::Enter(GameObject *o, GameObject *e)
{
   Commands->Start_Timer(o, this, 123.123, 10);
   playerid = Get_ID(enter)
}

void MyScript::Timer_Expired(GameObject *obj, GameObject *enter, int number)
{
   if(number == Get_Int_Parameter("TimerNumber"))
   {
         GameObject *enterer = Commands->Find_Object(playerid);
         //rest of code
   }
}


void MyScript::Register_Auto_Save_Variables()
{
	Auto_Save_Variable(1,5,&playerid);
}

You'll have to investigate into arrays if you want the zone to ever be able to handle more then one person, because if thats a 60 second timer, the last id will be overridden before it is put to use if someone hops in.


[Updated on: Wed, 11 February 2009 07:32]

Report message to a moderator

Re: Timer_Expired [message #371576 is a reply to message #371542] Wed, 11 February 2009 07:58 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
When im home i'll paste some more of the code because it's going to be pritty complicated to get Enter into the Timer_Expired part.

Also soon (this afternoon) i'll have a showoff on the ModDB on the Tiberium Redux page of the code so far. Everything is working except this second timer Razz (yes this script uses 2 timers xD )
Seems i have to rewrite the code for a big part if i have to move my proccesing of data from the void MyScript::Enter to void MyScript::Timer_Expired Huh


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Wed, 11 February 2009 07:59]

Report message to a moderator

Re: Timer_Expired [message #371579 is a reply to message #371576] Wed, 11 February 2009 08:14 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3813
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Here, I actually put a minute into this example, it will be a lot more helpful to you I'm sure.
class MyScript : public ScriptImpClass {
        int playerid[127];
        int lastid;
	void Created(GameObject *o);
	void Enter(GameObject *o, GameObject *e);
	void Timer_Expired(GameObject *obj,int number);
	void Register_Auto_Save_Variables();
};

void MyScript::Created(GameObject *o)
{
	lastid = 0;
	for (int x = 0;x < 127;x++)
	{
		playerid[x] = 0;
	}
}

void MyScript::Enter(GameObject *o, GameObject *e)
{
   int end = 0;
   for (int x = 0;x < 128;x++)
   {
      if (playerid[x] == Commands->Get_ID(e);
      {
          end = 1;
      }
   }
   for (int x = lastid;x < 128 && end == 0;x++)
   {
      if (playerid[x] == 0)
      {
           playerid[x] = Get_ID(e);
           lastid = x;
           end = 1;      
           Commands->Start_Timer(o, this, 123, 10);
      }
      if (x == 127)
      {
          x = 0;
      }

   }	
}

void MyScript::Timer_Expired(GameObject *obj,int number)
{
   if(number == 123)
   {
      int startarray = lastid + 1;
      if (startarray > 127)
      {
           startarray = 0;
      }
      for (int x = startarray,end = 0;x < 128 && end == 0;x++)
      {
         
         if (playerid[x] != 0)
         {
              GameObject *enterer = Commands->Find_Object(playerid[x]);
              playerid[x] = 0;
              end = 1;
         }
         if (x == lastid)
         {
              end = 1;
         }
         if (x == 127)
         {
             x = 0;
         }
      }
   }
}


void MyScript::Register_Auto_Save_Variables()
{
	Auto_Save_Variable(1,4,&playerid);
	Auto_Save_Variable(1,4,&lastid);
}


Lol, forgot the whole point of all my code, make it check if there is already a timer running for your soldier, lol, with out that check you may as well make the timer send the ID of the soldier as the number and then just have it get the id's when expired by the number lol.


[Updated on: Wed, 11 February 2009 10:14]

Report message to a moderator

Re: Timer_Expired [message #371598 is a reply to message #371542] Wed, 11 February 2009 09:33 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
Part of my Enter script:

Toggle Spoiler


My Timer_Expired part:

Toggle Spoiler


This is now.

EDIT: Kill_All_Building_By_Team is no option when it is a map without buildings... (duhu) Anyone who could tell me an alternative for ConsoleInput so it will also work when not running a dedicated server??

EDIT2: Sorry if some things are really n00bish. This is my first script Razz


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Wed, 11 February 2009 11:41]

Report message to a moderator

Re: Timer_Expired [message #371790 is a reply to message #371542] Thu, 12 February 2009 10:40 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Just use the Custom system instead, make it send a custom to itself with an x second delay and put the players ID as the parameter to the custom. Easy.

http://steamsignature.com/card/1/76561197975867233.png
Re: Timer_Expired [message #371843 is a reply to message #371542] Thu, 12 February 2009 14:45 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
Sorry can you tell me how i would send to itself?? What would i call for that??
I know what you mean with the second part Big Ups


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Thu, 12 February 2009 14:53]

Report message to a moderator

Re: Timer_Expired [message #371856 is a reply to message #371790] Thu, 12 February 2009 16:06 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3813
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
danpaul88 wrote on Thu, 12 February 2009 10:40

Just use the Custom system instead, make it send a custom to itself with an x second delay and put the players ID as the parameter to the custom. Easy.

Kind of removes the whole delay part though...


Re: Timer_Expired [message #371858 is a reply to message #371856] Thu, 12 February 2009 16:17 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Jerad Gray wrote on Thu, 12 February 2009 23:06

danpaul88 wrote on Thu, 12 February 2009 10:40

Just use the Custom system instead, make it send a custom to itself with an x second delay and put the players ID as the parameter to the custom. Easy.

Kind of removes the whole delay part though...


Quote:

typedef void (*_Send_Custom_Event) (GameObject *Sender,GameObject *Reciever,int Message,int Param,float Delay);


Highlighting added for emphasis. Why else do you think the Send_Custom_Event takes a delay parameter if not to delay the delivery of the custom?



Example;
float delay = 10.0f;   // delay in seconds
int message = 12345;  // unique message code to identify this from other customs
int param = Get_Player_ID( enter );  // ID of player (use Commands->Get_ID(obj) to get the player object ID, which is probably what you really need)
Commands->Send_Custom_Event ( obj, obj, message, param, delay );



No need to create the variables, you can condense it into a single line statement, I added them for clarity only. You need to decide if you want to send the player ID (as seen from FDS) or the player's object ID (which also makes it work for AI units and makes it easy to cancel triggering if the player died before the delay was triggered)


http://steamsignature.com/card/1/76561197975867233.png

[Updated on: Thu, 12 February 2009 16:30]

Report message to a moderator

Re: Timer_Expired [message #371965 is a reply to message #371542] Fri, 13 February 2009 11:48 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
Seems to be a very good option Big Ups

Only one thing... (kinda stupid xD) What do i call to receive the custom??


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg

[Updated on: Fri, 13 February 2009 11:56]

Report message to a moderator

Re: Timer_Expired [message #371969 is a reply to message #371965] Fri, 13 February 2009 12:00 Go to previous messageGo to next message
Genesis2001
Messages: 1397
Registered: August 2006
Karma: 0
General (1 Star)
Omar007 wrote on Fri, 13 February 2009 11:48

Seems to be a very good option Big Ups

Only one thing... (kinda stupid xD) What do i call to receive the custom??



in the class defintion, add:

void Custom(GameObject *o, int msg, int param, GameObject *s);


where,

GameObject *o -> the game object that the script is attached to.
GameObject *s -> the game object that sent the custom
int msg -> the message that was sent
int param -> the parameter that was sent with 'msg'
Re: Timer_Expired [message #372533 is a reply to message #371542] Wed, 18 February 2009 04:08 Go to previous messageGo to next message
Omar007 is currently offline  Omar007
Messages: 1711
Registered: December 2007
Location: Amsterdam
Karma: 0
General (1 Star)
Thanks all Big Ups
With this info im going to rewrite the script. Was kinda busy with school but i hope tomorrow i can modify it Big Grin

BTW sorry for the late responce Blush


http://tiberiumredux.omarpakker.nl/Old Unused Parts/Plaatjes/PromoteBanner_Hades_small.jpg
Re: Timer_Expired [message #372653 is a reply to message #371858] Thu, 19 February 2009 16:02 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3813
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
danpaul88 wrote on Thu, 12 February 2009 16:17

Jerad Gray wrote on Thu, 12 February 2009 23:06

danpaul88 wrote on Thu, 12 February 2009 10:40

Just use the Custom system instead, make it send a custom to itself with an x second delay and put the players ID as the parameter to the custom. Easy.

Kind of removes the whole delay part though...


Quote:

typedef void (*_Send_Custom_Event) (GameObject *Sender,GameObject *Reciever,int Message,int Param,float Delay);


Highlighting added for emphasis. Why else do you think the Send_Custom_Event takes a delay parameter if not to delay the delivery of the custom?



Example;
float delay = 10.0f;   // delay in seconds
int message = 12345;  // unique message code to identify this from other customs
int param = Get_Player_ID( enter );  // ID of player (use Commands->Get_ID(obj) to get the player object ID, which is probably what you really need)
Commands->Send_Custom_Event ( obj, obj, message, param, delay );



No need to create the variables, you can condense it into a single line statement, I added them for clarity only. You need to decide if you want to send the player ID (as seen from FDS) or the player's object ID (which also makes it work for AI units and makes it easy to cancel triggering if the player died before the delay was triggered)

Either way you still have the same possible issue as you would with a timer, which my code is designed to go around, as in, you walk in the zone, out of the zone, back in, back out, back in, and then you get hit by 3 customs because you weren't checking to make sure there wasn't a custom delayed/timer running.


Re: Timer_Expired [message #372660 is a reply to message #371542] Thu, 19 February 2009 17:16 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
Depending on the effect of the custom, that might not matter.



PS: What *does* that Auto_Save_Variable thing actually DO anyway? I have yet to find anything that actually explains it's function. How is it different to just having a variable inside the scripts class to store the value?


http://steamsignature.com/card/1/76561197975867233.png
Re: Timer_Expired [message #372740 is a reply to message #372660] Fri, 20 February 2009 10:17 Go to previous messageGo to next message
jnz is currently offline  jnz
Messages: 3396
Registered: July 2006
Location: 30th century
Karma: 0
General (3 Stars)
danpaul88 wrote on Fri, 20 February 2009 00:16

Depending on the effect of the custom, that might not matter.



PS: What *does* that Auto_Save_Variable thing actually DO anyway? I have yet to find anything that actually explains it's function. How is it different to just having a variable inside the scripts class to store the value?


I imagine it's to preserve the values if ever the script is deleted and recreated by the server. I can't think of any reason why the server would do this though.

[Updated on: Fri, 20 February 2009 10:20]

Report message to a moderator

Re: Timer_Expired [message #372741 is a reply to message #372660] Fri, 20 February 2009 10:24 Go to previous messageGo to next message
saberhawk
Messages: 1068
Registered: January 2006
Location: ::1
Karma: 0
General (1 Star)
danpaul88 wrote on Thu, 19 February 2009 19:16

Depending on the effect of the custom, that might not matter.



PS: What *does* that Auto_Save_Variable thing actually DO anyway? I have yet to find anything that actually explains it's function. How is it different to just having a variable inside the scripts class to store the value?


It's used to automatically save and restore certain variables should the script instance ever end up being saved or loaded.
Re: Timer_Expired [message #372746 is a reply to message #371542] Fri, 20 February 2009 10:45 Go to previous message
mrãçķz is currently offline  mrãçķz
Messages: 3069
Registered: August 2007
Karma: 0
General (3 Stars)
Permabanned for trying and failing DDoS
Just Edit ShaderHud and add a Counter to your Hud.
Previous Topic: Link To This Skin?
Next Topic: Script for aircrafts needed...
Goto Forum:
  


Current Time: Mon Dec 23 22:29:40 MST 2024

Total time taken to generate the page: 0.01640 seconds