Page 1 of 1

Random targetname[level.a]

Posted: Sat Nov 27, 2004 11:41 pm
by Phil {sfx}
I am trying to add random nums to a targetname using a basic method, but its not working, anyone script wise shine a light on this.

Code: Select all

//local.me is player


    level.a = 1

    level.a++
    local.me = $me[level.a]   //should be now $me[2]

iprintlnbold (level.a)      // gives 2
local.namer = $me[level.a]
iprintlnbold (local.namer)  // gives NIL
For some reason its not adding my number. :x

Posted: Sun Nov 28, 2004 2:30 am
by Master-Of-Fungus-Foo-D
whats this scrap for :-/

Posted: Sun Nov 28, 2004 2:41 am
by Phil {sfx}
Your nosey arnt you. :roll:

If you dont know, you dont need to. lol

Posted: Sun Nov 28, 2004 3:04 am
by Grassy
Hi ya, is this for single player or multi?
Just off the top of my head I came up with this;

//--------------------
random_player_id: //for single player game
//--------------------
local.b = (randomint(20)+1)
waitframe
local.player = $player
local.player = local.player[local.b]
println "zz------ Player id is = " local.player
end


Grassy

Posted: Sun Nov 28, 2004 3:09 am
by Master-Of-Fungus-Foo-D
heh heh... nosey i am

$me

Posted: Sun Nov 28, 2004 3:41 am
by tltrude
"$me" will look for something targetname "me" in the map. If there is nothing that uses that name, it will return "NIL" (no value). You can spawn something and give it that targetname, but it must be done before you give it an index number.

Also, for random you would need somthing like this.

level.a = ( randomint 1 + 16 )

Posted: Sun Nov 28, 2004 3:53 am
by Phil {sfx}
Its for multiplayer m8,

Anyway tracked the problem down abit more,

Code: Select all

//CODE NOW!:

//local.me is player 

    level.a = 1 
    level.a++ 

    local.me.targetname = me(level.a)   //should be now me2 

iprintlnbold (level.a)      // gives 2 
iprintlnbold me(level.a)  // gives NIL
If i rem this line out: local.me.targetname = me(level.a) i get what i want.

Code: Select all

//CODE NOW!:

//local.me is player 

    level.a = 1 
    level.a++ 

    //local.me.targetname = me(level.a)   //should be now me2 

iprintlnbold (level.a)      // gives 2 
iprintlnbold me(level.a)  // gives me2
Anyone know why it works if i dont set the player targetname to what i want. :(

Re: $me

Posted: Sun Nov 28, 2004 4:11 am
by Phil {sfx}
tltrude wrote:"$me" will look for something targetname "me" in the map. If there is nothing that uses that name, it will return "NIL" (no value). You can spawn something and give it that targetname, but it must be done before you give it an index number.

Also, for random you would need somthing like this.

level.a = ( randomint 1 + 16 )
Posted around the same time so didnt see your post tom,

Forgot about the "targetname" & $ token (lack of sleep, lol)

Instead of using "level.a = ( randomint 1 + 16 )" i was upping the count using "level.a++"

Posted: Sun Nov 28, 2004 4:48 am
by Phil {sfx}
//UPDATE.....

Using this code gives me the correct targetname but no number now.

Code: Select all

    level.a = 1 
    level.a++ 

    local.me targetname me(level.a)      //should be me2 

iprintlnbold (level.a)                // gives 2 
local.t = local.me.targetname
iprintlnbold (local.t)                 // gives me 
Whats happened to my number? :?

Posted: Sun Nov 28, 2004 7:50 am
by jv_map
local.me targetname ("me" + level.a)

Posted: Sun Nov 28, 2004 8:16 am
by Phil {sfx}
Cheers jv, that did the job.

:D

Posted: Sun Nov 28, 2004 9:28 am
by Phil {sfx}
Ok i have a few more problems, perhaps you can point me in the direction of whats wrong again jv.

Here is just a few bits of code taken from various points of my script, that seem to be good & bad for some reason. :? (i would post all 350 odd lines of code but i'd rather peeps not know what am upto at the moment. :wink:

Lines in blue do work:
Lines in red dont work:

//---------------------------------------------------------

if ($("me" + level.a).asit==1)
{
$("me" + level.a) iprint "YOU HAVE IT"
end
}
//----------------------------------------------------------

$("me" + level.a).health = 100
$("me" + level.a).asit=1


//-----------------------------------------------------------

while (isalive $("me" + level.a))
{
wait 0.2
if ($("me" + level.a).asit==1)
{
if ($("me" + level.a).dmteam=="spectator")
{

//-------------------------------------------------------------

($("me" + level.a)) waittill death

//--------------------------------------------------------------

Am getting field "asit" or "dmteam" applied to NULL listener for the ones that dont work, at first i thought it was just the ones with the coma in front of the $ token but it appears i have the same line working and not working. :?

I know its all fine & works if i use a singleplayer (local.me), so i must be typing them reds wrong i think, i hope. :cry:

Posted: Sun Nov 28, 2004 9:39 am
by bdbodger
What is the point of changeing the players targetname from player to me? If you do assign a random targetname how are you going to keep it straight which player is which . it all seems so pointless .

Posted: Sun Nov 28, 2004 10:35 am
by Phil {sfx}
Its not me, its something totally diff, but if i left all my code as it was, then my project idea would be robbed, thats why i have changed all the bits as it would of been a dead give away of what i was upto.

So "me" popped in my head, so "me" was typed. :wink:

Posted: Sun Nov 28, 2004 12:38 pm
by Phil {sfx}
Thanks guys for all your help, but i found my problem, i had left wait 0.2 in a naughty place. :oops:

Anyway :D