Перейти к контенту

Скриптование


Svoboда

Рекомендуемые сообщения

(изменено)

У меня сделать сценарий.

 

но в этом сценарии любой ложный или отсутствует, но что?

 

local npc = {

mar_clear_sky_respawn_1 = mar_clear_sky_respawn_1_counter
,
mar_clear_sky_respawn_2 = mar_clear_sky_respawn_2_counter
,
mar_clear_sky_respawn_3 = mar_clear_sky_respawn_3_counter
,
}

local npc_spawn_data = {

mar_clear_sky_respawn_1 = -61.996055603027, 0.92057931423187, 293.67742919922, game_vertex_id = 3402, level_vertex_id = 106182
,
mar_clear_sky_respawn_2 = -51.345394134521, 1.1859278678894, 296.54559326172, game_vertex_id = 3402, level_vertex_id = 114134
,
mar_clear_sky_respawn_3 = -51.345394134521, 1.1859278678894, 296.54559326172, game_vertex_id = 3402, level_vertex_id = 114134
,
}

local npc_respawn_counter = {

mar_clear_sky_respawn_1_counter = 3
,
mar_clear_sky_respawn_2_counter = 5
,
mar_clear_sky_respawn_3_counter = 2
,
}







local npc_spawn = Respawn_NPC()

function start()

    npc_spawn:LoadConfig()

end



class "Respawn_NPC"



function Respawn_NPC:__init()

    self.init_done = false



    self.respawn_npc_tabel = nil

    self.respawn_counter = nil

    self.respawn_counter_name = nil

    self.respawn_npc = nil

    self.respawn_npc_point = nil



    self.respawn_timer = 0

    if level.name() ~= "marsh" then

        self.enabled = false

    else

        self.enabled = true

        self:LoadConfig()

    end

    self.init_done = true

end



function Respawn_NPC:__finalize()

    self.init_done = nil

    self.enabled = nil

    self.respawn_counter = nil

    self.respawn_npc_tabel = nil

    self.respawn_counter_name = nil

    self.respawn_npc = nil

    self.respawn_npc_point = nil

end



function Respawn_NPC:LoadConfig()

        self.respawn_npc .. "_" .. count = 0

        local npc_1 = npc

        local npc_respawn_counter_1 = npc_respawn_counter

        local npc_spawn_data_1 = npc_spawn_data



        self.respawn_counter = {}

        self.respawn_counter_name = {}

        self.respawn_npc = {}

        self.respawn_npc_point = {}



        for k,v in pairs ("npc_1")do

            self.respawn_npc(k)

            self.respawn_counter_name(v)

        end

        for k,v in pairs("npc_respawn_counter_1") do 

                if k == respawn_counter_name then

                self.respawn_counter(v)

            end            

        end

        for k,v in pairs("npc_spawn_data_1") do 

            if k == respawn_npc then

                if respawn_npc .. "_" .. count < respawn_counter then

                self.respawn_npc_point(v)

                else 

                return

                end                    

            end

        end

end




function Respawn_NPC:Timer()

    if respawn_timer == false then 

    if respawn_timer == 0 then 

              respawn_timer = level.get_time_hours() + math.random(3, 4) 

              if respawn_timer > 23 then respawn_timer = respawn_timer - 24 end

        end

    if db.actor:alive() then

            if level.get_time_hours() > respawn_timer then

                respawn_timer = 0

        respawn_timer_a = true

        end

    end

end



