Hello,
this is my first lua script. I can not test it, so feel free to correct me
What it do:
If you destroy a entity, you can repair it later.
My plan: It is the start for some cod zombie scripts
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Collects Key
function PlankRestore_init(e)
a = 0
entity_startHealth[e]= nil
end
function PlankRestore_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX;
PlayerDY = g_Entity[e]['y'] - g_PlayerPosY;
PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if entity_startHealth[e] == nil then
entity_startHealth[e] = g_Entity[e]['health']
end
if PlayerDist < 150 then
SourceAngle = g_PlayerAngY
while SourceAngle < 0.0 do
SourceAngle = SourceAngle + 360.0
end
while SourceAngle > 340.0 do
SourceAngle = SourceAngle - 360.0
end
DestAngle = math.atan2( PlayerDZ , PlayerDX )
-- Convert to degrees
DestAngle = (DestAngle * 57.2957795) - 90.0
Result = math.abs(math.abs(SourceAngle)-math.abs(DestAngle))
if Result > 180 then
Result = 0
end
if entity_startHealth[e]>g_Entity[e]['health'] then
CollisionOff(e)
Hide(e)
end
if Result < 20.0 then
if entity_startHealth[e]>g_Entity[e]['health'] then
Prompt ("Hold E To repair Planks")
end
if g_KeyPressE == 1 and entity_startHealth[e]>g_Entity[e]['health'] and a == 0 then
StartTimer(e)
a=1
end
if g_KeyPressE == 1 and GetTimer(e) >= 1000 then
CollisionOn(e)
Show(e)
g_Entity[e]['health'] = entity_startHealth[e]
PromptDuration("Repaired",3000)
PlaySound(e,0)
a = 0
end
end
end
end
Corno_1
My dream is to develope games, which makes fun when I create it and fun when other people play it.