spownpoints problem

Post your scripting questions / solutions here

Moderator: Moderators

SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

doesn't work :cry:
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Console? What? How?

Did you put it in a while statement?
It could be your code, your logic seems like it would fail.
vector_within would be a lot more effective here.

vector_within [Centre] [Vector to Check] [Distance]
So the player's origin would be the Vector to Check. So what does vector_within do exactly? Well it checks if the player's origin is within the radius (=distance) of the centre. I'm positive, this is more effective than checking the Y value of the player's origin.

If the player's within the radius, this command will return 1, if not then it will return 0. Therefor you must either use this in an if statement or make a variable equal this command.


Code: Select all

if ( (vector_within local.centre local.player.origin 50) == 1)
or

Code: Select all

local.o = vector_within local.centre local.player.origin 50
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

I think I've found the problem of my script...
well..
the script is run everytime a player respawn and it's related to himself and not for all players..so maybe the problem is the FOR statemant..hummm..can be so?
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Well I have no idea if you don't answer my questions.
What did the console say?
Did you put this script in a while loop?
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

problem fixed..
well I didn't put it in a while loop, becouse it's executed everytime you spawn...so there's no need..anyway, the script seems not be executed when I cross this trigger:

Code: Select all

local.trig = spawn trigger_multiple
local.trig.origin = ( 2921 3266 969 ) 
local.trig setsize ( -21704 -1 -10000 ) ( 21704 1 10000 ) 
local.trig setthread Trigger1
local.trig message "NO CROSS!"
local.trig wait 0
local.trig delay 0 



Trigger1:
local.player=parm.other
if (local.player.isTrigger1==1) 



local.player.isTrigger1=1 
local.player respawn
local.player.isTrigger1=0 
end
So I've toke away the trigger and I've added this while loop:

Code: Select all

while (1)
{
     for (local.i = 1; local.i <= $player.size; local.i++) 
     {
           if ($player[local.i].origin[1] > 3266 || $player[local.i].origin[1] < -2116 )
           {
                 if ($player[local.i].dmteam == "axis")
                 {
                       self iprint "NO CROSS"
                       $player[local.i] tele local.gavutu_ax_sp[(randomint 4)]
                 }
           }
           if ($player[local.i].origin[1] < 3266)
           {
                 if ($player[local.i].dmteam == "allies")
                 {
                       self iprint "NO CROSS"
                       $player[local.i] tele local.gavutu_al_sp[(randomint 4)]
                 }
           }
     }
     wait 0.3
}
end
So..now when you cross origin[1] = 3266 you get teleported where I want and if you spawn (after been killed for exemple) you still get teleported becouse this script :

Code: Select all

main:

// teleport dest. arrays

local.gavutu_ax_sp[0] = ( 4495.99 -247.81 391.78 )
local.gavutu_ax_sp[1] = ( 5699.76 1006.68 408.69 )
local.gavutu_ax_sp[2] = ( 5954.04 -706.98 399.67 )
local.gavutu_ax_sp[3] = ( 5981.32 1048.26 408.69 )

local.gavutu_al_sp[0] = ( 632.23 7154.51 555.71 )
local.gavutu_al_sp[1] = ( 416.08 3397.52 441.27 )
local.gavutu_al_sp[2] = ( -427.86 6841.89 479.13 )
local.gavutu_al_sp[3] = ( 1823.51 5273 359.19 )

// magic number

local.rand_int = randomint 4

// Switcher

    if (local.rand_int == 0)
    {
        if ($player.origin[1] > 3266 || $player.origin[1] < -2116 ) 
        {
            if ($player.dmteam == "axis") 
            {
                $player tele local.gavutu_ax_sp[0]
            }
        }
        if ($player.origin[1] < 3266) 
        {
            if ($player.dmteam == "allies") 
            {
                $player tele local.gavutu_al_sp[0]
            }
        }
    }
    if (local.rand_int == 1)
    {
        if ($player.origin[1] > 3266 || $player.origin[1] < -2116 ) 
        {
            if ($player.dmteam == "axis") 
            {
                $player tele local.gavutu_ax_sp[1]
            }
        }
        if ($player.origin[1] < 3266) 
        {
            if ($player.dmteam == "allies") 
            {
                $player tele local.gavutu_al_sp[1]
            }
        }
    }
    if (local.rand_int == 2)
    {
        if ($player.origin[1] > 3266 || $player.origin[1] < -2116 ) 
        {
            if ($player.dmteam == "axis") 
            {
                $player tele local.gavutu_ax_sp[2]
            }
        }
        if ($player.origin[1] < 3266) 
        {
            if ($player.dmteam == "allies") 
            {
                $player tele local.gavutu_al_sp[2]
            }
        }
    }
    if (local.rand_int == 3)
    {
        if ($player.origin[1] > 3266 || $player.origin[1] < -2116 ) 
        {
            if ($player.dmteam == "axis") 
            {
                $player tele local.gavutu_ax_sp[3]
            }
        }
        if ($player.origin[1] < 3266) 
        {
            if ($player.dmteam == "allies") 
            {
                $player tele local.gavutu_al_sp[3]
            }
        }
    }
