Created
October 25, 2017 07:24
-
-
Save kkm/933fedf25ec0583e40df4c563e9ae30b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Hammer Marker and Resource Tracker | |
-- by: kkm | |
-- | |
-- Hammer Marker (Tracker) for Firefall Addon with squad hammer and resource share in realtime | |
require "math"; | |
require "string"; | |
require "table"; | |
require "lib/lib_Slash"; --Command | |
require "lib/lib_MapMarker"; --Marker | |
require "lib/lib_Callback2"; --Timer | |
require "lib/lib_InterfaceOptions"; | |
require "lib/lib_Items"; --Info Resource | |
--system\gui\components\MainUI\HUD\ResourceMonitor | |
local c_RawToRefinedConversion = { | |
["78014"] = "77703", --Copper | |
["78015"] = "77704", --Iron | |
["78016"] = "77705", --Aluminum | |
["78017"] = "77706", --Carbon | |
["78018"] = "77707", --Silicate | |
["78019"] = "77708", --Ceramics | |
["78020"] = "77709", --Methine | |
["78021"] = "77710", --Octine | |
["78022"] = "77711", --Nitrine | |
["82420"] = "82419", --Radine | |
["78023"] = "77713", --Petrochemical | |
["78024"] = "77714", --Biopolymer | |
["78025"] = "77715", --Xenografts | |
["78026"] = "77716", --Toxins | |
["78027"] = "77736", --Regenics | |
["78028"] = "77737", --Anabolics | |
["82628"] = "82628" --Melded_Crystite | |
} | |
local lineChat = 1; | |
local lineArray = {}; | |
local rowLine = 1; | |
local timer = Callback2.Create() --Timer Loop | |
local MARKER_SLASH_CMDS = {}; -- Slash | |
local markerList = {}; | |
local markers = {}; | |
local markersRes = {}; | |
local markersResList = {}; | |
local markersResTypeList = {}; | |
local resInsert = {}; | |
local key = nil; | |
local currentId = 0; | |
local lastupdate = "0"; | |
local lupdate = "0"; | |
local instanceId = ""; | |
local me = nil; --my.php | |
local step = 1; | |
local login = false; | |
local hide = false; | |
local player_name; | |
local version = "0.8"; | |
local host = "firefall.d3af.info"; | |
local const_Abil_ScanHammer = "34503"; | |
local const_SiftedEarth = "30404"; | |
local backColor = ""; | |
local logAlpha = 1; | |
local distance; | |
local single; | |
local thump; | |
local zoom; | |
local colorme = nil; | |
local submit = false; | |
local scanfadeout; | |
local synctimer; | |
local ago; | |
local hmago; | |
local clean = nil; | |
local iconAlpha = 1; | |
--CONSTANTS | |
local FRAME = Component.GetFrame("HMARKER") | |
local POI_FRAME = Component.GetFrame("POI") | |
local MFrame = Component.GetWidget("ResourceLog") | |
-- INTERFACE OPTIONS INFO | |
require "lib/lib_InterfaceOptions" | |
InterfaceOptions.AddMovableFrame({ | |
frame = FRAME, | |
label = "--Hammer MARKER--", | |
scalable = true, | |
}) | |
InterfaceOptions.AddMovableFrame({ | |
frame = POI_FRAME, | |
label = "--POI LOG--", | |
scalable = true, | |
}) | |
InterfaceOptions.StartGroup({id="ENABLED", label="Hammer Marker VIP " .. version}) | |
InterfaceOptions.AddTextInput({id="HASH_KEY", label="http://firefall.d3af.info/key/", default="##################", maxlen=18,tooltip="Anmeldung"}); | |
InterfaceOptions.AddColorPicker({id="HM_COLOR", label="Hammer Icon Farbe", default={tint="#FFFF00"}}) | |
--InterfaceOptions.AddSlider({id="HM_AGO", label="HM Zeit ausblenden ab", min=1, max=24, inc=1, format="%0.0f", suffix="h", default=1, tooltip="/rui benötigen"}) | |
InterfaceOptions.AddCheckBox({id="CLEAN", label="Anmeldung Hammer Marker löschen", default=false,tooltip="Hammer Marker löschen nach dem Anmeldung wenn gleiche Instanz"}); | |
InterfaceOptions.AddSlider({id="ICON_ALPHA", label="Hammer Icon Transparenz", min=0, max=100, inc=1, format="%0.0f", suffix="%", default=70 }) | |
InterfaceOptions.AddSlider({id="ZOOM", label="Hammer Markierung Zoom ab", min=1, max=5, inc=1, format="%0.0f", suffix="x", default=2, tooltip="/rui benötigen"}) | |
InterfaceOptions.StopGroup(); | |
InterfaceOptions.StartGroup({id="HM", label="Rohstoffe (Online)"}) | |
InterfaceOptions.AddColorPicker({id="LOG_COLOR", label="Log Hintergrund", default={tint="#FF00FF"}}) | |
InterfaceOptions.AddCheckBox({id="THUMP", label="Während Thumper Marker ausblenden", default=false,tooltip="Rohstoffe und Hammer Markierung"}); | |
InterfaceOptions.AddSlider({id="SYNC", label="Rohstoffe synchronisieren", min=1, max=5, inc=1, format="%0.0f", suffix="s", default=2, tooltip="/rui benötigen"}) | |
InterfaceOptions.AddSlider({id="SCANREPORT_ALPHA", label="Standart Scanbericht ausblenden", min=0, max=120, inc=1, format="%0.0f", suffix="s", default=5 }) | |
InterfaceOptions.AddSlider({id="AGO", label="Rohstoffe Zeit ausblenden ab", min=1, max=24, inc=1, format="%0.0f", suffix="h", default=1, tooltip="/rui benötigen"}) | |
InterfaceOptions.AddSlider({id="DISTANCE", label="Blende Scans aus nach", min=0, max=1000, inc=1, format="%0.0f", suffix="m", default=500 }) | |
InterfaceOptions.AddSlider({id="LOG_ALPHA", label="Log Hintergrund Transparenz", min=0, max=100, inc=1, format="%0.0f", suffix="%", default=100 }) | |
InterfaceOptions.AddSlider({id="SINGLE", label="Single Rohstoffe Transparenz", min=0, max=100, inc=1, format="%0.0f", suffix="%", default=50 }) | |
InterfaceOptions.StopGroup(); | |
InterfaceOptions.StartGroup({id="credits", label="Credits"}) | |
InterfaceOptions.AddCheckBox({id="coder", label="Programmierung: kkm aka DeafMassacre", default=false}); | |
InterfaceOptions.AddCheckBox({id="coder1", label="Thanks to: DeafCrank | DeafCortison", default=false}); | |
InterfaceOptions.StopGroup(); | |
---------------------------------------------------------- | |
-- On Load | |
-- ------------------------------------------------------- | |
function OnLoad() | |
player_name = Player.GetInfo(); | |
--Interface Callback | |
InterfaceOptions.SetCallbackFunc(function(id, val) OnMessage({type=id, data=val}) end, "Hammer Marker VIP"); | |
InitializeSlashCommands(); | |
HTTP.IssueRequest(host, "POST", nil, HTTP_checkOnline); | |
callback(function() ShowDisplayMarker(); end, nil, 1); | |
end | |
function HTTP_checkOnline(args, err) | |
if (err.status == 0) then | |
print_system_message("Oops, Hammer Marker Server ist down.") | |
end | |
end | |
-- world map or F9 hide | |
function OnShow(args) | |
FRAME:ParamTo("alpha", tonumber(args.show), args.dur); | |
POI_FRAME:ParamTo("alpha", tonumber(args.show), args.dur); | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- Interface Input Event Handler | |
-- ------------------------------------------------------- | |
function OnMessage(args) | |
instanceId = Chat.GetInstanceID(); | |
if(args.type == "HASH_KEY") then | |
key = args.data; | |
elseif(args.type == "LOG_COLOR") then | |
backColor = tostring(args.data['tint']); | |
elseif(args.type == "LOG_ALPHA") then | |
logAlpha = (args.data / 100) | |
elseif(args.type == "DISTANCE") then | |
distance = args.data; | |
elseif(args.type == "THUMP") then | |
thump = args.data; | |
elseif(args.type == "SINGLE") then | |
single = args.data; | |
elseif(args.type == "ZOOM") then | |
zoom = (args.data - 1) * 2 /10; | |
elseif(args.type == "HM_COLOR") then | |
colorme = args.data.tint; | |
elseif(args.type == "SCANREPORT_ALPHA") then | |
scanfadeout = args.data; | |
elseif(args.type == "SYNC") then | |
synctimer = args.data; | |
elseif(args.type == "AGO") then | |
ago = args.data; | |
elseif(args.type == "CLEAN") then | |
clean = args.data; | |
elseif(args.type == "ICON_ALPHA") then | |
iconAlpha = args.data; | |
elseif(args.type == "HM_AGO") then | |
hmago = args.data; | |
end | |
if (key ~= nil) and (colorme ~= nil) and (submit == false) and (clean ~= nil) then | |
if( clean == true) then | |
HTTP.IssueRequest(host.."/myclear.php", "POST", {key=key}, nil) --after log in every hammer marker clean up | |
end | |
instanceId = Chat.GetInstanceID(); | |
currentId = instanceId ; | |
HTTP.IssueRequest(host.."/my.php", "POST", {key=key,user=player_name,chatid=instanceId,color=tostring(colorme)}, Login); | |
submit = true; | |
end | |
end | |
function Login(args, err) | |
if (err) then | |
warn(tostring(err)); | |
else | |
for id, value in pairs(args) do | |
me = tostring(value[1]); | |
if string.byte(me) == 110 then --110 glaube fehler von string | |
login = false; | |
print_system_message("HammerMarker ClientID nicht erfolgreich."); | |
else | |
login = true; | |
print_system_message("Dein letzter Besuch war " .. tostring(value[3])); | |
step = tostring(value[2]) + 1; | |
end | |
end | |
--Login Fail return stop; | |
if login == false then | |
return; | |
end | |
--Squad Hammer and Resource in realtime | |
HammerSync(); | |
ResourceSync(); | |
end | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- Squad Hammer Sync | |
-- ------------------------------------------------------- | |
function HammerSync() | |
instanceId = Chat.GetInstanceID(); | |
--HTTP.IssueRequest(host.."/squadmarker.php", "POST", {key=key,id=tostring(lastupdate),chatid=instanceId,hours=hmago}, SquadHammerMarkerSync) | |
HTTP.IssueRequest(host.."/squadmarker.php", "POST", {key=key,id=tostring(lastupdate),chatid=instanceId}, SquadHammerMarkerSync) | |
callback(function() HammerSync(); end, nil, 4); | |
--check same instance e.g joinleader new instance number | |
if currentId ~= instanceId then | |
print_system_message("HammerMarker: bitte \"/rui\" in Chat Fenster eingeben"); | |
end | |
end | |
function SquadHammerMarkerSync(args, err) | |
if (err) then | |
warn(tostring(err)); | |
else | |
for id, value in pairs(args) do | |
local x = tostring(value[1]); | |
local y = tostring(value[2]); | |
local z = tostring(value[3]); | |
local user = tostring(value[4]); | |
local rstep = tostring(value[5]); | |
local datum = tostring(value[6]); | |
local degree = tostring(value[7]); | |
lastupdate = tostring(value[8]); --lastupdate like id | |
local color = tostring(value[9]); | |
SquadMarker(x,y,z,user .. ": " .. tostring(rstep), datum, degree,color); | |
end | |
end | |
end | |
function SquadMarker(x,y,z,titleText,datum,degree,color) | |
local markerInput = {}; | |
markerInput.x = x; | |
markerInput.y = y; | |
markerInput.z = z; | |
markerInput.color = tostring(color); | |
markerInput.markerId = tostring(round(markerInput.x,0))..math.random(1,1000); | |
markerInput.titleText = tostring(titleText); | |
markerInput.markerId = "HAMMERMARKER_"..tostring(markerInput.markerId); | |
markerInput.owner = tostring(Player.GetTargetId()); | |
markerInput.bodyText = "X:" .. x .. " Y:" .. y .. " Z:" .. z .. " ".. degree .."\194\176 \n" .. datum; | |
local sst = DegreeIcon(degree); | |
markerInput.iconName = sst; | |
local thisMarker = CreateMarker(markerInput); | |
markers[thisMarker:GetId()] = markerInput; | |
return thisMarker; | |
end | |
function CreateMarker(markerInput,remote) | |
local setColor; | |
setColor = markerInput.color; | |
local myMarker = MapMarker.Create(markerInput.markerId); | |
markerInput.pos = {}; | |
markerInput.pos.x = markerInput.x; | |
markerInput.pos.y = markerInput.y; | |
markerInput.pos.z = markerInput.z; | |
myMarker:SetTitle(markerInput.titleText) | |
myMarker:SetBodyText(markerInput.bodyText) | |
myMarker:BindToPosition(markerInput.pos) | |
myMarker:GetIcon():SetTexture("tracker_icons", markerInput.iconName) | |
myMarker:GetIcon():SetParam("tint", setColor) | |
myMarker:GetIcon():SetParam("glow", setColor); | |
myMarker:GetIcon():SetParam("scaleX", 2); --doent work? | |
myMarker:GetIcon():SetParam("scaleY", 2); | |
myMarker:GetIcon():SetParam("alpha", iconAlpha / 100); | |
myMarker:ShowOnWorldMap(true, zoom, 1); | |
markerList[myMarker:GetId()] = myMarker; | |
return myMarker; | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- Squad Resource Sync | |
-- ------------------------------------------------------- | |
function ResourceSync() | |
instanceId = Chat.GetInstanceID(); | |
HTTP.IssueRequest(host.."/squadresource.php", "POST", {key=key,chatid=instanceId,id=tostring(lupdate),hours=ago}, HTTP_SquadResource) | |
callback(function() ResourceSync(); end, nil, synctimer); | |
end | |
function HTTP_SquadResource(args, err) | |
if (err) then | |
warn(tostring(err)); | |
else | |
local resultMarker = {}; | |
for id, value in pairs(args) do | |
local markID = tostring(value['5']); | |
table.insert(resultMarker, markID); | |
insert = true; | |
--Check already Mark inserted | |
for ii,vv in pairs(resInsert) do | |
if (markID == vv) then | |
insert = false; | |
end | |
end | |
if(insert == true) then | |
local ar = {}; | |
ar.res_qual = {}; | |
ar.item = {}; | |
ar.percent = {}; | |
--Composition json extract | |
for ids, values in pairs(value['itemTypeId']) do | |
ar.item[ids] = tostring(value['itemTypeId'][ids]); | |
ar.res_qual[ids] = tostring(value['resource_quality'][ids]); | |
ar.percent[ids] = displayPercent(value['percent'][ids]); | |
end | |
ar.x = tostring(value['0']); | |
ar.y = tostring(value['1']); | |
ar.z = tostring(value['2']); | |
ar.user = tostring(value['3']); | |
ar.datum = tostring(value['4']); | |
ar.idy = markID; | |
table.insert(resInsert, tostring(value['5'])); | |
SquadResourceMarker(ar); | |
end | |
end | |
--Check remove comparison array index | |
for i,v in pairs(markersRes) do | |
local delete = true; | |
for ii,vv in pairs(resultMarker) do | |
local match = "HAMMERMARKER_"..tostring(vv); | |
if match == markersResList[i].id then | |
delete = false; | |
end | |
end | |
if delete == true then | |
markersResList[i].markerId= ""; | |
markersResList[i]:Destroy(); | |
markersRes[i] = nil; | |
markersResList[i] = nil; | |
end | |
end | |
end | |
end | |
function SquadResourceMarker(mark) | |
local markerInput = {}; | |
markerInput.x = mark.x; | |
markerInput.y = mark.y; | |
markerInput.z = mark.z; | |
markerInput.user = mark.user; | |
markerInput.markerId = "HAMMERMARKER_"..tostring(mark.idy); | |
--Resource Array Mixed web_icon,name,quality | |
markerInput.item = {}; | |
markerInput.item = mark.item; | |
markerInput.res_qual = {}; | |
markerInput.res_qual = mark.res_qual; | |
markerInput.percent = {}; | |
markerInput.percent = mark.percent; | |
markerInput.owner = tostring(Player.GetTargetId()); | |
markerInput.sourceName = mark.user .. ": " ..mark.datum; | |
local thisMarker = CreateMarkerSquadResource(markerInput); | |
markersRes[thisMarker:GetId()] = markerInput; | |
end | |
function CreateMarkerSquadResource(markerInput) | |
local myMarker = MapMarker.Create(markerInput.markerId); | |
markerInput.pos = {}; | |
markerInput.pos.x = markerInput.x; | |
markerInput.pos.y = markerInput.y; | |
markerInput.pos.z = markerInput.z; | |
local highestItem = 0; | |
local highest = {}; | |
highest.name = ""; | |
for i,v in pairs(markerInput.item) do | |
local percent = markerInput.percent[i]; | |
local quali = markerInput.res_qual[i]; | |
local item = v; | |
itemDetail = Game.GetItemInfoByType(tonumber(item)); | |
if highestItem < tonumber(quali) then | |
highestItem = tonumber(quali); | |
local aa = Game.GetItemInfoByType(c_RawToRefinedConversion[item]); | |
highest.web_icon = aa.web_icon; | |
highest.color = LIB_ITEMS.GetResourceQualityColor(highestItem); | |
highest.percent = percent; | |
highest.name = itemDetail.name; | |
end | |
local SHADOW = Component.CreateWidget("item_entry", myMarker:GetBody()) | |
SHADOW:GetChild("name"):SetText(itemDetail.name .. " " .. tostring(percent)); | |
SHADOW:GetChild("resource_quality"):SetText(quali); | |
qualityColor = LIB_ITEMS.GetResourceQualityColor(tonumber(quali)); | |
SHADOW:GetChild("resource_quality"):SetTextColor(qualityColor); | |
SHADOW:GetChild("icon"):SetUrl(tostring(itemDetail.web_icon)); | |
SHADOW:SetDims("left:-80; width:_; height:50; top:".. -50 + (i * 30) ..""); | |
end | |
local title = tostring(string.gsub(highest.name, "%^Q", "")); | |
myMarker:SetTitle(tostring(title .. " " .. highest.percent)); | |
local rowline = table.getn(markerInput.item); | |
local SHADOW = Component.CreateWidget("date", myMarker:GetBody()) | |
SHADOW:GetChild("name"):SetText(markerInput.sourceName); | |
SHADOW:SetDims("left:0; width:_; height:50; top:".. -20 + (rowline * 30) ..""); | |
myMarker:BindToPosition(markerInput.pos) | |
--myMarker:GetIcon():SetTexture("icons", "crystite") | |
myMarker:GetIcon():SetUrl(tostring(highest.web_icon)) | |
myMarker:GetIcon():SetParam("glow", highest.color) | |
myMarker:ShowOnHud(true); | |
--myMarker:ShowTrail(true); | |
--icon Mixed alpha | |
c = table.getn(markerInput.item); | |
if ( c > 1) then | |
myMarker:GetIcon():SetParam("alpha", 1); | |
else | |
myMarker:GetIcon():SetParam("alpha", single/100); | |
end | |
markersResList[myMarker:GetId()] = myMarker; | |
return myMarker; | |
end | |
function ShowDisplayMarker() | |
if hide == false then | |
for markerId,i in pairs(markersRes) do | |
local myMarker = markersResList[markerId]; | |
local myPos = Player.GetPosition(); | |
myMarker:ShowOnWorldMap(true); | |
myMarker:ShowOnRadar(true); | |
if IsInsideCircle(myPos.x, myPos.y, distance, myMarker.pos.x, myMarker.pos.y) == true then | |
myMarker:ShowOnHud(true) | |
else | |
myMarker:ShowOnHud(false) | |
end | |
end | |
else | |
for markerId,i in pairs(markersRes) do | |
local myMarker = markersResList[markerId]; | |
myMarker:ShowOnHud(false); | |
myMarker:ShowOnWorldMap(false); | |
myMarker:ShowOnRadar(false); | |
end | |
end | |
callback(function() ShowDisplayMarker(); end, nil, 0.1); | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- Action Hammer Scan | |
-- ------------------------------------------------------- | |
function OnScanHammer(args) | |
if(login == false) then | |
return; | |
end | |
if tostring(args.id) == const_Abil_ScanHammer then --Scan Hammer | |
local deg = round(GetDegrees()); | |
BuildPOI("Marker: " .. tostring(step), deg); | |
local ort = Player.GetPosition(); | |
instanceId = Chat.GetInstanceID(); | |
HTTP.IssueRequest(host .. "/myinsertmarker.php", "POST", {key=key, x=tostring(ort.x), y=tostring(ort.y), z=tostring(ort.z), step=tostring(step),degree=tostring(deg),chatid=instanceId},nil); | |
step = step + 1; | |
end | |
end | |
function OnResourceScanFailed(args) | |
if args.empty == true then | |
instanceId = Chat.GetInstanceID(); | |
HTTP.IssueRequest(host.."/myscanfailed.php", "POST", {key=key,data=tostring(args),chatid=instanceId}, nil) | |
end | |
end | |
function BuildPOI(titleText,degree) | |
local markerInput = {}; | |
local myPosition = Player.GetPosition() | |
markerInput.x = myPosition.x; | |
markerInput.y = myPosition.y; | |
markerInput.z = myPosition.z; | |
markerInput.markerId = tostring(round(markerInput.x,0))..math.random(1,1000); | |
markerInput.titleText = tostring(titleText); | |
markerInput.markerId = "HAMMERMARKER_"..tostring(markerInput.markerId); | |
local sst = DegreeIcon(degree); | |
markerInput.iconName = sst; | |
markerInput.owner = tostring(Player.GetTargetId()); | |
local datum = System.GetDate(); | |
markerInput.bodyText = "X:" .. round(markerInput.x) .. " Y:" .. round(markerInput.y) .. " Z:" .. round(markerInput.z) .. " ".. degree .."\194\176 \n" .. datum; | |
markerInput.color = "#" .. me; | |
local thisMarker = CreateMarker(markerInput); | |
markers[thisMarker:GetId()] = markerInput; | |
return thisMarker; | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- Resource Log Output | |
-- ------------------------------------------------------- | |
function MyWaypointEvent(args) | |
local thisScanDetails = {}; | |
local thisScan = {}; | |
thisScan.scanId = args.scanId; --ScanID | |
thisScanDetails = Game.GetResourceScanInfo(thisScan.scanId); | |
--Standart Scanbericht abschalten | |
callback(function() Game.AcceptResourceScan(args.scanId, false); end, nil, scanfadeout) | |
thisScan.x = thisScanDetails.x; | |
thisScan.y = thisScanDetails.y; | |
thisScan.z = thisScanDetails.z; | |
--Scan Hammer Playername | |
local ownerInfo = Game.GetTargetInfo(args.ownerId) | |
--Wenn noch keine Username hat bedeutet andere Instanz server. | |
if ownerInfo.name == nil then | |
return | |
end; | |
--Get the composition of the scan | |
thisScan.composition = thisScanDetails.composition; | |
local str = ""; | |
local mixed = 1; | |
local c = table.getn(thisScan.composition); | |
--Look up the name of the resources | |
for i, v in pairs(thisScan.composition) do | |
itemDetails = Game.GetItemInfoByType(v.itemTypeId) | |
thisScan.composition[i].itemTypeId = tonumber(v.itemTypeId); --It starts as an entity, but we want to store it as a number. | |
thisScan.composition[i].name = itemDetails.name; | |
thisScan.composition[i].quality = itemDetails.quality; | |
thisScan.composition[i].web_icon = itemDetails.web_icon; | |
--Info resource output log | |
if tostring(v.itemTypeId) ~= const_SiftedEarth then | |
moveChatLine(); | |
--Template XML Layout | |
local BP = Component.CreateWidget("ResourceLine", MFrame) | |
local LINE = { | |
GROUP = BP, | |
PLAYER = BP:GetChild("username"), | |
BACK_COLOR = BP:GetChild("backgroundColor"), | |
ICON = BP:GetChild("icon"), | |
SOURCE = BP:GetChild("source"), | |
PERCENT = BP:GetChild("percent"), | |
QUALITY = BP:GetChild("quality"), | |
} | |
--local stamp = System.GetDate(format) | |
str = tostring(string.gsub(thisScan.composition[i].name, "%^Q", "")); | |
local percent = thisScan.composition[i].percent; | |
LINE.SOURCE:SetText(str); | |
LINE.PERCENT:SetText(displayPercent(percent)); | |
--Trick mixed resource empty source text | |
if mixed > (c-2) then | |
LINE.PLAYER:SetText(rowLine..". "..ownerInfo.name..": "); | |
elseif c > 2 then | |
LINE.PLAYER:SetText("-"); | |
else | |
LINE.PLAYER:SetText(rowLine..". "..ownerInfo.name..": "); | |
end | |
local quality = thisScan.composition[i].resource_quality; | |
LINE.QUALITY:SetText(quality); | |
qualityColor = LIB_ITEMS.GetResourceQualityColor(quality); | |
LINE.QUALITY:SetTextColor(qualityColor); | |
log("********************f" .. v.itemTypeId); | |
local itemDetailss = Game.GetItemInfoByType(c_RawToRefinedConversion[tostring(v.itemTypeId)]); | |
LINE.ICON:SetUrl(itemDetailss.web_icon); | |
LINE.BACK_COLOR:SetParam("tint",backColor); | |
LINE.BACK_COLOR:SetParam("alpha", logAlpha); | |
--LINE.GROUP:ParamTo("alpha", 0, 5, 1); | |
--Array Line Chat | |
lineArray[lineChat] = LINE; | |
lineChat = lineChat + 1; | |
mixed = mixed + 1; | |
end | |
end | |
rowLine = rowLine + 1 ; | |
--Remove of Table list "Gesiebte Erde" | |
for i,v in pairs(thisScan.composition) do | |
if tostring(v.itemTypeId) == const_SiftedEarth then | |
table.remove(thisScanDetails.composition, i); | |
end | |
end | |
instanceId = Chat.GetInstanceID(); | |
HTTP.IssueRequest(host.."/myinserthistory.php", "POST", {data=tostring(thisScan), key=key, chatid=instanceId}, nil) | |
end | |
function moveChatLine() | |
for i,v in pairs(lineArray) do | |
lineArray[i].GROUP:SetDims("top:"..( 20 * 1 * (lineChat-i)).."; height:"..30); | |
end | |
local count = table.getn(lineArray); | |
--nur zwei zeilen anzeigen und rest fade out | |
for i,v in pairs(lineArray) do | |
if(i < count-1) then | |
lineArray[i].GROUP:ParamTo("alpha", 0, 15, 1); | |
end | |
end | |
--more than 7 hide | |
if(count > 5) then | |
for i,v in pairs(lineArray) do | |
if(i < (count - 5)) then | |
--Component.RemoveWidget(lineArray[i].GROUP) --problem wegen verschieben dann fehler | |
lineArray[i].GROUP:Hide(); | |
end | |
end | |
end | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- All Marker Hide and Show | |
-- ------------------------------------------------------- | |
function MarkersHideAll() | |
for i, v in pairs(markerList) do | |
MarkerHide(i); | |
end | |
--hide = true; | |
end | |
function MarkerHide(markerId) | |
local myMarker = markerList[markerId]; | |
myMarker:ShowOnHud(false); | |
myMarker:ShowOnWorldMap(false); | |
myMarker:ShowOnRadar(false); | |
end | |
function MarkersShowAll() | |
for i, v in pairs(markerList) do | |
MarkerShow(i); | |
end | |
--hide = false; | |
end | |
function MarkerShow(markerId) | |
local myMarker = markerList[markerId]; | |
myMarker:ShowOnWorldMap(true); | |
myMarker:ShowOnRadar(true); | |
end | |
function ClearSavedData() | |
for markerId, v in pairs(markers) do | |
DeleteUserMarker(markerId) | |
end | |
markers = {}; | |
markerList = {}; | |
end | |
function DeleteUserMarker(markerId) | |
if markers[markerId] ~= nil then | |
markerList[markerId]:Destroy(); | |
markerList[markerId] = nil; | |
markers[markerId] = nil; | |
end | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- OnTarget Event Handler (Thumper Monitor Join) | |
-- ------------------------------------------------------- | |
local thumpid = ""; | |
local listSquad = {}; | |
function OnTargetAvailable(args) | |
if args.type == "resourcenode" then | |
local thisThumper = Game.GetTargetInfo(args.entityId); | |
local thumpInfo = Game.GetTargetInfo(thisThumper.ownerId); | |
if thump then | |
local cc = table.getn(listSquad); | |
if cc ~= 0 then | |
for i,v in pairs(listSquad) do | |
if (v == thumpInfo.name) then | |
thumpid = tostring(args.entityId); | |
MarkersHideAll(); | |
hide = true; | |
end | |
end | |
else | |
if thumpInfo.name == player_name then | |
--never squad touch | |
thumpid = tostring(args.entityId); | |
MarkersHideAll(); | |
hide = true; | |
end | |
end | |
end | |
end | |
end | |
function OnTargetLost(args) | |
if tostring(args.entityId) == thumpid then | |
MarkersShowAll(); | |
thumpid = nil; | |
hide = false; | |
end | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- Squadlist join and leave Event | |
-- ------------------------------------------------------- | |
function OnSquadUpdate(args) | |
local roster = Squad.GetRoster(); | |
if (roster) then | |
if (#roster.members ~= #listSquad) then | |
listSquad = {} | |
for _,Member in pairs(roster.members) do | |
table.insert(listSquad, Member.name) | |
end | |
end | |
else | |
listSquad = {player_name} | |
end | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- SLASH COMMANDS | |
-- ------------------------------------------------------- | |
local slashhelp = [[Hammer Marker Hilfe: | |
"/hmvip log" Zeigt Rohstoffe Log an. | |
"/hmvip show" Zeige alle Hammer Wegpunkte an. | |
"/hmvip showall" Zeige alle Hammer Wegpunkte und Rohstoffe an. | |
"/hmvip hide" Verstecke alle Hammer Wegpunkte. | |
"/hmvip hideall" Verstecke alle Hammer Wegpunkte und Rohstoffe. | |
"/hmvip clear" Loesche alle deine Hammer Wegpunkte. | |
"/hmvip res [1-15]" Zeige alle bestimmte Rohstoffe an. | |
"/hmvip res [1-15][hours][quality]" Noch in der Entwicklung. | |
"/hmvip res hide" Loesche alle bestimmte Rohstoffe. | |
"/hmvip tab [1-15]" Zeige bestimmte Rohstoffe von POI. | |
"/hmvip sin" Sin Tower überwachen. | |
Coder by kkm v0.7]] | |
function InitializeSlashCommands() | |
LIB_SLASH.BindCallback({slash_list = "hmvip", description = "", func = MARKER_SLASH_CMDS.cmdroot}) | |
end | |
MARKER_SLASH_CMDS.cmdroot = function(text) | |
local option, message = text[1], text.text; | |
if option ~= nil then | |
if not ( MARKER_SLASH_CMDS[option] ) then | |
print_system_message(slashhelp) return nil | |
else | |
MARKER_SLASH_CMDS[option](message) | |
end | |
else | |
print_system_message(slashhelp) | |
end | |
end | |
MARKER_SLASH_CMDS.hide = function (text) | |
if tostring(text) == "hide" then | |
MarkersHideAll(); | |
end | |
end | |
local poiLine = {}; | |
local LINERAW = {}; | |
local POI; | |
local POI_total; | |
local tabItemId = 0; | |
MARKER_SLASH_CMDS.tab = function (text) | |
--local ss = Friends.GetList(); | |
--log(tostring(ss)); | |
--local ss = Game.GetTargetInfo("9212301835118531838"); | |
--log(tostring(ss)); | |
for is,vs in pairs(poiLine) do | |
if poiLine[is] then | |
Component.RemoveWidget(poiLine[is].GROUP) | |
end | |
end | |
poiLine = {}; --above after removewidget! | |
if tostring(text) == "tab 1" then | |
tabItemId = 78014; | |
elseif tostring(text) == "tab 2" then | |
tabItemId = 78015; | |
elseif tostring(text) == "tab 3" then | |
tabItemId = 78016; | |
elseif tostring(text) == "tab 4" then | |
tabItemId = 78017; | |
elseif tostring(text) == "tab 5" then | |
tabItemId = 78018; | |
elseif tostring(text) == "tab 6" then | |
tabItemId = 78019; | |
elseif tostring(text) == "tab 7" then | |
tabItemId = 78020; | |
elseif tostring(text) == "tab 8" then | |
tabItemId = 78021; | |
elseif tostring(text) == "tab 9" then | |
tabItemId = 78022; | |
elseif tostring(text) == "tab 10" then | |
tabItemId = 82420; | |
elseif tostring(text) == "tab 11" then | |
tabItemId = 78023 | |
elseif tostring(text) == "tab 12" then | |
tabItemId = 78024 | |
elseif tostring(text) == "tab 13" then | |
tabItemId = 78025 | |
elseif tostring(text) == "tab 14" then | |
tabItemId = 78026 | |
elseif tostring(text) == "tab 15" then | |
tabItemId = 78027 | |
elseif tostring(text) == "tab 16" then | |
tabItemId = 78028 | |
end | |
--Remove Widget after | |
if LINERAW.GROUP then | |
Component.RemoveWidget(LINERAW.GROUP); | |
end | |
POI = Game.GetWorldObjectList(); | |
POI_total = table.getn(POI); | |
local POI_info = Game.GetWorldObjectStatus(POI[1]); | |
print_system_message(tostring(POI_info)); | |
local itemDetails = Game.GetItemInfoByType(c_RawToRefinedConversion[tostring(tabItemId)]) | |
local BP = Component.CreateWidget("POILineRes", POI_FRAME) | |
LINERAW = { | |
GROUP = BP, | |
BACK_COLOR = BP:GetChild("backgroundColor"), | |
ICON = BP:GetChild("Icon"), | |
itemName = BP:GetChild("itemName"), | |
POI = BP:GetChild("POIc") | |
} | |
LINERAW.ICON:SetUrl(tostring(itemDetails.web_icon)); | |
LINERAW.itemName:SetText(itemDetails.name); | |
POIRefresh(); | |
end | |
function POIRefresh() | |
local faction = 0; | |
local array = 0; | |
local line = 0.5; --weil index 1 ist LINERAW reserviert. | |
local steper = 0; | |
for i,v in pairs(poiLine) do | |
if poiLine[i] then | |
Component.RemoveWidget(poiLine[i].GROUP) | |
end | |
end | |
--empty table array like respawn resource or choose rehack | |
for vv,ii in pairs(poiLine) do | |
local got = false; | |
for i,v in pairs(POI) do | |
local status = Game.GetWorldObjectStatus(POI[i]); | |
for is,vs in pairs(status.resources) do | |
if tostring(vs.rawItemTypeId) == tostring(tabItemId) then | |
if tostring(status.name) == tostring(vv) then | |
got = true; | |
end | |
end | |
end | |
end | |
if got == false then | |
if poiLine[vv] then | |
print_system_message("REMOVE: " ..vv); | |
poiLine[vv] = nil; | |
end | |
end | |
end | |
for i,v in pairs(POI) do | |
local status = Game.GetWorldObjectStatus(POI[i]); | |
if(status.faction == "accord") or (status.faction == "neutral") then | |
faction = faction + 1; | |
end | |
for is,vs in pairs(status.resources) do | |
if tostring(vs.rawItemTypeId) == tostring(tabItemId) then | |
local itemDetails = Game.GetItemInfoByType(vs.itemTypeId) | |
local BP = Component.CreateWidget("POILine", POI_FRAME) | |
local LINE = { | |
GROUP = BP, | |
PLAYER = BP:GetChild("POIName"), | |
BACK_COLOR = BP:GetChild("backgroundColor"), | |
itemName = BP:GetChild("itemName") | |
} | |
line = line + 1 | |
steper = steper + 1; | |
LINE.GROUP:SetDims("top:".. line * 20 ..";height:20"); | |
--LINE.itemName:SetText(steper..". " ..status.name .. " "..i); | |
LINE.itemName:SetText(steper..". " ..status.name); | |
if poiLine[status.name] then | |
if tonumber(poiLine[status.name].timer) < tonumber(System.GetClientTime()) then | |
LINE.BACK_COLOR:SetParam("tint", "#000000"); | |
poiLine[status.name].timer = 0; | |
else | |
LINE.BACK_COLOR:SetParam("tint", "#00FF00"); | |
LINE.timer = poiLine[status.name].timer; | |
end | |
else | |
LINE.timer = (tonumber(System.GetClientTime()) + 6000) | |
LINE.BACK_COLOR:SetParam("tint", "#00FF00"); | |
print_system_message(itemDetails.name ..": " .. status.name); | |
Chat.SendChannelText("squad", "[HammerMarker]: "..itemDetails.name.. ": ".. status.name) | |
end | |
poiLine[status.name] = LINE; | |
end | |
end | |
end | |
LINERAW.POI:SetText(tostring("POI: "..faction .."/" .. POI_total)); | |
callback(function() POIRefresh(); end, nil, 1); | |
end | |
--ares mission or thumper map notifcation for | |
--local markers = Game.GetMapMarkerList(); | |
--local s = Game.GetMapMarkerInfo(m.markerId); | |
local sins = {}; | |
MARKER_SLASH_CMDS.sin = function (text) | |
local markers = Game.GetWorldObjectList(); | |
sins = nil; | |
sins = {}; | |
for index, m in pairs(markers) do | |
local s = Game.GetWorldObjectStatus(index); | |
table.insert(sins,index,s.resources); | |
end | |
monitorsin(); | |
print_system_message("[HammerMarker] Sin Tower Monitor aktiviert."); | |
end | |
function monitorsin() | |
--list sin tower | |
for index, m in pairs(sins) do | |
local s = Game.GetWorldObjectStatus(index); | |
local einmal = false; | |
--Liste resource von aktuelle | |
for ii,mm in pairs(s.resources) do | |
if sins[index][ii] == nil or sins[index][ii].itemTypeId ~= mm.itemTypeId then | |
if einmal == false then | |
einmal = true; | |
print_system_message("***"..s.name.."***"); | |
--Liste machen mit + / - | |
local maxList = table.getn(sins[index]); | |
local maxList2 = table.getn(s.resources); | |
if maxList > maxList2 then | |
for kks,aa in pairs(sins[index]) do | |
local aas = Game.GetItemInfoByType(tonumber(aa.itemTypeId)); | |
local da = false; | |
for iis,mms in pairs(s.resources) do | |
local new = Game.GetItemInfoByType(mms.itemTypeId); | |
if tonumber(mms.itemTypeId) == tonumber(aa.itemTypeId) then | |
da = true; | |
end | |
end | |
if da == true then | |
print_system_message(kks .. ". " .. aas.name); | |
else | |
print_system_message(" --" .. kks .. ". " .. aas.name); | |
end | |
end | |
else | |
for iis,mms in pairs(s.resources) do | |
local new = Game.GetItemInfoByType(mms.itemTypeId); | |
local da = false; | |
for kks,aa in pairs(sins[index]) do | |
if tonumber(aa.itemTypeId) == tonumber(mms.itemTypeId) then | |
da = true; | |
end | |
end | |
if da == true then | |
print_system_message(iis .. "." .. new.name); | |
else | |
print_system_message(" ++".. iis .. "." .. new.name); | |
end | |
end | |
end | |
--alles anzeigen liste rohstoffe | |
--for kks,aa in pairs(sins[index]) do | |
--local aas = Game.GetItemInfoByType(tonumber(aa.itemTypeId)); | |
--print_system_message("OLD: " .. kks .. "." .. aas.name); | |
--end | |
--Ausgabe von liste resource scan | |
--for iis,mms in pairs(s.resources) do | |
--local new = Game.GetItemInfoByType(mms.itemTypeId); | |
--print_system_message("NEW: " .. iis .. "." .. new.name); | |
--end | |
end | |
end | |
end | |
end | |
local markers = Game.GetWorldObjectList(); | |
sins = nil; | |
sins = {}; | |
for index, m in pairs(markers) do | |
local s = Game.GetWorldObjectStatus(index); | |
table.insert(sins,index,s.resources); | |
end | |
callback(function() monitorsin(); end, nil, 3); | |
end | |
MARKER_SLASH_CMDS.hideall = function (text) | |
if tostring(text) == "hideall" then | |
MarkersHideAll(); | |
hide = true; | |
end | |
end | |
MARKER_SLASH_CMDS.showall = function (text) | |
if tostring(text) == "showall" then | |
MarkersShowAll(); | |
hide = false; | |
end | |
end | |
MARKER_SLASH_CMDS.show = function (text) | |
if tostring(text) == "show" then | |
hide = false; | |
MarkersShowAll(); | |
end | |
end | |
MARKER_SLASH_CMDS.clear = function (text) | |
if tostring(text) == "clear" then | |
step = 1; | |
ClearSavedData(); | |
lastupdate = 0; | |
HTTP.IssueRequest(host.."/myclear.php", "POST", {key=key}, nil) | |
print_system_message("Hammer Marker wurden gel\195\182scht.") | |
end | |
end | |
MARKER_SLASH_CMDS.log = function (text) | |
if tostring(text) == "log" then | |
local c = table.getn(lineArray); | |
for i,v in pairs(lineArray) do | |
lineArray[i].GROUP:ParamTo("alpha", 1,0,0); | |
--ab 3 beginnen fade out | |
if (i < (c - 2)) then | |
lineArray[i].GROUP:ParamTo("alpha", 0,10,1); | |
end | |
end | |
end | |
end | |
MARKER_SLASH_CMDS.res = function (text) | |
local itemId = 0; | |
if tostring(text) == "res hide" then | |
hide = false; | |
--destroy all | |
for i,v in pairs(markersResTypeList) do | |
markersResTypeList[i].markerId= ""; | |
markersResTypeList[i]:Destroy(); | |
markersResTypeList[i] = nil; | |
end | |
return; | |
end | |
if tostring(text) == "res 1" then | |
itemId = 78014; | |
elseif tostring(text) == "res 2" then | |
itemId = 78015; | |
elseif tostring(text) == "res 3" then | |
itemId = 78016; | |
elseif tostring(text) == "res 4" then | |
itemId = 78017; | |
elseif tostring(text) == "res 5" then | |
itemId = 78018; | |
elseif tostring(text) == "res 6" then | |
itemId = 78019; | |
elseif tostring(text) == "res 7" then | |
itemId = 78020; | |
elseif tostring(text) == "res 8" then | |
itemId = 78021; | |
elseif tostring(text) == "res 9" then | |
itemId = 78022; | |
elseif tostring(text) == "res 10" then | |
itemId = 82420; | |
elseif tostring(text) == "res 11" then | |
itemId = 78023 | |
elseif tostring(text) == "res 12" then | |
itemId = 78024 | |
elseif tostring(text) == "res 13" then | |
itemId = 78025 | |
elseif tostring(text) == "res 14" then | |
itemId = 78026 | |
elseif tostring(text) == "res 15" then | |
itemId = 78027 | |
elseif tostring(text) == "res 16" then | |
itemId = 78028 | |
end | |
hide = true; | |
HTTP.IssueRequest(host.."/squadresourcetype.php", "POST", {type=tostring(itemId),key=key}, HTTP_SquadResourceType); | |
ShowDisplayMarker2(); | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- Squad Resource Filter | |
-- ------------------------------------------------------- | |
function HTTP_SquadResourceType(args, err) | |
if (err) then | |
warn(tostring(err)); | |
else | |
--destroy all | |
for i,v in pairs(markersResTypeList) do | |
markersResTypeList[i].markerId= ""; | |
markersResTypeList[i]:Destroy(); | |
markersResTypeList[i] = nil; | |
end | |
markersResTypeList = {}; | |
local resultMarker = {}; | |
for id, value in pairs(args) do | |
local markID = tostring(value['5']); | |
local ar = {}; | |
ar.res_qual = {}; | |
ar.item = {}; | |
ar.percent = {}; | |
--Composition json extract | |
for ids, values in pairs(value['itemTypeId']) do | |
ar.res_qual[ids] = tostring(value['resource_quality'][ids]); | |
ar.item[ids] = tostring(value['itemTypeId'][ids]); | |
ar.res_qual[ids] = tostring(value['resource_quality'][ids]); | |
ar.percent[ids] = displayPercent(value['percent'][ids]); | |
end | |
ar.x = tostring(value['0']); | |
ar.y = tostring(value['1']); | |
ar.z = tostring(value['2']); | |
ar.user = tostring(value['3']); | |
ar.datum = tostring(value['4']); | |
ar.idy = markID; | |
table.insert(resInsert, tostring(value['5'])); | |
SquadResourceTypeMarker(ar); | |
end | |
end | |
end | |
function SquadResourceTypeMarker(mark) | |
local markerInput = {}; | |
markerInput.x = mark.x; | |
markerInput.y = mark.y; | |
markerInput.z = mark.z; | |
markerInput.user = mark.user; | |
--markerInput.markerId = tostring(round(position.x,0))..math.random(1,1000); | |
markerInput.markerId = "HAMMERMARKER_"..tostring(mark.idy)..math.random(1,1000); | |
--Resource Array Mixed web_icon,name,quality | |
markerInput.item = {}; | |
markerInput.item = mark.item; | |
markerInput.res_qual = {}; | |
markerInput.res_qual = mark.res_qual; | |
markerInput.percent = {}; | |
markerInput.percent = mark.percent; | |
markerInput.owner = tostring(Player.GetTargetId()); | |
markerInput.sourceName = mark.user .. ": " ..mark.datum; | |
local thisMarker = CreateMarkerSquadResourceType(markerInput); | |
end | |
function CreateMarkerSquadResourceType(markerInput) | |
local myMarker = MapMarker.Create(markerInput.markerId); | |
markerInput.pos = {}; | |
markerInput.pos.x = markerInput.x; | |
markerInput.pos.y = markerInput.y; | |
markerInput.pos.z = markerInput.z; | |
--because someone wrong quality e.g 0 | |
local highestItem = -1; | |
local highest = {}; | |
for i,v in pairs(markerInput.item) do | |
local percent = markerInput.percent[i]; | |
local quali = markerInput.res_qual[i]; | |
local item = v; | |
itemDetail = Game.GetItemInfoByType(tonumber(item)); | |
if highestItem < tonumber(quali) then | |
highestItem = tonumber(quali); | |
local aa = Game.GetItemInfoByType(c_RawToRefinedConversion[item]); | |
highest.web_icon = aa.web_icon; | |
highest.color = LIB_ITEMS.GetResourceQualityColor(highestItem); | |
highest.percent = percent; | |
highest.name = itemDetail.name; | |
end | |
local SHADOW = Component.CreateWidget("item_entry", myMarker:GetBody()) | |
SHADOW:GetChild("name"):SetText(itemDetail.name .. " " .. tostring(percent)); | |
SHADOW:GetChild("resource_quality"):SetText(quali); | |
qualityColor = LIB_ITEMS.GetResourceQualityColor(tonumber(quali)); | |
SHADOW:GetChild("resource_quality"):SetTextColor(qualityColor); | |
SHADOW:GetChild("icon"):SetUrl(tostring(itemDetail.web_icon)); | |
SHADOW:SetDims("left:-80; width:_; height:50; top:".. -50 + (i * 30) ..""); | |
end | |
local title = tostring(string.gsub(highest.name, "%^Q", "")); | |
myMarker:SetTitle(tostring(title .. " " .. highest.percent)); | |
local rowline = table.getn(markerInput.item); | |
local SHADOW = Component.CreateWidget("date", myMarker:GetBody()) | |
SHADOW:GetChild("name"):SetText(markerInput.sourceName); | |
SHADOW:SetDims("left:0; width:_; height:50; top:".. -20 + (rowline * 30) ..""); | |
myMarker:BindToPosition(markerInput.pos) | |
myMarker:GetIcon():SetUrl(tostring(highest.web_icon)) | |
myMarker:GetIcon():SetParam("glow", highest.color) | |
myMarker:ShowOnHud(true); | |
--icon Mixed alpha | |
c = table.getn(markerInput.item); | |
if ( c > 1) then | |
myMarker:GetIcon():SetParam("alpha", 1); | |
else | |
myMarker:GetIcon():SetParam("alpha", single/100); | |
end | |
markersResTypeList[myMarker:GetId()] = myMarker; | |
return myMarker; | |
end | |
function ShowDisplayMarker2() | |
for markerId,i in pairs(markersResTypeList) do | |
local myMarker = markersResTypeList[markerId]; | |
local myPos = Player.GetPosition(); | |
myMarker:ShowOnWorldMap(true); | |
myMarker:ShowOnRadar(true); | |
if IsInsideCircle(myPos.x, myPos.y, distance, myMarker.pos.x, myMarker.pos.y) == true then | |
myMarker:ShowOnHud(true) | |
else | |
myMarker:ShowOnHud(false) | |
end | |
end | |
callback(function() ShowDisplayMarker2(); end, nil, 0.1); | |
end | |
-- | |
-- | |
-- | |
-- | |
---------------------------------------------------------- | |
-- Utility | |
-- ------------------------------------------------------- | |
function print_system_message(message) | |
Component.GenerateEvent("MY_SYSTEM_MESSAGE", {text=message}) | |
end | |
function round(number, decimal) | |
local multiplier = 10^(decimal or 0) | |
return math.floor(number * multiplier + 0.5) / multiplier | |
end | |
function displayPercent(percent) | |
local display_pct = tonumber(percent)*100; | |
if (display_pct > .01) then | |
display_pct = string.format("%.02f%%", display_pct); | |
else | |
display_pct = "<0.01%"; | |
end | |
return display_pct; | |
end | |
function DegreeIcon(degree) | |
if tonumber(degree) <= 22.5 then | |
return "top"; | |
end | |
if tonumber(degree) <= 67.5 then | |
return "topright"; | |
end | |
if tonumber(degree) <= 112.5 then | |
return "right"; | |
end | |
if tonumber(degree) <= 157.5 then | |
return "rightbottom"; | |
end | |
if tonumber(degree) <= 202.5 then | |
return "bottom"; | |
end | |
if tonumber(degree) <= 247.5 then | |
return "bottomleft"; | |
end | |
if tonumber(degree) <= 292.5 then | |
return "left"; | |
end | |
if tonumber(degree) <= 337.5 then | |
return "lefttop"; | |
end | |
--Mehr als 337.5 bis 360 Grad | |
return "top"; | |
end | |
function IsInsideCircle(x_center, y_center, radius, checkX, checkY) | |
local distance = (math.sqrt(math.pow((checkX - x_center), 2) + math.pow((checkY - y_center), 2))) + 2 | |
if radius == 0 then | |
return true | |
end | |
if distance < radius then | |
return true | |
else | |
return false | |
end | |
end | |
function GetDegrees() | |
local pos = Player.GetPosition(); | |
local aim = Player.GetAimPosition(); -- ;( doesnt update in vehicle | |
if Player.IsInVehicle() then -- in vehicle | |
if not vequals2d(pos,g_lastpos,0.5) then -- moving | |
aim = pos | |
pos = g_lastpos | |
g_lastpos = aim | |
else | |
aim = pos | |
pos = g_lastpos | |
end | |
end -- works but shows wrong dir in reverse | |
local vector = { x = aim.x - pos.x, y = aim.y - pos.y }; | |
local rad = math.atan2(vector.y, vector.x); | |
local deg = math.deg(rad) | |
local dd = 90-deg -- 90-deg gives right ^ til 270 | |
if dd < 0 then dd = 360+dd end | |
return dd | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment