pressed = 0 function thirdp_projectile_ammo_init_name(e,name) weapon_name[e] = name end function thirdp_projectile_ammo_main(e) if gun_number == nil then return end if PlayerLooking(e,150,20) == 1 and g_PlayerHealth > 0 then x1 = GetEntityPositionX(e) y1 = GetEntityPositionY(e)+0.5 z1 = GetEntityPositionZ(e) y2 = g_PlayerPosY x2 = g_PlayerPosX z2 = g_PlayerPosZ obstructionhit = IntersectAll(x2,y2,z2,x1,y1,z1,g_Entity[e]['obj']) if obstructionhit == nil then obstructionhit = 0 end if obstructionhit == g_Entity[GetGamePlayerControlThirdpersonCharactere()]['obj'] then Prompt("Collect "..weapon_name[e].."?") if g_KeyPressE == 1 and pressed == 0 then for a,_ in pairs (fired) do if string.find(weapon_name[e],weapon_name[a]) ~= nil then pressed = 1 if projectile_ammo[gun_number] < max_projectile_ammo[gun_number] then PromptDuration("Collected "..weapon_name[e],3000) PlaySound(e,0) projectile_ammo[gun_number] = projectile_ammo[gun_number]+g_Entity[e]['health'] if projectile_ammo[gun_number] > max_projectile_ammo[gun_number] then projectile_ammo[gun_number] = max_projectile_ammo[gun_number] end Destroy(e) break end end end end else end if g_KeyPressE == 0 then pressed = 0 end end end function thirdp_projectile_ammo_exit(e) end function PlayerLooking(e,dis,v) if g_Entity[e] ~= nil then if dis == nil then dis = 3000 end if v == nil then v = 0.5 end if GetPlayerDistance(e) <= dis then local destx = g_Entity[e]['x'] - g_PlayerPosX local destz = g_Entity[e]['z'] - g_PlayerPosZ local angle = math.atan2(destx,destz) angle = angle * (180.0 / math.pi) if angle <= 0 then angle = 360 + angle elseif angle > 360 then angle = angle - 360 end while g_PlayerAngY < 0 or g_PlayerAngY > 360 do if g_PlayerAngY <= 0 then g_PlayerAngY = 360 + g_PlayerAngY elseif g_PlayerAngY > 360 then g_PlayerAngY = g_PlayerAngY - 360 end end local L = angle - v local R = angle + v if L <= 0 then L = 360 + L elseif L > 360 then L = L - 360 end if R <= 0 then R = 360 + R elseif R > 360 then R = R - 360 end if (L < R and math.abs(g_PlayerAngY) > L and math.abs(g_PlayerAngY) < R) then return 1 elseif (L > R and (math.abs(g_PlayerAngY) > L or math.abs(g_PlayerAngY) < R)) then return 1 else return 0 end else return 0 end end end