Technology (Read Only) > Programming

Multiple Scripting Problems

<< < (3/3)

StartedBullet:
0.o  :idk: Well can you give me an example? Im still kinda new to programming.

Кrаsher:
to make ein table

SpawnTable={}

To use ein table

SpawnTable[1]="rite hear"

Tomcat:

--- Quote from: Кrашер on September 06, 2010, 11:58:55 AM ---to make ein table

SpawnTable={}

To use ein table

SpawnTable[1]="rite hear"

--- End quote ---




nonoonono



--- Code: ---ents.FindByClass("pingaz")

--- End code ---

Rbn:

--- Quote from: mdew355 on September 06, 2010, 01:21:04 AM ---I think you can only use math.random with numbers like math.random(0, 10)
I don't know zombie survival's LUA that well (if that's whats this for) but I don't know where you got #spawns from 0.o

--- End quote ---

Actually a # will retrieve the quantity of registers than a table has.

Example:


--- Code: ---Player: World Spawned: models/weapons/v_toolgun.mdlPlayer: World Spawned: models/weapons/v_superphyscannon.mdl
Player: World Spawned: maps/gm_construct.bsp
] net_graph 1
] net_graph 0
] lua_run spawns = ents.FindByClass( "info_player_start" )
> spawns = ents.FindByClass( "info_player_start" )...
] lua_run print(#spawns)
> print(#spawns)...
18
] lua_run PrintTable(spawns)
> PrintTable(spawns)...
1 = Entity [18][info_player_start]
2 = Entity [19][info_player_start]
3 = Entity [20][info_player_start]
4 = Entity [21][info_player_start]
5 = Entity [22][info_player_start]
6 = Entity [23][info_player_start]
7 = Entity [24][info_player_start]
8 = Entity [25][info_player_start]
9 = Entity [26][info_player_start]
10 = Entity [27][info_player_start]
11 = Entity [28][info_player_start]
12 = Entity [29][info_player_start]
13 = Entity [30][info_player_start]
14 = Entity [31][info_player_start]
15 = Entity [32][info_player_start]
16 = Entity [33][info_player_start]
17 = Entity [34][info_player_start]
18 = Entity [35][info_player_start]

--- End code ---


--- Quote from: StartedBullet on September 06, 2010, 09:06:56 AM ---This is for a single-player LFD last stand mode. Ive seen multiple examples of random spawning through this method on the wki. If not this, how will I randomly spawn zombies.
_______
function GM:PlayerSelectSpawn( pl )
 
    local spawns = ents.FindByClass( "info_player_start" )
    local random_entry = math.random(#spawns)
 
    return spawns[random_entry]
 
end
_________
Thats the wiki script.

--- End quote ---

Try something like this

spawns should be loaded before the function or will make a table every time you call it, memory vs processor. :/

local spawns = ents.FindByClass( "info_player_start" ) --This is what actually a map uses to spawn a (Default player). You can use with Zombie_Spawn_Point too but idk what map u using.


--- Code: ---function RandomSpot( player )

if player:IsValid() then
player:Spawn()
player:SetPos( spawns[math.random( #spawns )]:GetPos() )  -- Every product in the table is an Entity so we can retrieve using the methos GetPos()
else
return
end

end
--- End code ---

I'll help ya later with derma, I HATE DERMA :/ k laterz.

mdew355:
I know this is a really old post, but with the derma you use a line like this:

local ready = vgui.Create("DFrame"); //It's DFrame, not BFrame.

Navigation

[0] Message Index

[*] Previous page

Go to full version