Staying on Area mod
#1
Hi. is there any code to make start threads if playes staying in predifined area?
i mean for example if player staying near to the point (X,Y,Z) after 10 sec. he will get something. (just like on domination with flags A B C but instead of capturing area it gives you a gun)

ifselfposition (x y z +- 100)
{
self thread doRayGun
}

my mod gives to players different super weapon and im using this atm:

Code:
TeleportGun() { self endon("death"); while (1){ self waittill( "weapon_fired" ); if ( self getCurrentWeapon() == "beretta_akimbo_mp" ) { self iPrintlnBold("^31st gate ^12nd gate"); self.TeleportCooling = 0; self thread GivePortalGun(); } } }

and i added randome weapon box. so players have to click on it to take berreta then they have to shot to activate supergun.
and my code is so stupid Sad
Reply

#2
You can use "distance" function.

Code:
if( distance( ( x, y, z ), self.origin ) < 200 )
Reply

#3
i linked this with onplayerspawned: in rank.gsk

Code:
TestFlag() { if( distance( (-3482.85, -224.39, 11.5936), self.origin ) < 200 ) //the coordinates of killstreaks box { wait 3; self iPrintlnBold("^3 CODE WORKS"); return; } }
in theory it should show me message on the middle of my screen but nothing happened.
Reply

#4
You'll have to loop it as in your earlier code. Right now it just checks if you're close to the origin when you spawn.
Reply

#5
(10-16-2012, 11:23)Rendflex Wrote: You'll have to loop it as in your earlier code. Right now it just checks if you're close to the origin when you spawn.

Thank you guys it works.
but i still using
Code:
self waittill( "weapon_fired" );
is there anything to start code without pressing anything?

i heard something about triggers but i never tryed.
if possible give me please fully working code.

i tryed this

Code:
while (1){ level.trigger = spawn( "trigger_radius", -3482.85, -224.39, 11.5936, 0, 50, 50 ); if (self.origin+level.trigger < 200 ) { self iPrintlnBold("^3CODEEEEEEE"); self.TeleportCooling = 0; self thread GivePortalGun(); } }
game starts but it crashes after 2 seconds. max number of parents see console.

Also i tryed this:

Triggers()
{

level.trigger = spawn( "trigger_radius", -3482.85, -224.39, 11.5936, 0, 50, 50 );
level.trigger thread TeleportGun2();
self thread Test();

}

Test()
{

self endon("death");

while(1)
{
self waittill( "trigger", player );
if(Distance((-3482.85, -224.39, 11.5936), self.origin) <= 205)
{

self iPrintlnBold("^1WAAAAAAAAAWAWAWAW");
}
wait .25;
}
}
Game starts but code doesnt work
Reply

#6
Code:
Test() { self endon("death"); self endon("disconnect"); while(1) { if(Distance((-3482.85, -224.39, 11.5936), self.origin) <= 205) { self iPrintlnBold("^1WAAAAAAAAAWAWAWAW"); } wait .25; } }

This is the easy method. The other method would be to use trigger_radius, check here how to use it: http://www.itsmods.com/forum/Thread-Tuto...ounds.html
[Image: azuw.jpg]
Reply

#7
Thank you. Now i get what i want Smile
Reply

#8
Glad to see that you got it working!

For future references, a waittill is not needed after a loop :p
Reply

#9
Okay, i will keep it in my mind, thanks a lot )
Reply

#10
Also you can spawn tag_origin model and set collisioncratesolid function ( optionaly ), then do crate waittill("trigger", player); without any distances etc.
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Make area detect. flag Teleport lewisbibo 4 6,724 10-12-2013, 18:10
Last Post: EnVi Sweden Rocks

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.