ProjectsWhat's NewDownloadsCommunitySupportCompany
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
respwan script help

Posted by/on
Question/AnswerMake Newest Up Sort by Descending
  20:31:10  14 June 2012
profilee-mailreply Message URLTo the Top
olaf1
Senior Resident
 

 
On forum: 01/17/2012
 

Message edited by:
olaf1
06/16/2012 13:16:01
Messages: 240
respwan script help

Hey guys

can you help me pleas????

i have make a respawn script but the NPC´s dont´will spawn can you help me away??

Thank you



local npc_table = {
mar_clear_sky_respawn_1_1_kamper = {
timer 		= {zahl1 = 3, zahl2 = 6},
sections	= "mar_clear_sky_respawn_1_kamper",
position = {15.05495262146,2.565721988678,-265.27029418945, 146152, 3423},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_1_2_kamper = {
timer 		= {zahl1 = 3, zahl2 = 6},
sections	= "mar_clear_sky_respawn_1_kamper",
position = {15.05495262146,2.565721988678,-265.27029418945, 146152, 3423},
count		= 1,
id 			= {},
respwanen = true},


mar_clear_sky_respawn_1_3_kamper = {
timer 		= {zahl1 = 3, zahl2 = 6},
sections	= "mar_clear_sky_respawn_1_kamper",
position = {15.05495262146,2.565721988678,-265.27029418945, 146152, 3423},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_2_1_kamper = {
timer 		= {zahl1 = 3, zahl2 = 6},
sections	= "mar_clear_sky_respawn_2_kamper",
position = {26.493240356445,3.2842679023743,-264.8073425293, 152405, 3436},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_2_2_kamper = {
timer 		= {zahl1 = 3, zahl2 = 6},
sections	= "mar_clear_sky_respawn_2_kamper",
position = {26.493240356445,3.2842679023743,-264.8073425293, 152405, 3436},
count		= 1,
id 			= {},
respwanen = true},


mar_clear_sky_respawn_2_3_kamper = {
timer 		= {zahl1 = 3, zahl2 = 6},
sections	= "mar_clear_sky_respawn_2_kamper",
position = {26.493240356445,3.2842679023743,-264.8073425293, 152405, 3436},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_3_1_kamper = {
timer 		= {zahl1 = 3, zahl2 = 6},
sections	= "mar_clear_sky_respawn_3_kamper",
position = {35.865989685059,3.1588425636292,-259.74450683594, 157685, 3436},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_3_2_kamper = {
timer 		= {zahl1 = 3, zahl2 = 6},
sections	= "mar_clear_sky_respawn_3_kamper",
position = {35.865989685059,3.1588425636292,-259.74450683594, 157685, 3436},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_3_3_kamper = {
timer 		= {zahl1 = 3, zahl2 = 6},
sections	= "mar_clear_sky_respawn_3_kamper",
position = {35.865989685059,3.1588425636292,-259.74450683594, 157685, 3436},
count		= 1,
id 			= {},
respwanen = true}
}






function read()
local npc = npc_table[math.random(1, 9)]
		if npc_table[npc] and npc_table[npc].respwanen == true then
		local npc_name = npc_table[npc].sections
		local pos = npc_table[npc].position
		local npc_number = npc_table[npc].count
		spawn(npc_name,pos,npc_number)
		for k,v in paris(npc_table[npc].timer)do
			if k == "zahl1" then 
			local timer1 = v
			if k == "zahl2" then
			local timer2 = v
			timer(timer1,timer2)
			end
		end		
	end
end


local spawn_start = false
local timer = nil


function timer(time1,time2)
if db.actor:alive() == false then return end
local level_name = level.name()
	if spawn_start == false then
			if timer == nil then
			timer = level.get_time_hours() + math.random(time1, time2)
			if timer > 23 then timer = timer - 24 end
			end
		if time_global() > timer then
		timer = nil
		spawn_start = true
		end
	end
end
                            


function spawn(npc,pos,count)
if spawn_start == true then
	for i = 1,count do
	spawn = alife():create(npc, pos) 
	npc_table[npc].id = spawn.id
	npc_table[npc].respwanen = false
	end	
end
spawn_start = false	
end



function npc_dead()
local npc = npc_table[math.random(1, 9)]
	if npc_table[npc] == true then
             if npc_table[npc].respwanen == false then	
		if npc_table[npc].id ~= nil then
		return 
		else npc_table[npc].id = {}
		npc_table[npc].respwanen = true
		end
		end
	end
end
end


function save(packet)
	save_table(packet,npc_table)
end

function load(reader)
	load_table(reader,npc_table)
end

function load_table(reader, obj)
	local ctr = reader:r_u32()
	local tn = 0
	local varname = ""
	local xobj = nil
	for i = 1, ctr do
		varname = reader:r_stringZ()
		tn = reader:r_u8()
		if tn == 0 then
			obj[varname] = reader:r_float()
		elseif tn == 1 then
			obj[varname] = reader:r_stringZ()
		elseif tn == 2 then
			obj[varname] = reader:r_bool()
		elseif tn == 3 then
			obj[varname] = {}
			xobj = obj[varname]
			load_table(reader, xobj)
		end
	end
end

function save_table(packet, obj)
	local ctr = 0
	local tv = nil
	local xobj = nil
	for k,v in pairs(obj) do
		ctr = ctr + 1
	end
	packet:w_u32(ctr)
	for k,v in pairs(obj) do
 		packet:w_stringZ(k)
		tv = type(v)
		if tv == "number" then
			packet:w_u8(0)
	 		packet:w_float(v)
	 	elseif tv == "string" then
			packet:w_u8(1)
	 		packet:w_stringZ(v)
		elseif tv == "boolean" then
			packet:w_u8(2)
			packet:w_bool(v)
		elseif tv == "table" then
			packet:w_u8(3)
			xobj = obj[k]
			save_table(packet, xobj)
		end
	end	
end









i hope you can help me
  22:43:58  14 June 2012
profilee-mailreply Message URLTo the Top
DooMike
The Janitor
(Resident)

 

 
On forum: 01/31/2009
Messages: 415
Dear Olaf1...

"respwan..." maybe that should read: respawn?

I may not know much of scripting, but i know dyslexia when i see it.

You may want to try and get somebody interrested in proofreading your scripts for you....

Good lcuk
  09:17:07  15 June 2012
profilee-mailreply Message URLTo the Top
ThunderFreak
Senior Resident
 

 
On forum: 08/07/2009
Messages: 685
You should write that way.

if npc_table[npc] and npc_table[npc].respwanen == true then
    ...
end


Which is the same like

if if npc_table[npc] then
    if npc_table[npc].respwanen == true then
        ...
    end
end


If you get a 'NIL' error mostly a check for 'NIL' is missing.
  15:38:00  15 June 2012
profilee-mailreply Message URLTo the Top
olaf1
Senior Resident
 

 
On forum: 01/17/2012
Messages: 240
Thank you Thunder yet i don´t get a erro but the NPC´s don´t will spawn.
Can anyone say me why???
  20:49:49  16 June 2012
profilee-mailreply Message URLTo the Top
olaf1
Senior Resident
 

 
On forum: 01/17/2012
 

Message edited by:
olaf1
06/17/2012 12:12:03
Messages: 240
can nobody help me???
hier is the new script

but the NPC´s don´t will spawn
can you say me why???
Thank you


local npc_table = {
mar_clear_sky_respawn_1_1_kamper = {
timer1		= 3,
timer2 		= 6,
sections	= "mar_clear_sky_respawn_1_kamper",
position = {15.05495262146,2.565721988678,-265.27029418945, 146152, 3423},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_1_2_kamper = {
timer1		= 3,
timer2 		= 6,
sections	= "mar_clear_sky_respawn_1_kamper",
position = {15.05495262146,2.565721988678,-265.27029418945, 146152, 3423},
count		= 1,
id 			= {},
respwanen = true},


mar_clear_sky_respawn_1_3_kamper = {
timer1		= 3,
timer2 		= 6,
sections	= "mar_clear_sky_respawn_1_kamper",
position = {15.05495262146,2.565721988678,-265.27029418945, 146152, 3423},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_2_1_kamper = {
timer1		= 3,
timer2 		= 6,
sections	= "mar_clear_sky_respawn_2_kamper",
position = {26.493240356445,3.2842679023743,-264.8073425293, 152405, 3436},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_2_2_kamper = {
timer1		= 3,
timer2 		= 6,
sections	= "mar_clear_sky_respawn_2_kamper",
position = {26.493240356445,3.2842679023743,-264.8073425293, 152405, 3436},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_2_3_kamper = {
timer1		= 3,
timer2 		= 6,
sections	= "mar_clear_sky_respawn_2_kamper",
position = {26.493240356445,3.2842679023743,-264.8073425293, 152405, 3436},
count		= 1,
id 			= {},
respwanen = true},


mar_clear_sky_respawn_3_1_kamper = {
timer1		= 3,
timer2 		= 6,
sections	= "mar_clear_sky_respawn_3_kamper",
position = {35.865989685059,3.1588425636292,-259.74450683594, 157685, 3436},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_3_2_kamper = {
timer1		= 3,
timer2 		= 6,
sections	= "mar_clear_sky_respawn_3_kamper",
position = {35.865989685059,3.1588425636292,-259.74450683594, 157685, 3436},
count		= 1,
id 			= {},
respwanen = true},

mar_clear_sky_respawn_3_3_kamper = {
timer1		= 3,
timer2 		= 6,
sections	= "mar_clear_sky_respawn_3_kamper",
position = {35.865989685059,3.1588425636292,-259.74450683594, 157685, 3436},
count		= 1,
id 			= {},
respwanen = true}
}






function read()
local npc = npc_table[math.random(1, 9)]
		if npc_table[npc] and npc_table[npc].respwanen == true then
		local npc_name = npc_table[npc].sections
		local pos = npc_table[npc].position
		local npc_number = npc_table[npc].count
		spawn(npc_name,pos,npc_number)
		local timer1 = npc_table[npc].timer1
		local timer2 = npc_table[npc].timer2
		timer(timer1,timer2)
		end		
end


local spawn_start = false
local timer = nil


function timer(time1,time2)
if db.actor:alive() == false then return end
local level_name = level.name()
	if spawn_start == false then
			if timer == nil then
			timer = level.get_time_hours() + math.random(time1, time2)
			if timer > 23 then timer = timer - 24 end
			end
		if time_global() > timer then
		timer = nil
		spawn_start = true
		end
	end
end
                            


function spawn(npc,pos,count)
if spawn_start == true then
	for i = 1,count do
	spawn = alife():create(npc, pos) 
	npc_table[npc].id = spawn.id
	npc_table[npc].respwanen = false
	end	
end
spawn_start = false	
end


function npc_dead()
local npc = npc_table[math.random(1, 9)]
	if npc_table[npc] == true then
		if npc_table[npc].respwanen == false then	
			if npc_table[npc].id ~= nil then
			return 
			else npc_table[npc].id = {}
			npc_table[npc].respwanen = true
			end
		end
		end
	end




function save(packet)
	save_table(packet,npc_table)
end

function load(reader)
	load_table(reader,npc_table)
end

function load_table(reader, obj)
	local ctr = reader:r_u32()
	local tn = 0
	local varname = ""
	local xobj = nil
	for i = 1, ctr do
		varname = reader:r_stringZ()
		tn = reader:r_u8()
		if tn == 0 then
			obj[varname] = reader:r_float()
		elseif tn == 1 then
			obj[varname] = reader:r_stringZ()
		elseif tn == 2 then
			obj[varname] = reader:r_bool()
		elseif tn == 3 then
			obj[varname] = {}
			xobj = obj[varname]
			load_table(reader, xobj)
		end
	end
end

function save_table(packet, obj)
	local ctr = 0
	local tv = nil
	local xobj = nil
	for k,v in pairs(obj) do
		ctr = ctr + 1
	end
	packet:w_u32(ctr)
	for k,v in pairs(obj) do
 		packet:w_stringZ(k)
		tv = type(v)
		if tv == "number" then
			packet:w_u8(0)
	 		packet:w_float(v)
	 	elseif tv == "string" then
			packet:w_u8(1)
	 		packet:w_stringZ(v)
		elseif tv == "boolean" then
			packet:w_u8(2)
			packet:w_bool(v)
		elseif tv == "table" then
			packet:w_u8(3)
			xobj = obj[k]
			save_table(packet, xobj)
		end
	end	
end








I hope you can help me away.
 
Each word should be at least 3 characters long.
Search:    
Search conditions:    - spaces as AND    - spaces as OR   
 
Forum Index » S.T.A.L.K.E.R.: Shadow of Chernobyl Forum » Mod discussion
 

All short dates are in Month-Day-Year format.


 

Copyright © 1995-2021 GSC Game World. All rights reserved.
This site is best viewed in Internet Explorer 4.xx and up and Javascript enabled. Webmaster.
Opera Software products are not supported.
If any problem concerning the site functioning under Opera Software appears apply
to Opera Software technical support service.