spownpoints problem

Post your scripting questions / solutions here

Moderator: Moderators

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

spownpoints problem

Post by SilentAngel »

this is the script I've made:

Code: Select all

local.dm_teleax = ( 5826.08 -2580.43 245.45 )::( -1817.17 -4229.18 206.21 )
local.dm_teleal = ( 3305.79 5284.85 192.35 )::( -1921.29 6269.79 249.59 )

if (local.player.origin[2] > 359)
{
 if (local.player.dmteam == "axis")
 {
  if ($player[local.i].origin = local.dm_teleax[1])
  {
   local.player tele local.dm_teleax[2]
  }
  else
  {
   local.player tele local.dm_teleax[1]
  }
 }
}
if (local.player.origin[2] < 359)
{
 if (local.player.dmteam == "allied")
 {
  if ($player[local.i].origin = local.dm_teleal[1])
  {
   local.player tele local.dm_teleal[2]
  }
  else
  {
   local.player tele local.dm_teleal[1]
  }
 }
}
end




local.trig1 = spawn trigger_multiple
local.trig1.origin = local.dm_teleax[1] 
local.trig1 setsize ( -10 -10 -10 ) ( 10 10 10 ) 
local.trig1 setthread Trigg1
local.trig1 message "Please change spot, you're in a spownpoint!!"
local.trig1 wait 0
local.trig1 delay 0 

Trigg1:
local.player=parm.other
if (local.player.isTrigg1==1) 

local.player.isTrigg1=1 
goto trigg1
local.player.isTrigg1=0 
end




local.trig2 = spawn trigger_multiple
local.trig2.origin = local.dm_teleax[2] 
local.trig2 setsize ( -10 -10 -10 ) ( 10 10 10 ) 
local.trig2 setthread Trigg2
local.trig2 message "Please change spot, you're in a spownpoint!!"
local.trig2 wait 0
local.trig2 delay 0 

Trigg2:
local.player=parm.other
if (local.player.isTrigg2==1) 

local.player.isTrigg2=1 
goto trigg2
local.player.isTrigg2=0 
end




local.trig3 = spawn trigger_multiple
local.trig3.origin = local.dm_teleal[1] 
local.trig3 setsize ( -10 -10 -10 ) ( 10 10 10 ) 
local.trig3 setthread Trigg3
local.trig3 message "Please change spot, you're in a spownpoint!!"
local.trig3 wait 0
local.trig3 delay 0 

Trigg3:
local.player=parm.other
if (local.player.isTrigg3==1) 

local.player.isTrigg3=1 
goto trigg3
local.player.isTrigg3=0 
end




local.trig4 = spawn trigger_multiple
local.trig4.origin = local.dm_teleal[2] 
local.trig4 setsize ( -10 -10 -10 ) ( 10 10 10 ) 
local.trig4 setthread Trigg4
local.trig4 message "Please change spot, you're in a spownpoint!!"
local.trig4 wait 0
local.trig4 delay 0 

Trigg4:
local.player=parm.other
if (local.player.isTrigg4==1) 

local.player.isTrigg4=1 
goto trigg4
local.player.isTrigg4=0 
end

it seems not works..
however I've got the map divided into 2 parts (one allied, one axis).
the line that cannot be crossed is ( -1329 359 405 ).
I've already made the trigger that do not allow you to cross from a side to the other, but now I have spownpoints problems.
there are a lot of axis spownpoints that are in allied side too, and vice-versa. I've made this script to respown axis players in axis side and allied players in allied side, but do not works..why? :roll:
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Code: Select all

  if ($player[local.i].origin = local.dm_teleal[1]) 
If statements must always have double equation tokens: ==

Code: Select all

 if (local.player.dmteam == "allied") 
The .dmteam property can only contain: "allies", "axis", "spectator" or "freeforall".

Code: Select all

local.trig3.origin = local.dm_teleal[1] 
local.trig2.origin = local.dm_teleax[2] 
local.trig1.origin = local.dm_teleax[1] 
local.trig4.origin = local.dm_teleal[2] 
This makes no sense because you ended the thread where local.dm_teleax and local.dm_teleal were defined, therefor they are NIL in your new thread.

Code: Select all