function Respawn_NPC:Spawn_NPC(respawn_counter_ltx, respawn_npc_point)

    if respawn_timer_a == true then

    if respawn_timer == 0 then

    if not respawn_counter and not respawn_npc_point then

        return false

        end

    end

    self.respawn_npc_tabel = {}

    if npc_respawn_counter < respawn_counter then

    self.spwan = alife():create(respawn_npc, vector():set(respawn_npc_point)

    respawn_npc_tabel[spwan.id] = true
    end

end





function Respawn_NPC:Counter(respawn_npc_tabel)

if not respawn_npc_tabel then

    return false

end



local obj,count,tbl_cnt = nil,0,#respawn_npc_tabel 

for k,v in pairs(respawn_npc_tabel) do

obj = alife():object(k)

if obj == nil then

v = nil   

respawn_npc .. "_" .. count = respawn_npc .. "_" .. count - 1

end

end

    if respawn_npc .. "_" .. count < respawn_counter  then

        respawn_timer = false 

            respawn_timer = 0   

    end

end

 

 

LUA мой редактор сказал, что в строке 111 "=" ожидается около `.. '(111)

 

100 function Respawn_NPC:Spawn_NPC(respawn_counter_ltx, 101respawn_npc_point)
102    if respawn_timer_a == true then
103    if respawn_timer == 0 then
104    if not respawn_counter and not respawn_npc_point then
105        return false
106        end
107    end
108    self.respawn_npc_tabel = {}
109    if npc_respawn_counter < respawn_counter then
110    self.spwan = alife():create(respawn_npc, vector():set(respawn_npc_point)
111    respawn_npc_tabel[spwan.id] = true
112    end
113end

 

Я надеюсь, кто-нибудь может мне помочь моей проблеме.

 

Я не knwo, что у меня есть реактивный делать.

 

пс почему мой последний вклад был удален?.

 

Сообщение от модератора ColR_iT
Please write your question in the native language, you will.
Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение

i have correct the script.

local npc = {

mar_clear_sky_respawn_1 = mar_clear_sky_respawn_1_counter
,
mar_clear_sky_respawn_2 = mar_clear_sky_respawn_2_counter
,
mar_clear_sky_respawn_3 = mar_clear_sky_respawn_3_counter
,
}

local npc_data = {
mar_clear_sky_respawn_1 = -61.996055603027, 0.92057931423187, 293.67742919922, game_vertex_id = 3402, level_vertex_id = 106182
,
mar_clear_sky_respawn_2 = -51.345394134521, 1.1859278678894, 296.54559326172, game_vertex_id = 3402, level_vertex_id = 114134
,
mar_clear_sky_respawn_3 = -51.345394134521, 1.1859278678894, 296.54559326172, game_vertex_id = 3402, level_vertex_id = 114134,
}


local npc_respawn_counter = {

mar_clear_sky_respawn_1_counter = 3
,
mar_clear_sky_respawn_2_counter = 5
,
mar_clear_sky_respawn_3_counter = 2
,
}

local NPC = nil
function Start()
if NPC == nil then
	NPC = Respawn_NPC()
end
return NPC
end

class "Respawn_NPC"

function Respawn_NPC:__init()
self.init_done = false
self.counter_im_script = nil
self.respawn_npc_tabel = nil
self.respawn_counter = nil
self.respawn_counter_name = nil
self.respawn_npc = nil
self.respawn_npc_point = nil

self.respawn_timer = 0
if level.name() ~= "marsh" then
	self.enabled = false
else
	self.enabled = true
	self:LoadConfig()
end
self.init_done = true
end



function Respawn_NPC:__finalize()
self.counter_im_script = nil
self.init_done = nil
self.enabled = nil
self.respawn_counter = nil
self.respawn_npc_tabel = nil
self.respawn_counter_name = nil
self.respawn_npc = nil
self.respawn_npc_point = nil
end



function Respawn_NPC:LoadConfig()
	local npc_1 = npc
	local npc_respawn_counter_1 = npc_respawn_counter
	local npc_spawn_data_1 = npc_spawn_data
	self.respawn_counter = {}
	self.respawn_counter_name = {}
	self.respawn_npc = {}
	self.respawn_npc_point = {}

	for k,v in pairs ("npc_1")do
		self.respawn_npc(k)
		self.respawn_counter_name(v)
	end
	self.counter_im_script = respawn_npc.."_counter"
	self.counter_im_script = 0
	for k,v in pairs("npc_respawn_counter_1") do 
			if k == respawn_counter_name then
			self.respawn_counter(v)
		end    
	end

	for k,v in pairs("npc_spawn_data_1") do 
		if k == respawn_npc then
			if counter_im_script < respawn_counter then
			self.respawn_npc_point(v)
			else 
			return
			end					
		end
	end
end




function Respawn_NPC:Timer()
if respawn_timer == false then 
if respawn_timer == 0 then 
             respawn_timer = level.get_time_hours() + math.random(3, 4) 
             if respawn_timer > 23 then respawn_timer = respawn_timer - 24 end
       end
if db.actor:alive() then
           if level.get_time_hours() > respawn_timer then
               respawn_timer = 0
	respawn_timer_a = true
	end
end
end


function Respawn_NPC:Spawn_NPC(respawn_counter_ltx, respawn_npc_point)
if respawn_timer_a == true then
	if respawn_timer == 0 then
		if not respawn_counter and not respawn_npc_point then
			return false
		end
	end
	self.respawn_npc_tabel = {}
	if npc_respawn_counter < respawn_counter then
		self.spwan = alife():create(respawn_npc, vector():set(respawn_npc_point))
		respawn_npc_tabel[spwan.id] = true
	end
   end
end




function Respawn_NPC:Counter(respawn_npc_tabel)
if not respawn_npc_tabel then
return false
end
local obj,count,tbl_cnt = nil,0,#respawn_npc_tabel 
for k,v in pairs(respawn_npc_tabel) do
obj = alife():object(k)
if obj == nil then
v = nil 
counter_im_script = counter_im_script - 1  
end
end
if counter_im_script < respawn_counter  then
	respawn_timer = false 
   	respawn_timer = 0   
end
end
end


 

 

but when i start the game it comming a crash.

 

FATAL ERROR

[error]Expression    : fatal error
[error]Function      : CScriptEngine::lua_error
[error]File          : E:\stalker\patch_1_0004\xr_3da\xrGame\script_engine.cpp
[error]Line          : 73
[error]Description   : <no expression>
[error]Arguments     : LUA error: ...w of chernobyl\gamedata\scripts\resapwan_npc2.script:128: bad argument #1 to 'pairs' (table expected, got string)


stack trace:

 

 

but i don´t know what i have yet to do.

 

can anyone help me?

 

thank you

Поделиться этим сообщением


Ссылка на сообщение

when i use the local tabel name is it then correct?

 

i have use this

 

local npc = {

mar_clear_sky_respawn_1 = mar_clear_sky_respawn_1_counter
,
mar_clear_sky_respawn_2 = mar_clear_sky_respawn_2_counter
,
mar_clear_sky_respawn_3 = mar_clear_sky_respawn_3_counter
,
    }

local npc_data = {
mar_clear_sky_respawn_1 = -61.996055603027, 0.92057931423187, 293.67742919922, game_vertex_id = 3402, level_vertex_id = 106182
,
mar_clear_sky_respawn_2 = -51.345394134521, 1.1859278678894, 296.54559326172, game_vertex_id = 3402, level_vertex_id = 114134
,
mar_clear_sky_respawn_3 = -51.345394134521, 1.1859278678894, 296.54559326172, game_vertex_id = 3402, level_vertex_id = 114134,
}


local npc_respawn_counter = {

mar_clear_sky_respawn_1_counter = 3
,
mar_clear_sky_respawn_2_counter = 5
,
mar_clear_sky_respawn_3_counter = 2
,
    }
    
local NPC = nil
function Start()
    if NPC == nil then
        NPC = Respawn_NPC()
    end
    return NPC
end

class "Respawn_NPC"

function Respawn_NPC:__init()
    self.init_done = false
    self.counter_im_script = nil
    self.respawn_npc_tabel = nil
    self.respawn_counter = nil
    self.respawn_counter_name = nil
    self.respawn_npc_name = nil
    self.respawn_npc_point = nil

    self.respawn_timer = 0
    if level.name() ~= "marsh" then
        self.enabled = false
    else
        self.enabled = true
        self:LoadConfig()
    end
    self.init_done = true
end



function Respawn_NPC:__finalize()
    self.counter_im_script = nil
    self.init_done = nil
    self.enabled = nil
    self.respawn_counter = nil
    self.respawn_npc_tabel = nil
    self.respawn_counter_name = nil
    self.respawn_npc_name = nil
    self.respawn_npc_point = nil
end



function Respawn_NPC:LoadConfig()
        self.respawn_counter = {}
        self.respawn_counter_name = {}
        self.respawn_npc_name = {}
        self.respawn_npc_point = {}

        for k,v in pairs ("npc")do
            self.respawn_npc_name(k)
            self.respawn_counter_name(v)
        end
        self.counter_im_script = respawn_npc_name.."_counter"
        self.counter_im_script = 0
        for k,v in pairs("npc_respawn_counter") do 
                if k == respawn_counter_name then
                self.respawn_counter(v)
            end    
        end

        for k,v in pairs("npc_spawn_data") do 
            if k == respawn_npc then
                if counter_im_script < respawn_counter then
                self.respawn_npc_point(v)
                else 
                return
                end                    
            end
        end
end




function Respawn_NPC:Timer()
    if respawn_timer == false then 
    if respawn_timer == 0 then 
              respawn_timer = level.get_time_hours() + math.random(3, 4) 
              if respawn_timer > 23 then respawn_timer = respawn_timer - 24 end
        end
    if db.actor:alive() then
            if level.get_time_hours() > respawn_timer then
                respawn_timer = 0
        respawn_timer_a = true
        end
    end
end


function Respawn_NPC:Spawn_NPC(respawn_counter_ltx, respawn_npc_point)
    if respawn_timer_a == true then
        if respawn_timer == 0 then
            if not respawn_counter and not respawn_npc_point then
                return false
            end
        end
        self.respawn_npc_tabel = {}
        if npc_respawn_counter < respawn_counter then
            self.spwan = alife():create(respawn_npc, vector():set(respawn_npc_point))
            counter_im_script = counter_im_script + 1
            respawn_npc_tabel[spwan.id] = true
        end
    end
end




function Respawn_NPC:Counter(respawn_npc_tabel)
if not respawn_npc_tabel then
    return false
end
local obj,count,tbl_cnt = nil,0,#respawn_npc_tabel 
for k,v in pairs(respawn_npc_tabel) do
obj = alife():object(k)
if obj == nil then
v = nil 
counter_im_script = counter_im_script - 1  
end
end
if counter_im_script < respawn_counter  then
        respawn_timer = false 
        respawn_timer = 0   
    end
end
end

 

but it give the same problem.

 

what i must yet do?

 

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

what mean you i donґt understand this.

sorry.

Сообщение от модератора ColR_iT
The function pairs must take as its argument the name of the table, not a string.

Добавлено через 24 мин.:

when i use it not in a function then i works but when i use it in a function it donґt works but why it donґt work?

Сообщение от модератора ColR_iT
Here in this line:
for k,v in pairs ("npc")do

parameter npc should be written without quotation marks.

And so everywhere.

I advise you read the articles on the syntax of the language Lua, here: http://www.lua.org/

Добавлено через 38 мин.:

when i use this

function tabel(npc)
local npc = 
{
mar_clear_sky_respawn_1 = 232442,
mar_clear_sky_respawn_2 = 243544,
mar_clear_sky_respawn_3 = 7685686
    }
for k,v in pairs(npc)do
print(k)
end
end

and i starting debugging this then is not output

 

but when i start is to debugging

local npc = 
{
mar_clear_sky_respawn_1 = 232442,
mar_clear_sky_respawn_2 = 243544,
mar_clear_sky_respawn_3 = 7685686
    }
for k,v in pairs(npc)do
print(k)
end

then spent some.

why is it so?

I know that it really belongs here, not pure but could you please ask the beantoworten anyway.

thank you before

Сообщение от модератора ColR_iT
It appears that you have no programming experience.

Therefore, in order not to mislead either registered users, nor you, encourage you to read the basic principles of programming in Lua, on the official site:http://www.lua.org/

Thank you for your understanding.

Добавлено через 32 мин.:

i have learn somthing in lua and iґm at the beginning.

can anyone explaen me this why this is so?

thank you.

 

Добавлено через 37 мин.:

i have make it yet in the function.

local npc = nil

function Start()
if npc == nil then
	npc = Respawn_NPC()
end
return npc
end

class  "Respawn_NPC"
function Respawn_NPC:__init()
self.init_done = false
self.counter_im_script = nil
self.respawn_npc_tabel = nil
self.respawn_counter = nil
self.respawn_counter_name = nil
self.respawn_npc_name = nil
self.respawn_npc_point = nil

self.respawn_timer = 0
if level.name() ~= "marsh" then
	self.enabled = false
else
	self.enabled = true
	self:LoadConfig()
end
self.init_done = true
end



function Respawn_NPC:__finalize()
self.counter_im_script = nil
self.init_done = nil
self.enabled = nil
self.respawn_counter = nil
self.respawn_npc_tabel = nil
self.respawn_counter_name = nil
self.respawn_npc_name = nil
self.respawn_npc_point = nil
end



function Respawn_NPC:LoadConfig()
	local npc = 
{
mar_clear_sky_respawn_1 = {"mar_clear_sky_respawn_1_counter"},
mar_clear_sky_respawn_2 = {"mar_clear_sky_respawn_2_counter"},
mar_clear_sky_respawn_3 = {"mar_clear_sky_respawn_3_counter"}
}
local npc_data = 
{
mar_clear_sky_respawn_1 = -61.996055603027, 0.92057931423187, 293.67742919922, game_vertex_id = 3402, level_vertex_id = 106182,
mar_clear_sky_respawn_2 = -51.345394134521, 1.1859278678894, 296.54559326172, game_vertex_id = 3402, level_vertex_id = 114134,
mar_clear_sky_respawn_3 = -51.345394134521, 1.1859278678894, 296.54559326172, game_vertex_id = 3402, level_vertex_id = 114134
}


local npc_respawn_counter =
{
mar_clear_sky_respawn_1_counter = 3,
mar_clear_sky_respawn_2_counter = 5,
mar_clear_sky_respawn_3_counter = 2	
}

	for k,v in pairs(npc)do 
		self.respawn_npc_name = k
		self.respawn_counter_name = v
	end
	self.counter_im_script = respawn_npc_name.."_counter"
	self.counter_im_script = 0
	for k,v in pairs(npc_respawn_counter)do 
			if k == respawn_counter_name then
			self.respawn_counter(v)
		end    
	end

	for k,v in pairs(npc_spawn_data)do 
		if k == respawn_npc then
			if counter_im_script < respawn_counter then
			self.respawn_npc_point(v)
			else 
			return
			end					
		end
	end
end




function Respawn_NPC:Timer()
if respawn_timer == false then 
if respawn_timer == 0 then 
             respawn_timer = level.get_time_hours() + math.random(3, 4) 
             if respawn_timer > 23 then respawn_timer = respawn_timer - 24 end
       end
if db.actor:alive() then
           if level.get_time_hours() > respawn_timer then
               respawn_timer = 0
	respawn_timer_a = true
	end
end
end


function Respawn_NPC:Spawn_NPC(respawn_counter_ltx, respawn_npc_point)
if respawn_timer_a == true then
	if respawn_timer == 0 then
		if not respawn_counter and not respawn_npc_point then
			return false
		end
	end
	self.respawn_npc_tabel = {}
	if npc_respawn_counter < respawn_counter then
		self.spwan = alife():create(respawn_npc, vector():set(respawn_npc_point))
		counter_im_script = counter_im_script + 1
		respawn_npc_tabel[spwan.id] = true
	end
   end
end




function Respawn_NPC:Counter(respawn_npc_tabel)
if not respawn_npc_tabel then
return false
end
local obj,count,tbl_cnt = nil,0,#respawn_npc_tabel 
for k,v in pairs(respawn_npc_tabel)do
obj = alife():object(k)
if obj == nil then
v = nil 
counter_im_script = counter_im_script - 1  
end
end
if counter_im_script < respawn_counter  then
	respawn_timer = false 
   	respawn_timer = 0   
end
end
end


but it comming a crash,too.

FATAL ERROR

[error]Expression    : fatal error
[error]Function      : CScriptEngine::lua_error
[error]File          : E:\stalker\patch_1_0004\xr_3da\xrGame\script_engine.cpp
[error]Line          : 73
[error]Description   : <no expression>
[error]Arguments     : LUA error: ...ow of chernobyl\gamedata\scripts\respwan_npc2.script:71: attempt to concatenate global 'respawn_npc_name' (a nil value)


stack trace:

is it to global or what?

what i have yet to do?

can anyone say me that.

thank you

Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

i have make a script witch shall repswan npc

local first_spwan = false
local respwan_table = {}
local timer = 0
local timer_repswan = 0
local spwan = false

function spwawn()
local levels = {[0] = "marsh", [1] = "l01_escape", [2] = "l02_garbage", [3] = "l03_agroprom", [4] = "l04_darkvalley", [5] = "l05_bar", [6] = "l06_rostok", [7] = "l07_military", [8] = "l08_yantar"}
local level_name = level.name()
if spwan == false then
    if timer == 0 then timer = time_global() + math.random(36, 60) end

        if db.actor:alive() then

            if time_global() > timer then

            timer = 0 
                for indx, lvl in pairs(levels)do
                    if level_name == lvl then
                    ws = indx
                    spwan = true            
                        if spwan == true then
                                if ws == 0 then
                                spawn = 
                                alife():create("mar_clear_sky_respawn_1", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
                                alife():create("mar_clear_sky_respawn_2", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
                                alife():create("mar_clear_sky_respawn_3", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
                                respwan_table[spawn.id] = true
                                first_spwan = true
                                end
                        end
                    end
                end
            end
        end
    end    
if first_spwan == true then
if type(respwan_table) == "table" then
local obj,count,tbl_cnt = nil,0,#respwan_table 

for k,v in pairs(respwan_table) do
obj = alife():object(k)

if obj == nil then
k = respwan_npc_name
v = nil   
if timer_repswan == 0 then timer = time_global() + math.random(36, 60) end
    if db.actor:alive() then
        if time_global() > timer_repswan then
            timer_repswan = 0  
            spawn = alife():create(respwan_npc_name, vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
            respwan_table[spawn.id] = true
        end
    end
end
end
end
end
end

but when i kill a npc the npc donґt respwan but why?

can anyoen help me?

thank you

 

No errors, except for some discrepancies.

It is not clear assignment script.

Describe your idea - what do you want to do?

ColR_iT

Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

Sorry that i make a new psot but i donґt knwo how i can at it on my

i will make a script what respwan npc

i have write a script first what all npcґs spwant and then are this npcґs incold in a table

local first_spwan = false
local respwan_table = {}
local timer = 0
local timer_repswan = 0
local spwan = false

function spwawn()
local levels = {[0] = "marsh", [1] = "l01_escape", [2] = "l02_garbage", [3] = "l03_agroprom", [4] = "l04_darkvalley", [5] = "l05_bar", [6] = "l06_rostok", [7] = "l07_military", [8] = "l08_yantar"}
local level_name = level.name()
if spwan == false then
    if timer == 0 then timer = time_global() + math.random(36, 60) end

        if db.actor:alive() then

            if time_global() > timer then

            timer = 0 
                for indx, lvl in pairs(levels)do
                    if level_name == lvl then
                    ws = indx
                    spwan = true            
                        if spwan == true then
                                if ws == 0 then
                                spawn = 
                                alife():create("mar_clear_sky_respawn_1", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
                                alife():create("mar_clear_sky_respawn_2", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
                                alife():create("mar_clear_sky_respawn_3", vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
                                respwan_table[spawn.id] = true
                                first_spwan = true
                                end
                        end
                    end
                end
            end
        end
    end    
if first_spwan == true then
if type(respwan_table) == "table" then
local obj,count,tbl_cnt = nil,0,#respwan_table 

for k,v in pairs(respwan_table) do
obj = alife():object(k)

if obj == nil then
k = respwan_npc_name
v = nil   
if timer_repswan == 0 then timer = time_global() + math.random(36, 60) end
    if db.actor:alive() then
        if time_global() > timer_repswan then
            timer_repswan = 0  
            spawn = alife():create(respwan_npc_name, vector():set(-61.996055603027, 0.92057931423187, 293.67742919922), db.actor:level_vertex_id(), db.actor:game_vertex_id())
            respwan_table[spawn.id] = true
        end
    end
end
end
end
end
end

in the next part of the script the table checked wether the npc is dead

is the nc dead a timmer start and after the timer the npc will respwan

i hope anyone can understand this

sorry for my bad englisch

but when i kill a npc ,the npc dont respwan but why?

can anyoen help me?

thank youolaf1, olaf1, olaf1,

Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

can anyone help me??

i have write a script wich shll respwan npcґs in any level

i hope you can see what for what is and i hope that anyone help me.

when you have question to my script the ask me.

local respwan_table = {}
local timer = nil
local levels = {marsh=            {x=-61.996055603027,y=0.92057931423187,z=293.67742919922}
                }
                
local respwan_npc = {
mar_clear_sky_respawn_1 = true,
mar_clear_sky_respawn_2 = true,
mar_clear_sky_respawn_3 = true,
}


function spwan()
if db.actor:alive() == false then return end
            local level_name = level.name()
                    if timer == nil then
                            timer = level.get_time_hours() + math.random(3, 6)
                            if timer > 23 then timer = timer - 24 end
                    end
                    if time_global() > timer then
                            timer = nil
                            for lvl, pos in pairs(levels) do
                                if level_name == lvl then 
                                            local pos = vector():set(pos.x, pos.y, pos.z)
                                            local lvi = db.actor:level_vertex_id()
                                            local gvi = db.actor:game_vertex_id()
                                    for npc,spwan in pairs(respwan_npc)do
                                        if spwan == true then
                                               respwan_table[alife():create("mar_clear_sky_respawn_1", pos, lvi, gvi).id] = true
                                            table.insert(respwan_npc,2,false)
                                           end
                                    end
                                end
                            end
                            
           end   
           local tbl_count,obj = 1,nil
           for k,v in pairs(respwan_table) do
                   obj = db.storage[k] and db.storage[k].object
                        if obj and obj:alive() == false and v == true then
                       table.insert(respwan_npc,2,true)   
                       end
          end
end

but when i start the game i get a crash but in the log are nothing

can anyone help me away?

thank you.

Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение

Этот код предназначен для проверки respwan_npc второй позади = истинное, если он верен ему в таблице (respwan_table) NPC gespwant вплоть до уровня

 

, а затем положил обратно в таблице respwan_npc значение ложной

 

for npc,spwan in pairs(respwan_npc)do
    if spwan == true then
        respwan_table[alife():create("mar_clear_sky_respawn_1", pos, lvi, gvi).id] = true
        table.insert(respwan_npc,2,false)
    end
end

 

Поделиться этим сообщением


Ссылка на сообщение

Artos,

 

Извините, но я не могу понять, что вы говорите с Вашими ответами russic.

 

respwan_npc = {
  ["mar_clear_sky_respawn_1"] = true,
  [2] = false,
  [3] = false,
  ...
  [NNN] = false,
  ["mar_clear_sky_respawn_2"] = true,
  ["mar_clear_sky_respawn_3"] = true,
}

 

Что я могу участвовать в этом?

что это

[NNN] = false

 

спасибо

Поделиться этим сообщением


Ссылка на сообщение

Я могу хранить данные, предназначенные или функции?

 

было бы очень приятно для меня jemadn помогает, потому что у меня есть сценарий все NPC, когда я приглашаю spwant новый, но я просто хочу, даже если они мертвы

 

потому, что кто-то может сказать, как я могу сделать это

 

local respwan_table = {}
local timer = nil
local spwan = false
local levels = {marsh=            {x=-61.996055603027,y=0.92057931423187,z=293.67742919922}, 
                l01_escape=        {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
                l02_garbage=    {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
                l03_agroprom=    {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
                l04_darkvalley=    {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
                l05_bar=        {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
                l06_rostok=        {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
                l07_military=    {x=-61.996055603027,y=0.92057931423187,z=293.67742919922},
                l08_yantar=        {x=-61.996055603027,y=0.92057931423187,z=293.67742919922}}

function spwawn()
    if db.actor:alive() == false then return end
    local level_name = level.name()
    if spwan == false then
        if timer == nil then 
            timer = level.get_time_hours() + math.random(3, 6) 
            if timer > 23 then timer = timer - 24 end
        end
        if time_global() > timer then
            timer = nil
            for lvl, pos in pairs(levels) do
                if level_name == lvl then
                    spwan = true
                    local pos = vector():set(pos.x, pos.y, pos.z)
                    local lvi = db.actor:level_vertex_id()
                    local gvi = db.actor:game_vertex_id()
                    respwan_table[alife():create("mar_clear_sky_respawn_1", pos, lvi, gvi).id] = true
                    respwan_table[alife():create("mar_clear_sky_respawn_2", pos, lvi, gvi).id] = true
                    respwan_table[alife():create("mar_clear_sky_respawn_3", pos, lvi, gvi).id] = true
                end
            end
        end
    elseif spwan == true then
        local tbl_count,obj = 0,nil
        for k,v in pairs(respwan_table) do
            obj = db.storage[k] and db.storage[k].object
            if obj and obj:alive() == false and v == true then
                v = false
            else
                tbl_count = tbl_count + 1
            end
        end
        if tbl_count == 0 then 
            respwan_table = {}
            spwan = false 
        end
    end
end

 

спасибо

 

Hide your code under the spoiler. Cyclone

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

Как я могу спросить, если NPC мертв в сценарии?

какой из них подходит?

local npc
local npc_dead = db.storage[npc:id()].death

или

npc = level_object_by_sid(p[1])
return not npc or not npc:alive()

или иного сценария?

может ли кто-нибудь сказать мне об этом

спасибо

Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

Как я могу продолжать использовать, потому что, когда я делаю это с помощью скрипта и хочет использовать его в качестве условного if?

Я даже не могу в результате чего я

if npc then
  return npc:alive() == false
end
if npc:alive() == false then
......

кто-то может помочь мне, потому что?

спасибо

 

Изменено пользователем Artos

Поделиться этим сообщением


Ссылка на сообщение

Я прошу следующее

 

У меня есть скрипт, который будет сидеть НПС respwanen но проблема в том, что они gespwant снова и снова anchdem я перезагрузить его, а не тогда, когда они умерли, что они на самом деле.

 

Как мне справиться с этой, так как скрипт хранится и как я могу взять эту я знаю, к сожалению, пока нет.

 

Благодарю вас, прежде чем

 

 

local respwan_table = {}

local timer = nil

local levels = {marsh= {x=-61.996055603027,y=0.92057931423187,z=293.67742919922} }

 

local respwan_npc = {

["mar_clear_sky_respawn_1"] = true,

["mar_clear_sky_respawn_2"] = true,

["mar_clear_sky_respawn_3"] = true,

}

 

 

function spwanen()

if db.actor:alive() == false then return end

local level_name = level.name()

local coordinates = levels[level_name]

if coordinates then

local pos = vector():set(coordinates.x, coordinates.y, coordinates.z)

local lvi = db.actor:level_vertex_id()

local gvi = db.actor:game_vertex_id()

for section,flag in pairs(respwan_npc)do

if flag == true then

if timer == nil then

timer = level.get_time_hours() + math.random(3, 6)

if timer > 23 then timer = timer - 24 end

end

if time_global() > timer then

timer = nil

local se_obj = alife():create(section, pos, lvi, gvi)

respwan_table[se_obj.id] = section

respwan_npc[section] = false

end

end

end

end

end

 

for id,section in pairs(respwan_table) do

local obj = db.storage[id] and db.storage[id].object

if not obj or obj:alive() == false then

respwan_npc[section] = true

respwan_table[id] = nil

end

end

 

 

 

 

 

 

 

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

So you want that I write better in English.

I have a problem if I ever will, and reload again and again the NPC's as often as I want but I want to reload respectively only if they want to be, respectively, they are dead.

I've heard that you can grab something eo something similar or something like

packet: w_u16 (self.m_restrictor_id)

But I know that I do not look as good that would be very nice if someone would do this for me.

the code is better than the

time_global

as

level.get_time_hours

?

I test this.

I would like to save this and have also saved and can read it but I know myself so unfortunately not so well marked and not a tutorial for it

i hope that is better to understand for you and other.

Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

hey

will you that i writ it so?

that when i have has_alife_info thrn

spwan this npc?

but when the respwant npc is dead when will he respwan?

and i have no gulag i have only a logic script.

can you help me away or a other?

thank you

 

Желающие помочь/ответить иностранному гостю - пишите, плз, ему в ЛС.

ИМХО, пока прекращать эти потуги и практически бесплезную болтологию на англо-русско-луашном сленге, только засоряющую топик ... --/Artos

 

Добавлено через 120 мин.:

why ?

you will not help me Artus?

 

i have a problem by this every i laod again the npc´s will respwan but that i don´t will must i save it?

but how i can save it?

 

 

thank you

Изменено пользователем Artos

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

Oh i have some misspelling in englisch sorry for that but that can you make too in Russian.

And this i have read ,too but it is not that what i will by that the npcґs where delet from the List(clear) and this give by me a cras as i have test it.

But i will respwan NPCґs.

But i donґt know how i can save it and i have not find somthing abut it (which I do believe)

This is the problem not the re_spwan.script that i donґt need.

The re_spwan.script is only i think for gulags and by me the gualgs get a crash and i have make all but it work not.

And then i have found a text in the englisch forum of GSC-Forum that logic script are better then the gulags then i will make logic script but the NPCґs respwan by this not ;(

And then i have an Idea that i can writ a script the spwan script is easy but the repswan that i donґt can and is very hard.

But this where very nice when you ot an other can help me.

I donґt know why this only make how it wants speak the npcґs are spwan when i save and load the game again but this i donґt will and i have not find somethinh about that.

I hope that anyone will help me.

Thnak you.

Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

Однажды я спросил ее один надеюсь, что я ответил на него так или иначе?

Я хотел бы знать, можно ли написать скрипт с файла LTX и сохранить то, если да, то как?

 

Благодарю вас, прежде чем

 

I hope you will help me continue anyway?

 

I would like to know whether you can write a script with an ltx file and save it then if so how?

 

thank you before

 

rus: Правилами форума запрещено дублировать один и тот же вопрос.

eng: Rules of a forum it is forbidden to duplicate the same question.

--/Artos

 

Добавлено через 54 мин.:

ой извините, но ознакомиться с правилами и понять, то после того, как переводится это действительно трудно.

 

rus: Не знание и/или непонимание правил не освобождает от ответственности их нарушения.

eng: Not the knowledge and/or misunderstanding of rules doesn't relieve from responsibility of their violation.

--/ Artos

 

Строгое предупреждение от модератора ColR_iT
Запрещено оставлять сообщения, содержащие чрезмерное количество грамматических и пунктуационных ошибок.
Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение

Вы можете дать мне небольшой пример простого кода для этого?

 

спасибо

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

Вы имеете в виду это произойдет в конце концов?

Я уже сделал это здесь

local ltx = ini_file("respawn\\respwaner.ltx")

function spwanen()
if db.actor:alive() == false then return end
    local level_name = level.name()
        if ltx then
            if ltx:section_exist("respawns") then
            local respwan_haupt = read_section(ltx, "respawns")
                for respwans,bool in pairs(respwan_haupt) do
                    if bool == true then
                        if ltx:section_exist(respwans) then
                        local level = ltx:r_bool(respwans,"level")
                            if level_name == level then 
                            local sections = ltx:r_bool(respwans,"sections") 
                            local position = ltx:r_bool(respwans,"position") 
                            local pos = vector():set(position)
                            local lvi = db.actor:level_vertex_id()
                            local gvi = db.actor:game_vertex_id()
                            local se_obj = alife():create(section, pos, lvi, gvi)
                            datei = io.open("respawn\\respwaner.ltx", "w")


                        end
                    end
                end
            end
        end        
    end
end

 

и это LTX файл

[respawns]
mar_clear_sky_respawn_1 = true
mar_clear_sky_respawn_2 = true
mar_clear_sky_respawn_3 = true


[mar_clear_sky_respawn_1]
level = marsh
sections    = mar_clear_sky_respawn_1
position = -61.996055603027,0.92057931423187,293.67742919922



[mar_clear_sky_respawn_2]
level = marsh
sections    = mar_clear_sky_respawn_2
position = 61.996055603027,0.92057931423187,293.67742919922



[mar_clear_sky_respawn_3]
level = marsh
sections    = mar_clear_sky_respawn_3
position = -61.996055603027,0.92057931423187,293.67742919922

 

 

и как я могу написать книгу сейчас LTX особенность файла, так что, что?

Я сказал, да hbae книга теперь с "W", что я напишу об этом, но я могу сказать Вам точно, где

 

спасибо

 

Cколько же вам можно твердить, что библиотека io (Input-Output) ОТСУТСТВУЕТ в оригинальной игре "S.T.A.L.K.E.R.: \'Shadow Of Chernobyl"!

И кем же нужно быть (?), чтобы как вы, имея версию именно SHOC (v.1.0004), продолжать пытаться писать коды с использованием:

datei = io.open("respawn\\respwaner.ltx", "w")

- Не возможно применение данной библиотеки в вашем случае!

--/Artos

 

Строгое предупреждение от модератора ColR_iT
Запрещено оставлять сообщения, содержащие чрезмерное количество грамматических и пунктуационных ошибок.

Сутки чтения.

Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение
(изменено)

У меня есть вопрос о LW группы мод АМК.

В этом пространстве, как я могу появляться NPC мод?

Respwnen, но не раз?

У этого, но это уже verscuht программное обеспечение устанавливается только не всегда аварии и ничего в журнале

vPos = vector():set(-172.94567871094,1.1770851612091,403.09545898438)

oNpc = alife():create("mar_clear_sky_first_stalker_2", vPos,55978,3361)

local tData = net_packet_read.GetStalker(oNpc)

tData.iUpdHealth = 0

net_packet_write.SetStalker(tData, oNpc)

 

и даже здесь

 

local oIni = ini_file("spawn\\spwaner.ltx")

function spwan()

if not has_alife_info("spwan_only_one_npc") then

 

if oIni:section_exist("spawns") then

for iKey = 0, oIni:line_count("spawns") - 1 do

local bResult, sRespawn, sValue = oIni:r_line("spawns", iKey, "", "false")

if bResult and sValue == "true" and oIni:section_exist(sRespawn) then

 

local tData = {}

 

tData["RespawnSections"] = ReadLine(oIni, "String", sRespawn, "sections")

tData["MaxSpawn"] = ReadLine(oIni, "Number", sRespawn, "max_spawn", 1)

tData["MaxCount"] = ReadLine(oIni, "Number", sRespawn, "max_count", tData["MaxSpawn"])

tData["MinCount"] = ReadLine(oIni, "Number", sRespawn, "min_count", tData["MaxCount"])

tData["Conditions"] = ReadLine(oIni, "String", sRespawn, "conditions", 100)

tData["iIdleSpawn"] = ReadLine(oIni, "String", sRespawn, "idle_spawn", "medium")

tData["sLogic"] = ReadLine(oIni, "String", sRespawn, "logic", "nil")

tData["sCount"] = ReadLine(oIni, "String", sRespawn, "count", "nil")

 

local sPosition = ReadLine(oIni, "String", sRespawn, "position")

local tPos = SplitString(sPosition, 1, ",")

 

local sCustomData = "[respawn]\n" ..

"name = "..sRespawn.."\n" ..

"respawn_section = "..tData["RespawnSections"].."\n" ..

"max_spawn = "..tData["MaxSpawn"].."\n" ..

"idle_spawn = "..tData["iIdleSpawn"].."\n" ..

"conditions = "..tData["Conditions"].."\n" ..

"logic = "..tData["sLogic"].."\n" ..

"count = "..tData["sCount"]

 

local vPos = vector():set(tonumber(tPos[1]), tonumber(tPos[2]), tonumber(tPos[3]) )

local oRespawn = alife():create("respawn", vPos, tonumber(tPos[4]), tonumber(tPos[5]) )

 

tData = net_packet_read.GetStalker(oRespawn)

 

tData.tShape = {}

tData.tShape[1] = {}

tData.tShape[1].iShapeType = 0

tData.tShape[1].iRadius = 1

tData.tShape[1].vCenter = vector():set(0, 0, 0)

 

tData.sCustomData = sCustomData

 

net_packet_write.SetStalker(tData, oRespawn)

 

 

end

end

end

end

db.actor:give_info_portion("spwan_only_one_npc")

end

 

 

Я надеюсь, что вы можете помочь мне, что.

Спасибо!

 

Строгое предупреждение от модератора ColR_iT
Ведь предлагал задавал вопросы на родном языке и дополнительно перевод на русский, оба варианта пряча под спойлер. Но нет ...

За отсутствие правописания в тексте 7 суток чтения, как регулярное нарушение.

Изменено пользователем ColR_iT

Поделиться этим сообщением


Ссылка на сообщение
  • Недавно просматривали   0 пользователей

    Ни один зарегистрированный пользователь не просматривает эту страницу.

AMK-Team.ru

×
×
  • Создать...