ItsMods
Staying on Area mod - Printable Version

+- ItsMods (https://www.itsmods.com)
+-- Forum: Archive (https://www.itsmods.com/Forum-Archive.html)
+--- Forum: Archive (https://www.itsmods.com/Forum-Archive--64.html)
+--- Thread: Staying on Area mod (/Thread-Staying-on-Area-mod.html)

Pages: 1 2


Staying on Area mod - islamsaab - 10-15-2012

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


RE: Staying on Area mod - Yamato - 10-16-2012

You can use "distance" function.

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



RE: Staying on Area mod - islamsaab - 10-16-2012

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.


RE: Staying on Area mod - Rendflex - 10-16-2012

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.


RE: Staying on Area mod - islamsaab - 10-16-2012

(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


RE: Staying on Area mod - zxz0O0 - 10-16-2012

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-Tutorial-Trigger-Radius-Pingplayer-and-Ambient-Sounds.html


RE: Staying on Area mod - islamsaab - 10-16-2012

Thank you. Now i get what i want Smile


RE: Staying on Area mod - Rendflex - 10-16-2012

Glad to see that you got it working!

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


RE: Staying on Area mod - islamsaab - 10-16-2012

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


RE: Staying on Area mod - Nekochan - 10-16-2012

Also you can spawn tag_origin model and set collisioncratesolid function ( optionaly ), then do crate waittill("trigger", player); without any distances etc.