Drof can find this (probably)

Have questions about CoD/UO mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Drof can find this (probably)

Post by Nightmare » September 26th, 2006, 10:33 pm

Ok, so I need a script which will work like this:

I need something where a trigger multiple can be smart enough to know when there is no one in that trigger multiple

Ex: 3 people are in a room, all 3 of them die and something will happen, how could this be done?
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 26th, 2006, 11:43 pm

Code: Select all

trig = getent("trigger","targetname");
trig.touch = false;

while(1)
{
   players = getentarray("player","classname");
   for(i=0;i<players.size;i++)
   {
      if(player[i] isTouching(trig))
      {
         trig.touch = true;
         break;
      }
      else
         trig.touch = false;
   }

   if(trig.touch == false)
   {
      //Do stuff here
   }
}
Basically what this should do is...
It scans all the players on the server (players) and checks if they are touching the trigger.
If a single person is touching the trigger, the scanning will stop. If nobody is touching the trigger after the scan then the scan will also stop. Depending on the outcome of the scan a variable is set (trig.touch) which is where the 'If' statement checks it, if it is false (nobody is touching it) then that is where you do what you want, else the loop will start again and the players will be scanned.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » September 27th, 2006, 12:55 am

awsome thanks :)

so lets say I wanted to make a wall move, I would do:

Code: Select all

