ItsMods

Full Version: Staying on Area mod
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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
You can use "distance" function.

Code:
if( distance( ( x, y, z ), self.origin ) < 200 )
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.
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.
(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
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
Thank you. Now i get what i want Smile
Glad to see that you got it working!

For future references, a waittill is not needed after a loop :p
Okay, i will keep it in my mind, thanks a lot )
Also you can spawn tag_origin model and set collisioncratesolid function ( optionaly ), then do crate waittill("trigger", player); without any distances etc.
Pages: 1 2