HI all.
I want to start this thread for only one reason, and that is to say thank you.
Thanks to all the modelers and programmers and anyone else who has given me free models or free scripts or free advice or just an inspiring thought.
So i want to say thank you by giving away any scripts that i have that can maybe help other users.
i know exactly how it feels if you have an idea that feels brilliant but you do not have the models or the scripts to go with it.
so any free script that can help to make a project / game better is always welcome.
hopefully some people will be able to use some of the scripts that i will post here.
i am a slow learner so don't expect to see a lot of scripts coming in. but as soon as i have some scripts that can be of use i will post it here.
no fancy scripts at this time , but plain ones that can do useful stuff.
Please bear in mind i am a newbie here , i am no programmer, my programming skills are at a level of learn as you play.
So for all the programmers out there when i make mistakes , and i will , feel free to correct me, or if you just want to make the scrip better also feel free to do that and also if you want , post the modified script here again to help anyone who wants to use it.
Ok so i have this 3 scripts to determent if a player is inside or out side off a building.
i know there is scripts out there that also cover this but this is my take on it.
the difference of my script is i use g_time in the zone scripts to get like a time stamp the see when the player goes in or out of a zone.
this helps so the player can not move in and out between the zones and try to confuse the game .
1. player_in_or_out.lua
2. outside_zone. lua
3. inside_zone.lua
--- Pcs
p_inside = 0 ------ variable to use in other scripts
p_outside = 0 ------ variable to use in other scripts
t_stamp_out = 0
t_stamp_in = 0
function player_in_or_out_init(e)
end
function player_in_or_out_main(e)
if t_stamp_out > 0 and t_stamp_in > 0 then
if t_stamp_out > t_stamp_in then
p_outside = 1
p_inside = 0
Prompt("player is outside") ----- remember to remove this line
end
if t_stamp_in > t_stamp_out then
p_inside = 1
p_outside = 0
Prompt("player is inside") ----- remember to remove this line
end
end
end
--- Pcs
function inside_zone_init(e)
inonce = 0
t_stamp_in = 0
end
function inside_zone_main(e)
if g_Entity[e]['plrinzone']== 1 and inonce == 0 then
ActivateIfUsed(e)
inonce = 1
t_stamp_in = g_Time
end
if g_Entity[e]['plrinzone']~= 1 then
inonce = 0
end
end
--- Pcs
function outside_zone_init(e)
outonce = 0
t_stamp_out = 0
end
function outside_zone_main(e)
if g_Entity[e]['plrinzone']== 1 and outonce == 0 then
ActivateIfUsed(e)
outonce = 1
t_stamp_out = g_Time
end
if g_Entity[e]['plrinzone']~= 1 then
outonce = 0
end
end
This picture also explain were you have to place the zones if you have a building with more than one entrance.
i know you can just use one big zone in the test map were you have a flat normal surface,
but as soon as you have a complex building or a building with elevated levels it helps to place the zones at the in and out side of each door.
you can use as many zone's as you like depending on how many doors the building have.
i also have attached the test map so that you can test the scripts. just put the scripts in the script bank and re select them , because i run them out of my own folder.
i hope this can help someone.
Please correct me if i have done any mistakes.
Thank you.
Pcs.
Windows 7 Professional 64-bit
Intel(R) Pentium(R) CPU G3260 @ 3.30GHz (2 CPUs), ~3.3GHz RAM 16GB NVIDIA GeForce GT 730
DirectX Version: DirectX 11