end    
is executed when you spawn...
Everything seems working good..but I still have some doubts...
while (1)
{
for (local.i = 1; local.i <= $player.size; local.i++)
{
if ($player[local.i].origin[1] > 3266 || $player[local.i].origin[1] < -2116 )
{
if ($player[local.i].dmteam == "axis")
{
self iprint "NO CROSS"
$player[local.i] tele local.gavutu_ax_sp[(randomint 4)]
}
}
if ($player[local.i].origin[1] < 3266)
{
if ($player[local.i].dmteam == "allies")
{
self iprint "NO CROSS"
$player[local.i] tele local.gavutu_al_sp[(randomint 4)]
}
}
}
wait 0.3
}
end
If 2 players cross origin = 3266 at the same time..they will be teleported exectly in the same place..if this happend they will get stuck!! How can I prevent this problem?
I was thinking about make more index for exemple [local.i] [local.e]..and make the script teleport $player[local.i] and $player[local.e] in differents places. (using 2 for satement)
I'm asking you if it will works becouse I can't try it now becouse I've got some problems and cannot do it right now... :cry:
So you think it's a good idea or not?
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

I'll tell you how, but I'm confused, which script is the one you're using and that's working???
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

:lol: you're right, I'm not so good in explanations! :lol:
however, The map run 2 scripts:
this one:

Code: Select all

main: 

// teleport dest. arrays 

local.gavutu_ax_sp[0] = ( 4495.99 -247.81 391.78 ) 
local.gavutu_ax_sp[1] = ( 5699.76 1006.68 408.69 ) 
local.gavutu_ax_sp[2] = ( 5954.04 -706.98 399.67 ) 
local.gavutu_ax_sp[3] = ( 5981.32 1048.26 408.69 ) 

local.gavutu_al_sp[0] = ( 632.23 7154.51 555.71 ) 
local.gavutu_al_sp[1] = ( 416.08 3397.52 441.27 ) 
local.gavutu_al_sp[2] = ( -427.86 6841.89 479.13 ) 
local.gavutu_al_sp[3] = ( 1823.51 5273 359.19 ) 

// magic number 

local.rand_int = randomint 4 

// Switcher 

    if (local.rand_int == 0) 
    { 
        if ($player.origin[1] > 3266 || $player.origin[1] < -2116 ) 
        { 
            if ($player.dmteam == "axis") 
            { 
                $player tele local.gavutu_ax_sp[0] 
            } 
        } 
        if ($player.origin[1] < 3266) 
        { 
            if ($player.dmteam == "allies") 
            { 
                $player tele local.gavutu_al_sp[0] 
            } 
        } 
    } 
    if (local.rand_int == 1) 
    { 
        if ($player.origin[1] > 3266 || $player.origin[1] < -2116 ) 
        { 
            if ($player.dmteam == "axis") 
            { 
                $player tele local.gavutu_ax_sp[1] 
            } 
        } 
        if ($player.origin[1] < 3266) 
        { 
            if ($player.dmteam == "allies") 
            { 
                $player tele local.gavutu_al_sp[1] 
            } 
        } 
    } 
    if (local.rand_int == 2) 
    { 
        if ($player.origin[1] > 3266 || $player.origin[1] < -2116 ) 
        { 
            if ($player.dmteam == "axis") 
            { 
                $player tele local.gavutu_ax_sp[2] 
            } 
        } 
        if ($player.origin[1] < 3266) 
        { 
            if ($player.dmteam == "allies") 
            { 
                $player tele local.gavutu_al_sp[2] 
            } 
        } 
    } 
    if (local.rand_int == 3) 
    { 
        if ($player.origin[1] > 3266 || $player.origin[1] < -2116 ) 
        { 
            if ($player.dmteam == "axis") 
            { 
                $player tele local.gavutu_ax_sp[3] 
            } 
        } 
        if ($player.origin[1] < 3266) 
        { 
            if ($player.dmteam == "allies") 
            { 
                $player tele local.gavutu_al_sp[3] 
            } 
        } 
    } 