local.dm_teleax = ( 5826.08 -2580.43 245.45 )::( -1817.17 -4229.18 206.21 )
local.dm_teleal = ( 3305.79 5284.85 192.35 )::( -1921.29 6269.79 249.59 )
//......
  else
  {
   local.player tele local.dm_teleal[1]
  }
 }
}
end // <------- here


local.trig1 = spawn trigger_multiple
local.trig1.origin = local.dm_teleax[1] 
Who is local.player? Did you define it before?

Perhaps try this script, it should work if I understood properly what you are trying to achieve:

Code: Select all

correction:

local.dm_teleax = ( 5826.08 -2580.43 245.45 )::( -1817.17 -4229.18 206.21 )
local.dm_teleal = ( 3305.79 5284.85 192.35 )::( -1921.29 6269.79 249.59 )

while(1)
{
         for (local.i = 1; local.i <= $player.size; local.i++)
         {
                   if ( (vector_within local.dm_teleax[1] $player[local.i].origin 25) == 1 && $player[local.i].dmteam == "axis")
                   {
                             $player[local.i] iprint "Please change spot, you're in a spawnpoint!!" 
                             $player[local.i] tele local.dm_teleax[2]
                   }
                   if ( (vector_within local.dm_teleal[1] $player[local.i].origin 25) == 1 && $player[local.i].dmteam == "allies")
                   {
                             $player[local.i] iprint "Please change spot, you're in a spawnpoint!!" 
                              $player[local.i] tele local.dm_teleal[2]
                   }
          }
wait 0.3
}
end
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 »

OMG! I've made a mistake..this post should be in PA not AA! sorry.... :oops: :oops:
however, ty for the corrections SOR..
I tried your script but don't works, probably becouse there's something different from AA to PA..however now I'll correct mine and see the results..ty :wink:
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

supposing that I have a coord like this:
( 111 222 333 )

in this case, I'm sure that $player[local.i].origin[1] is 111, so [2] should be 222, isn't it?


if ( (vector_within local.dm_teleax[1] $player[local.i].origin 25) == 1 && $player[local.i].dmteam == "axis")
what "vector_within" and "origin 25" are?
Condor
Colour Sergeant
Posts: 82
Joined: Mon Apr 09, 2007 3:19 pm
Location: Bavaria (Germany)

Post by Condor »

I guess the lowest index of an array is usually zero. Try it out ^^
...waking up in the middle of the night with your hands covered in blood and you have no idea what happened.
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

humm I had a look at a mod that I was running some time ago and I found this:

if ($player[local.i].origin[1] > 1400)

and that mod was for a no cross so that players with north/south coord over 1400 get killed..and the mod worked beautifully so should be 1 the lower index for a variable..and as a logical deduction (..almost I hope..) the second variable of the arrey should be [2]..but that's givin me problems..
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Index 0 is the X axis (east-west).

Index 1 is the Y axis (north-south).

Index 2 is the Z axis (up-down).

kthxbai.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

hahaha that's soo strange..it's 012 but when you get coords is 102
that's cofusing me? humm I was trying right now with 0 as Condor advices me and it works..ty
ty Rookie too to make it more clear! :wink:
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

however that's fixed in PA..
AA coords was ( 1 0 2 )
PA coords is ( 0 1 2 )
that's have more sense I think lol ^^
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Here's a brief tutorial explaining almost everything you need to know about arrays. Except working with them, that's more complicated. But once you understand the use of arrays and how to work with them, you will keep using them.

Arrays

Introdution
It might seem strange but it's quite logical. You start at the lowest non-negative number. And that's 0.

What's not logical is that this rule is only applied when dealing with vector arrays and string arrays. However constant arrays, targetname arrays and arrays made using makeArray all start at 1.

And the logical mind would also prefer starting at 1 instead of 0 when creating arrays (which is as simple as pie, just add a box you want to define and declare like you would a variable):

Code: Select all

local.myarray[1] = 56
But there are many other ways and many kinds of arrays.

Kinds of Arrays
Examples of vector and string arrays:

Code: Select all

local.myvector = ( 5 6 9 )
local.mystring = "hello"
So:

Code: Select all

local.myvector[0] = 5
local.myvector[1] = 6
local.myvector[2] = 9

local.mystring[0] = "h"
local.mystring[1] = "e"
local.mystring[2] = "l"
local.mystring[3] = "l"
local.mystring[4] = "o"
Constant array:

Code: Select all

local.myarray = 5::6::9
So:

Code: Select all

