local junkscrap = 0
local pressed = 0
function craftgun_init(e)
end
function craftgun_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 PlayerDist < 100 then
PromptLocal ("Gun Crafting Press E to start")
if g_KeyPressE == 1 and pressed == 0 then
pressed = 1
if junkscrap >= 5 then
junkscrap = junkscrap - 5;
AddPlayerWeapon(e);
pressed = 0;
Destroy(e)
end
else
PromptDuration ("You do not have enough Scrap Metal",5)
end
end
end
Here is the Junkscrap that goes with the above script. when I walk up to the weapon it crashes back to the editor with no explanation why.
local junkscrap = 0
function junkscrap_init(e)
end
function junkscrap_main(e)
if GetPlayerDistance(e) <= 100 then
PromptLocal (e,"Press E to pick up scrap");
if g_KeyPressE == 1 then
junkscrap = junkscrap + 1
PromptDuration ("Junk scrap added to Inventory" .. junkscrap ,5)
Destroy(e)
end
end
end
The scrap pick up works, but when ever I walk up to the weapon to craft it the editor crashes and reverts.
CPU; Intel G850 2.9ghz GPU: Raedon HD 7750 1gb 4GB Ram
Windows 10 1TB HD 60GB HD