Random targetname[level.a]

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Random targetname[level.a]

Post 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
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

whats this scrap for :-/
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Post by Phil {sfx} »

Your nosey arnt you. :roll:

If you dont know, you dont need to. lol
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
Grassy
First Lieutenant
Posts: 221
Joined: Sun Aug 22, 2004 11:36 am

Post 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
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

heh heh... nosey i am
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

$me

Post 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 )
Last edited by tltrude on Sun Nov 28, 2004 3:57 am, edited 1 time in total.
Tom Trude,

Image
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Post 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. :(
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Re: $me

Post 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++"
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Post 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? :?
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

local.me targetname ("me" + level.a)
Image
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Post by Phil {sfx} »

Cheers jv, that did the job.

:D
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Post 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:
Last edited by Phil {sfx} on Sun Nov 28, 2004 11:15 am, edited 2 times in total.
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post 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 .
Image
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Post 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:
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
Phil {sfx}
Sergeant
Posts: 67
Joined: Thu Sep 30, 2004 2:08 pm
Location: uk
Contact:

Post 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
Senior Modder/Mapper/Scripter/Modeller @ www.mods-r-us.net
Post Reply