local.myarray[1] = 5
local.myarray[2] = 6
local.myarray[3] = 9
Targetname array:

Code: Select all

local.o = spawn script_origin "targetname" "object"
local.b = spawn script_object "targetname" "object"
local.p = spawn script_model "targetname" "object"
So:

Code: Select all

$object[1] = script_origin
$object[2] = script_object
$object[3] = script_model

Example of makeArray (these are 2-dimensional):
The first dimension represents the Xth row, the second dimension represents the Xth value of that row.

Code: Select all

local.myarray = makeArray
1 2 3 
4 5 6 
7 8 9
endArray
So:

Code: Select all

local.myarray[1][1] = 1
local.myarray[1][2] = 2
local.myarray[1][3] = 3
local.myarray[2][1] = 4
local.myarray[2][2] = 5
local.myarray[2][3] = 6
local.myarray[3][1] = 7
local.myarray[3][2] = 8
local.myarray[3][3] = 9
makeArray may seem confusing at first but it can be very helpful and efficient.

Sizes
Each variable has the .size property. The .size property does not give the total size! Only the size of the dimension you specify.

Code: Select all

local.vector = ( 1 2 3 )
local.string = "hello"
local.example = 5
local.array[1] = 6
local.newarray[1][1] = 7
local.newarray[1][2] = 6
local.newarray[2][1] = 1
local.model = spawn script_model "targetname" "object"
So:

Code: Select all

local.sthing.size = -1 //uninitialized variables have a negative size -1
local.vector.size = 3 //despite starting from 0, the vector still has 3 variables
local.string.size = 5 //despite starting from 0, the string still has 5 variables

local.example.size = 1 
local.example[1].size = -1 //uninitialized variables have a negative size -1
local.array.size = 1
local.array[1].size = 1
local.newarray.size = 2
local.newarray[1].size = 2
local.newarray[2].size = 1

$object.size = 1 //there's 1 object
$another_object.size = 0 //inexistent objects' sizes equals 0
local.model.size = 1 //local.model equals the spawned object, so the size is 1 and it must be checked for NULL, because NIL is for variables
Array Flexibility
Arrays don't always need to contain positive numbers, you can use negatives as well. Of course you must be prepared to handle/parse them like that (in your for statements).

Code: Select all

local.myarray[ -1] = 5
The size is logically 1.

Code: Select all

local.myarray[ -1] = 5
local.myarray[ -2] = 16
The size is now 2 and so on.

You can also use strings. I don't know how people call them but I call them stringbox arrays:

Code: Select all

local.array["text"] = 6
local.array["other_text"] = 1
The size is 2...and so on. I think you get the picture.

Array Possibilities
Arrays do not only contain numbers, they can contain vectors, strings, spawned object...etc... everything normal local., group., level. and game. objects can do.

Examples

Code: Select all

local.array["text"] = ( 2 1 5 )
local.ar[1][2] = "hello"
local.ray[ -1] = spawn script_model model "fx/dummy.tik"
local.ray[ -1].origin = ( 25 678 -8 )
//so: local.ray[ -1].origin[1] =  678
Clearing Arrays and Entries
To clear array-entries simple equal that entry to NIL. Of course if that entry has spawned an object, then delete it. To clear an entire array, equal the main variable to NIL.

Examples:

Code: Select all

local.a[1][1] = spawn script_object

local.b[2][3] = 1

local.c[1][1] = 56
local.c[1][2] = 7
local.c[1][3] = 8
local.c[2][1] = 22
Now let's clear them:

Code: Select all

//when an entry represents an object:
local.a[1][1] delete
// if it contains values:
local.b[2][3] = NIL
//if you want to clear all entries:
local.c = NIL
Dimensions
You can set arrays with or without multiple dimensions just like this:

Code: Select all

local.a[1][5] = 1
It's that simple. Or you can use makeArray.
However local.a[1] = ?

Code: Select all

local.a[1] = anArray
Because there are 2-dimensions. You can add as many dimensions as you like but keeping it moderate is the key to efficiency.

Imagine:

Code: Select all

local.a = 2
Then what happens to local.a if I declare an array entry:

Code: Select all

local.a[2] = 5
Well local.a becomes an array meaning the value 2 is lost (actually overwritten). local.a[1] equals NIL and so do all other uninitialized entries in any dimension of this array.