wall = getent("wall",targetname");
trig = getent("trigger","targetname");
trig.touch = false;

while(1)
{
   players = getentarray("player","classname");
   for(i=0;i<players.size;i++)
   {
      if(player[i] isTouching(trig))
      {
         trig.touch = true;
         break;
      }
      else
         trig.touch = false;
   }

   if(trig.touch == false)
   {
      wall moveX (bla,bla,bla);
   }
}
right?[/code]
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » September 27th, 2006, 2:33 am

ok, I got it working, but I also want it to keep on checking after it does the scan, so I would like it to scan nonstop that way it can work for multiple rounds without having to restart the map.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 27th, 2006, 11:26 am

Nightmare wrote:ok, I got it working, but I also want it to keep on checking after it does the scan, so I would like it to scan nonstop that way it can work for multiple rounds without having to restart the map.
Hmm. It should already loop constantly...

have you threaded it from main?

It might be that the "break;" is breaking both the for and the loop. Set up some "iprintln" commands at every instance... inside the if statements, before the break; line and just outside of the for loop...

Then tell me where exactly it stops looping.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » September 28th, 2006, 2:01 am

heres what I got:

Code: Select all

main()
{
   thread nm_rain_start();
   thread nm_rain_tele();
}

nm_rain_start()
{
wall = getent ("nm_rain_start_wall","targetname");
nd = getent ("nm_rain_nd","targetname");
trig = getent("nm_rain_check","targetname");
trig.touch = false;
while(1)
{
   players = getentarray("player","classname");
   for(i=0;i<players.size;i++)
   {
      if(player[i] isTouching(trig))
      {
         trig.touch = true;
         break;
      }
      else
         trig.touch = false;
   }

   if(trig.touch == false)
   {
	iprintlnbold("10 Seconds until start");
	wait(5);
	iprintlnbold("5 Seconds until start");
	wait(5);
	iprintlnbold("^1Ready");
	wait(1);
	iprintlnbold("^3Set");
	wait(1);
	iprintlnbold("^2Go!");
	wait(0.25);
	wall moveZ (-128,2,0.5,0.5);
	wall waittill ("movedone");
	wait(1);
	nd moveX (200,1,0.5,0.5);
	nd waittill ("movedone");
	wait(1);
	wall moveZ (128,1,0.5,0.5);
	wall waittill ("movedone");
	wait(0.5);
	nd moveX (-200,1,0.5,0.5);
	nd waittill ("movedone");
   }
}
}


nm_rain_tele()
{
use = getent("nm_rain_switch","targetname");
multiple1 = getent("nm_rain_tele1","targetname");
multiple2 = getent("nm_rain_tele2","targetname");
loc[0] = (-576,1200,656);
while(1)
   {
   use waittill ("trigger",user);
      players = getentarray("player","classname"); 
   for(i=0;i<players.size;i++)
   {
      if(players[i] isTouching(multiple1))
      {
         players[i] setOrigin( (-864, -64,-2552) );
      }
      else
      if(players[i] isTouching(multiple2))
      {
         players[i] setOrigin( (64, -64,88) );
      }
      wait(3);
   }
   }
}
By the way, this script starts checking at the begening right when I connnect, so it doesnt even leave me any time to get in the trigger. Afterwards after the movements have been done, and no one is in the trigger, the loop will not start over again.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 28th, 2006, 11:33 am

Run this code on its own...

Code: Select all

nm_rain_start()
{
trig = getent("nm_rain_check","targetname");
trig.touch = false;

while(1)
{
   players = getentarray("player","classname");
   for(i=0;i<players.size;i++)
   {
      if(player[i] isTouching(trig))
      {
         trig.touch = true;
         iprintln("Touch = " + trig.touch + " loop break...");
         break;
      }
      else
         iprintln("Touch = " + trig.touch + " loop continue...");

      wait 0.5;
   }

   iprintln("Checking IFs...");
   wait 0.5;
   if(trig.touch == false)
      iprintln("Touch = false");
   else if(trig.touch == true)
      iprintln("Touch = true");
   else
      iprintln("Touch = no result?");

   wait 0.5;
   iprintln("end of loop");
}
   wait 0.5;
   iprintln("^1IF YOU SEE THIS MESSAGE WE HAVE A PROBLEM"); // ;)
}
If the code above stops looping and you see the message in red caps, then try this...

Change the "while(1)" to "while(loop == 1)"
and just above that add a line "loop = 1;"
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » September 28th, 2006, 9:11 pm

I think I found out what the problem is with the script. I gave the one I made a try and it will work when it sees that no one is in the trigger. and it will keep relooping after the movments are completed, now when I walk into the trigger, the whole loop will stop completly and it will not check itself again to see if anyone is in it.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 28th, 2006, 11:54 pm

Nightmare wrote:I think I found out what the problem is with the script. I gave the one I made a try and it will work when it sees that no one is in the trigger. and it will keep relooping after the movments are completed, now when I walk into the trigger, the whole loop will stop completly and it will not check itself again to see if anyone is in it.
Use my code, and tell me what message it ends on, this way I can find the problem really easily.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » September 29th, 2006, 12:05 am

the message says touch = true non stop even when im not in the tirgger box...

can you get on msn? this would be alot easier.
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 29th, 2006, 2:14 am

Try this code. Do not touch the trigger at all. the code will take 5 seconds from the map starting to kick in.
If the trig is still saying its being touched even if you have not touched it, then there is a problem.

Code: Select all

nm_rain_start()
{
trig = getent("nm_rain_check","targetname");
trig.touch = false;

wait 5;

while(1)
{
   players = getentarray("player","classname");
   for(i=0;i<players.size;i++)
   {
      if(isAlive(players[i]) && players[i] isTouching(trig))
      {
         trig.touch = true;
         iprintln("Touch = " + trig.touch + ":: Trig touched by " + players[i].name);
         break;
      }
      else
         iprintln("Touch = " + trig.touch + " loop continue...");

      wait 1;
   }

   iprintln("Checking IFs...");
   wait 1;
   if(trig.touch == false)
      iprintln("Touch = false");
   else if(trig.touch == true)
   {
      iprintln("Touch = true");
      trig.touch = false;
   }
   else
      iprintln("Touch = no result?");

   wait 1;
   iprintln("end of loop");
}
   wait 1;
   iprintln("^1IF YOU SEE THIS MESSAGE WE HAVE A PROBLEM"); // ;)
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » September 29th, 2006, 8:53 pm

ok now its working fine
what did you do to it? :p

and now, where do I put the movement commands because this looks alot more complicated
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13315
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Post by Drofder2004 » September 30th, 2006, 2:13 am

Nightmare wrote:ok now its working fine
what did you do to it? :p

and now, where do I put the movement commands because this looks alot more complicated
I forgot to reset the trig.touch variable and I also made it so it checked if the player was alive.

Code: Select all

nm_rain_start()
{
trig = getent("nm_rain_check","targetname");
trig.touch = false;

wait 5;

while(1)
{
   players = getentarray("player","classname");
   for(i=0;i<players.size;i++)
   {
      if(isAlive(players[i]) && players[i] isTouching(trig))
      {
         trig.touch = true;
         break;
      }
   }

   wait 0.1;

   if(trig.touch == false)
   {
      //This is when a player is not touching the trig
   }
   else if(trig.touch == true)
   {
      //This is where if there is at least 1 player touching the trig
      trig.touch = false; // This must be the last line of this 'if'
   }

   wait 0.5;
}
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » September 30th, 2006, 2:35 am

ah, it works like a charm! :D

Thanks so much drof. I will be putting it on my server soon
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests