NPC´s per script spawnen helpe
Posted: Sun Feb 12, 2012 4:24 pm
can anyone say me why this is not right?
and can help me by my script away?
this script will be replace my gulag because my gulag don´t work
when one npc dead after 1 or 2 hours hw will respawned.
can anyone helpe me by me problem away?
thank you
- Code: Select all
local respawn_timer = 0
local clear_sky_respwan_1_count = 0
local clear_sky_respwan_2_count = 0
local clear_sky_respwan_3_count = 0
function spawnbare_npc()
local levels = {[1] = "marsh", [2] = "l01_escape", [3] = "l02_garbage", [4] = "l03_agroprom", [5] = "l04_darkvalley", [6] = "l05_bar", [7] = "l06_rostok", [8] = "l07_military", [9] = "l08_yantar"}
local clear_sky_respwan_1 = {"mar_clear_sky_respawn_1"}
local clear_sky_respwan_2 = {"mar_clear_sky_respawn_2"}
local clear_sky_respwan_3 = {"mar_clear_sky_respawn_3"}
local level_name = level.name()
local ws = 0
local which_spawn = math.random(1, 2)
if respawn_timer == 0 then respawn_timer = time_global() + math.random(3, 4) end
if db.actor:alive() then
if respawn_timer() > respawn_timer then
respawn_timer = 2
local Koordinate = {}
local creatures = {"clear_sky_respwan_1", "clear_sky_respwan_2", "clear_sky_respwan_3"}
local who = creatures[math.random(1, 3)]
for indx, lvl in pairs(levels) do
if level_name == lvl then
ws = indx
else
ws = 0
end
if ws == 1 then
if which_spawn == 1 then
if who == "clear_sky_respwan_1" or
if who == "clear_sky_respwan_2" or
if who == "clear_sky_respwan_3" then
Koordinate = {x = -61.996055603027, y = 0.92057931423187, z = 293.67742919922, game_vertex_id = 3402, level_vertex_id = 106182}
else
if who == "clear_sky_respwan_1" or
if who == "clear_sky_respwan_2" or
if who == "clear_sky_respwan_3" then
Koordinate = {x = -51.345394134521, y = 1.1859278678894, z = 296.54559326172, game_vertex_id = 3402, level_vertex_id = 114134}
end
end
if ws > 0 then
if who == "clear_sky_respwan_1" and
if clear_sky_respwan_1_count = 0 then
npc_spawnen(clear_sky_respwan_1, Koordinate)
elseif who == "clear_sky_respwan_2" and
if clear_sky_respwan_2_count = 0 then
npc_spawnen(clear_sky_respwan_2, Koordinate)
elseif who == "clear_sky_respwan_3" and
if clear_sky_respwan_3_count = 0 then
npc_spawnen(clear_sky_respwan_3, Koordinate)
end
end
function npc_spawnen()
local npc_tbl = {}
local spwn = alife():create(creatures, vector():set(Koordinate)
npc_tbl[spwn.id] = true
end
function ist_npc_tot()
local obj,count,tbl_cnt = nil,0,#npc_tbl
for k,v in pairs(npc_tbl) do
obj = alife():object(k)
if obj == nil then
v = nil
creatures..count = count + 1
end
end
if creatures..count == tbl_cnt then
respawn_timer = 0
end
and can help me by my script away?
this script will be replace my gulag because my gulag don´t work
when one npc dead after 1 or 2 hours hw will respawned.
can anyone helpe me by me problem away?
thank you