Like I showed you earlier makeArray arrays always have a minimum of 2 dimensions. The first represents the Xth row, the second, the Xth value on that row.
local.a = makeArray
1 2
3 4
endArray
local.a[1][2]

Of course, there can be a lot more of dimensions!

Code: Select all

local.a = makeArray
((1::2)::3) 2
"hello" ( 445 65 -9 )
endArray
So:

Code: Select all

local.a[1][1] = Constant Array
local.a[1][1][1] = Constant Array
local.a[1][1][1][1] = 1
local.a[1][1][1][2] = 2
local.a[1][1][2] = 3
local.a[1][2] = 2
local.a[2][1] = String Array
local.a[2][1][0] = "h"
local.a[2][1][1] = "e"
local.a[2][1][2] = "l"
local.a[2][1][3] = "l"
local.a[2][1][4] = "o"
local.a[2][2] = Vector Array
local.a[2][2][0] = 445
local.a[2][2][1] = 65
local.a[2][2][2] = -9
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 »

wow! :o
that's amazing!
this tut is really useful!
good job man :wink:
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

how can I call a variable of an array randomly?

I tryed to do somthing similar to this:

Code: Select all

anarray1 = 11::12::13::14

local.rand_var = 1 randomint 5

iprintln "anarray1[local.rand_var]"
but didn't work...
well..I think the problem is 1randomint5...becouse I'm not sure that it can be written [int]randomint[int]...however if I write randomint 5 it will give me numbers from 0 to 4..and 0 in my case is not a valid number for the array!

So I've tried this one:

Code: Select all

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 )


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")
                             {
                                       $player[local.i] tele local.gavutu_ax_sp[randomint 4]
                             }
       }
       if ($player[local.i].origin[1] < 3266)
       {
                             if ($player[local.i].dmteam == "allies")
                             {
                                       $player[local.i] tele local.gavutu_al_sp[randomint 4]
                             }
}
end                    
still without results! so how I do that?
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Holy........!

Code: Select all

anarray1 = 11::12::13::14

local.rand_var = 1 randomint 5

iprintln "anarray1[local.rand_var]"
First of all, anarray1? Where's the local. or group. or level. or game.?
Did you practise C before or something?

Second, 1 randomint 5. What's the 1 doing there? Like I said in my tutorial, arrays have the extremely useful, cannot-live-without property .size. Simply use:

Code: Select all

local.rand_var = randomint (local.anarray1.size + 1)
And third, when you print variables, there may be no quotation marks else just "anarray1[local.rand_var]" will be printed. And again, where's the variable's prefix? (local, group, level, game??):

Code: Select all

iprintln local.anarray1[local.rand_var]

You must use scriptthread commands and syntax with brackets in arrays:

Code: Select all

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")
                             {
                                       $player[local.i] tele local.gavutu_ax_sp[(randomint (local.gavutu_ax_sp.size + 1))]
                             }
       }
       if ($player[local.i].origin[1] < 3266)
       {
                             if ($player[local.i].dmteam == "allies")
                             {
                                       $player[local.i] tele local.gavutu_al_sp[(randomint (local.gavutu_al_sp.size + 1))]
                             }
}
end  
And finally, this check gets executed only once in a split of a milisecond. Of course it doesn't work. Put it in a while loop with a reasonable wait, say 0.2.
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 »

anarray1 = 11::12::13::14

local.rand_var = 1 randomint 5

iprintln "anarray1[local.rand_var]"
That was an exemple..I didn't watch at all these stuff becouse of that! second..I'm studing C right now but MOH scr is a lot different ( even if it's similar for some aspects).

Code: Select all

local.rand_var = randomint (local.anarray1.size + 1)
yep, I've forgot .size existence :lol:
And third, when you print variables, there may be no quotation marks else just "anarray1[local.rand_var]" will be printed. And again, where's the variable's prefix? (local, group, level, game??):

Code: Select all

iprintln local.anarray1[local.rand_var]
I've already replayed to your question..I've made it as a quick exemple (without thinking at what's missing or not!)

...I don't see what you mean in the last part of the post...srry if I'm stupid man!!
and I cannot add it in a while statement for good reasons..so ot will be executed by another script at certain times during the game..
SilentAngel
Captain
Posts: 239
Joined: Wed Mar 12, 2008 8:27 pm

Post by SilentAngel »

oooh yeah now I've understood..I'll try..
Post Reply