end    
is exec only when only players spown.

and this one:

Code: Select all

while (1) 
{ 
     for (local.i = 1; local.i <= $player.size; local.i++) 
     { 
           if ($player[local.i].origin[1] > 3266 || $player[local.i].origin[1] < -2116 ) 
           { 
                 if ($player[local.i].dmteam == "axis") 
                 { 
                       self iprint "NO CROSS" 
                       $player[local.i] tele local.gavutu_ax_sp[(randomint 4)] 
                 } 
           } 
           if ($player[local.i].origin[1] < 3266) 
           { 
                 if ($player[local.i].dmteam == "allies") 
                 { 
                       self iprint "NO CROSS" 
                       $player[local.i] tele local.gavutu_al_sp[(randomint 4)] 
                 } 
           } 
     } 
     wait 0.3 
} 
end
is run in a costant loop..my problem is with this scr.
with this script, when 2 players coord 3266 at the same time the would be teleported in the same place and they would get stuck..I need to fix that so the 2 players would be teleported in different places..
I thought to use 2 for statement..for exemple:

Code: Select all

while (1)
{
    for (local.i = 1; local.i = $player.size; local.i++)
    {
         for (local.e = 1; local.e = $player.size; local.e++)
         {
               if ($player[local.i] != $player[local.e]
               {
                     if ($player[local.i].origin[1] > 3266 || $player[local.i].origin[1] < -2116 || $player[local.e].origin[1] > 3266 || $player[local.e].origin[1] < -2116 )
                      {
                             if ($player[local.i].dmteam == "axis" || if ($player[local.e].dmteam == "axis") 
                             {
                                   $player[local.i] tele local.gavutu_ax_sp[(randomint 4)] 
                                   $player[local.e] tele local.gavutu_ax_sp[(randomint 4)] 
                             }
                      }
                      if ($player[local.i].origin[1] < 3266 || $player[local.e].origin[1] < 3266)
                      {
                             if ($player[local.i].dmteam == "allies" || $player[local.e].dmteam == "allies")
                             {
                                    $player[local.i] tele local.gavutu_al_sp[(randomint 4)] 
                                    $player[local.e] tele local.gavutu_al_sp[(randomint 4)] 
                             }
                      }
                }
         }
    }
    wait 0.2
}
end
is it possible to do somthing like that?
Also I think that a script like this wont work in just one player cross..but I'm not sure of that (I just wrote down the first code I thought..lol).
I can't try becouse I lost my CD, so I'm looking for it right now! lol
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

That won't be a problem. Since there are 4 randomly chosen spots players tele to. If players cross the line at the same time, both will be teleported.

If for some coincidence, both end up teleported to the same spot then they can get stuck.

Perhaps try this:

Code: Select all

while (1)
{
     for (local.i = 1; local.i <= $player.size; local.i++)
     {
           if ($player[local.i].origin[1] > 3266 || $player[local.i].origin[1] < -2116 )
           {
                 if ($player[local.i].dmteam == "axis" && s$player[local.i].being_tele != 1)
                 {
                       thread telep $player[local.i] local.gavutu_ax_sp
                 }
           }
           if ($player[local.i].origin[1] < 3266)
           {
                 if ($player[local.i].dmteam == "allies" && s$player[local.i].being_tele != 1)
                 {
                       thread telep $player[local.i] local.gavutu_al_sp
                 }
           }
     }
     wait 0.3
}
end

telep local.p local.dest:

          local.p.being_tele = 1

          for (local.i = 1; local.i <= local.dest.size; local.i++)
          {
                 for (local.o = 1; local.o <= $player.size; local.o++)
                 {
                        if ( (vector_within local.dest[local.i] $player[local.o].origin 10) != 1)
                         {
                                 local.p.being_tele = NIL
                                 local.p iprint "NO CROSS"
                                 local.p tele local.dest[local.i]
                         }
                  }
            }

            local.p.being_tele = NIL
end
The only way this script can fail is if all teleport destinations are occupied by other players. The chance of this happening is extremely small and almost nihil.
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

ok..when I found the cd I'll try your scr..it seems good for my problem.. :wink:
however, could you explain to me how this scr is made? for exemple..

Code: Select all

thread telep $player[local.i] local.gavutu_al_sp 
why there's not need of randomint?
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

I just passed on the player and the array with the teleport destinations to a new thread. In that new thread I check every origin in that array to see if one is clear (so there are no players on it). If so then I teleport that player to that spot.
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

genious! :wink:
Post Reply