-- LUA Script - precede every function and global member with lowercase name of script + '_main' -- Player Collects Ammo local ammoSpawn = {} local ammoTimeset = {} local TS1 = {} local TS2 = {} local Ax = {} local Ay = {} local Az = {} function test_ammo_init(e) Ax[e] = 0 Ay[e] = 0 Az[e] = 0 end function test_ammo_main(e) --PromptLocal(e,"ID: "..e) RotateY(e,40) PlayerDist = GetPlayerDistance(e) if PlayerDist < 60 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 then PromptDuration("Collected ammo",3000) PlaySound(e,0) Ax[e] = g_Entity[e]['x'] Ay[e] = g_Entity[e]['y'] Az[e] = g_Entity[e]['z'] AddPlayerAmmo(e) SetPosition(e,Ax[e]-1000,Ay[e]+1000,Az[e]-1000) Hide(e) ammoSpawn[e] = 1 ammoTimeset[e] = 0 --Destroy(e) ActivateIfUsed(e) end if ammoSpawn[e] == 1 and ammoTimeset[e] == 0 then TS1[e] = GetTimer(e) ammoTimeset[e] = 1 end if ammoTimeset[e] == 1 then TS2[e] = GetTimer(e) if TS1[e] + 8000 < TS2[e] then TS1[e] = GetTimer(e) SetPosition(e,Ax[e],Ay[e],Az[e]) Show(e) PlaySound(e,1) ammoSpawn[e] = 0 ammoTimeset[e] = 0 end end end