Jump to content

Exportar función


Nyx17

Recommended Posts

Esto lo tengo en el freeroam:

Spoiler

        {'btn', id='neon', onclick=wndNeon},

------------------------

function wndNeon()
    exports.neon:openGui()
end  

 Server:

function openGui(plr)   
local veh = getPedOccupiedVehicle(plr)
if haveNeon(veh) then
triggerClientEvent(plr,"openNeonGui",root)
end
end

 

-------------------------------------------------

Client:

guiSetVisible(guiWindow,false)
addEvent("openNeonGui",true)
addEventHandler("openNeonGui",root,function()
showCursor(true)
guiSetVisible(guiWindow,true)

-----------------------------------------------------

<export function='openGui' type='client'/>

Link to comment
--Esto va en el meta del script "neon"

<export function='openGui' type='server'/>

--fr_client.lua

{'btn', id='neon', onclick=wndNeon},

function wndNeon()
   triggerServerEvent("openGUINeon", localPlayer)
end  

--fr_server.lua

addEvent("openGUINeon", true)
addEventHandler("openGUINeon", root,
    function()
      	exports.neon:openGui(source)
	end
)

 

  • Like 1
Link to comment

Client:

Spoiler

sx,sy = guiGetScreenSize()
function wantNeon(state)
if state == true then
addEventHandler("onClientPreRender",root,loop)
else
removeEventHandler("onClientPreRender",root,loop)
end
end
function loop()
for i,veh in ipairs(getElementsByType("vehicle")) do
x,y,z = getElementPosition(veh)
a,b,c = getElementPosition(getLocalPlayer())
dis = getDistanceBetweenPoints3D(x,y,z,a,b,c)
vis = isElementOnScreen(veh)
if vis and dis < 50 then
x,y,rot = getElementRotation(veh)
if x < 50 or x > 310 then
if y < 50 or y > 310 then
if getElementData(veh,"neonlight") ~= "off!!!" then
drawIt(veh,rot)
end
end
end
end
end
end

addEventHandler("onClientPreRender",root,loop)

function drawIt(veh,rot)
x,y,z = getElementPosition(veh)
az = getGroundPosition(x,y,z)
dis = getDistanceBetweenPoints3D(x,y,z,x,y,az)
if dis < 2 then
a = 100
model = getElementModel(veh)
data = getElementData(veh,"neonlight")
if data then
r = tonumber(gettok(data,1,string.byte(",")))
g = tonumber(gettok(data,2,string.byte(",")))
b = tonumber(gettok(data,3,string.byte(",")))
ck = tonumber(gettok(data,4,string.byte(",")))
--if ck and ck <= 255 and ck >= 0 then a = ck end
rot = rot
if 
--rot < 1 or rot > 359 
1 == 1
then
rx,ry,rz = getElementRotation(veh)
x,y,z = getElementPosition(veh)
r3 = rz-30
r4 = rz-150
r3 = math.abs(r3-360)
r4 = math.abs(r4-360)
r1 = r3-60
r2 = r4-300
r1 = math.rad(r1)
r2 = math.rad(r2)
r3 = math.rad(r3)
r4 = math.rad(r4)
cr1 = math.cos(r1)
sr1 = math.sin(r1)
cr2 = math.cos(r2)
sr2 = math.sin(r2)
cr3 = math.cos(r3)
sr3 = math.sin(r3)
cr4 = math.cos(r4)
sr4 = math.sin(r4)
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)
cr1 = 1.03*cr1
sr1 = 1.03*sr1
cr2 = 1.03*cr2
sr2 = 1.03*sr2
cr3 = 1.03*cr3
sr3 = 1.03*sr3
cr4 = 1.03*cr4
sr4 = 1.03*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+x
y3 = cr3+y
x4 = sr4+x
y4 = cr4+y
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)
--factor
ffactor,bfactor = 1.65,1.5 
--front
_,_,rz = getElementRotation(veh)
rb = math.abs(rz-360)
rb = rb-180
rb = math.rad(rb)
crb = bfactor*math.cos(rb)
srb = bfactor*math.sin(rb)
xb,yb = srb+x,crb+y
azb = getGroundPosition(xb,yb,az+2)
--back
rf = math.abs(rz-360)
rf = math.rad(rf)
crf = ffactor*math.cos(rf)
srf = ffactor*math.sin(rf)
xf,yf = srf+x,crf+y
azf = getGroundPosition(xf,yf,az+2)
--draw front
x,y,z = xf,yf,azf 
x1,y1,z1 = xb,yb,azb
rz = rz-90
r3 = rz-30
r4 = rz-150
r3 = math.abs(r3-360)
r4 = math.abs(r4-360)
r1 = r3-60
r2 = r4-300
r1 = math.rad(r1)
r2 = math.rad(r2)
r3 = math.rad(r3)
r4 = math.rad(r4)
cr1 = 0.7*math.cos(r1)
sr1 = 0.7*math.sin(r1)
cr2 = 0.7*math.cos(r2)
sr2 = 0.7*math.sin(r2)
cr3 = 0.7*math.cos(r3)
sr3 = 0.7*math.sin(r3)
cr4 = 0.7*math.cos(r4)
sr4 = 0.7*math.sin(r4)
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)
cr1 = 1.03*cr1
sr1 = 1.03*sr1
cr2 = 1.03*cr2
sr2 = 1.03*sr2
cr3 = 1.03*cr3
sr3 = 1.03*sr3
cr4 = 1.03*cr4
sr4 = 1.03*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

cr1 = 1.02*cr1
sr1 = 1.02*sr1
cr2 = 1.02*cr2
sr2 = 1.02*sr2
cr3 = 1.02*cr3
sr3 = 1.02*sr3
cr4 = 1.02*cr4
sr4 = 1.02*sr4
x1 = sr1+x
y1 = cr1+y
x2 = sr2+x
y2 = cr2+y
x3 = sr3+xb
y3 = cr3+yb
x4 = sr4+xb
y4 = cr4+yb
az1 = getGroundPosition(x1,y1,z+2)
az2 = getGroundPosition(x2,y2,z+2)
az3 = getGroundPosition(x3,y3,z+2)
az4 = getGroundPosition(x4,y4,z+2)
dxDrawLine3D(x1,y1,az1,x2,y2,az2,tocolor(r,g,b,a),3)
dxDrawLine3D(x3,y3,az3,x4,y4,az4,tocolor(r,g,b,a),3)

end
end
end
end
sizex = 300
sizey = 300
guiWindow = guiCreateWindow(0.5*sx-0.5*sizex,0.5*sy-0.5*sizey,sizex,sizey,"neon",false)
guiWindowSetSizable(guiWindow,false)
redGui = guiCreateEdit(sizex/3,20,sizex/3,20,"0",false,guiWindow)
greenGui = guiCreateEdit(sizex/3,50,sizex/3,20,"0",false,guiWindow)
blueGui = guiCreateEdit(sizex/3,80,sizex/3,20,"0",false,guiWindow)
guiCheck = guiCreateCheckBox(40,140,sizex/6,20,"done?",false,false,guiWindow)
button = guiCreateButton(sizex/3,140,sizex/3,40,"OK",false,guiWindow)
addEventHandler("onClientGUIClick",button,
function() 
checkstate = guiCheckBoxGetSelected(guiCheck)
if checkstate then
if tonumber(guiGetText(redGui)) == nil then
local hex = guiGetText(redGui)
local r,g,b = getColorFromString(hex)
if b then ther,theg,theb = r,g,b end
end
local cr = tonumber(guiGetText(redGui))
local cg = tonumber(guiGetText(greenGui))
local cb = tonumber(guiGetText(blueGui))
if cr and cg and cb then
local cr = math.floor(cr)
local cg = math.floor(cg)
local cb = math.floor(cb)
end
if not theb then ther,theg,theb = cr,cg,cb end
guiSetVisible(guiWindow,false)
showCursor(false)
triggerServerEvent("closeNeonGui",getLocalPlayer(),ther,theg,theb)
end
end)

guiSetVisible(guiWindow,false)
addEvent("openNeonGui",true)
addEventHandler("openNeonGui",root,function()
showCursor(true)
guiSetVisible(guiWindow,true)
gr = tonumber(gettok(data,1,string.byte(",")))
gg = tonumber(gettok(data,2,string.byte(",")))
gb = tonumber(gettok(data,3,string.byte(",")))
if r and g and b then 
guiSetText(tostring(redGui),gr)
guiSetText(tostring(greenGui),gg)
guiSetText(tostring(blueGui),gb)
end
end)

addEventHandler("onClientRender",root,function()
local state = guiGetVisible(guiWindow)
local MTA = isMTAWindowActive()
if state and not MTA then
dxx,dxy = guiGetPosition(guiWindow,false)
dxxx,dxxy = dxx+40,dxy+sizey-180
dxDrawLine(dxxx,dxxy,dxx+260,dxxy,guiColor(),30,true)
end 
end)

function guiColor()
local hex = guiGetText(redGui)
local r,g,b = getColorFromString(hex)
if b then return tocolor(r,g,b,255) end
dxr = tonumber(guiGetText(redGui))
dxg = tonumber(guiGetText(greenGui))
dxb = tonumber(guiGetText(blueGui))
if not dxr then dxr = 0 end
if not dxg then dxg = 0 end
if not dxb then dxb = 0 end
return tocolor(dxr,dxg,dxb,255)
end

Server:

Spoiler

--determine whether color change can be made with a command
cmd = true
--the command to use
thecmd = "neon"
function neon(plr,cmd,r,g,b,a)
if not r then openGui(plr) return true end
if tonumber(tostring(r)) == nil then r,g,b,a = getColorFromString(r)
end
if not a then a = 200 end
veh = getPedOccupiedVehicle(plr)
if veh and r and g and b then
model = getElementModel(veh)
if canHaveNeon(veh) then 
if haveNeon(veh) then
setNeonColor(veh,tonumber(r),tonumber(g),tonumber(b))
end
end
end
end

if cmd then
addCommandHandler(thecmd,neon)
end

function setNeonColor(vehicle,r,g,b)
setElementData(vehicle,"neonlight",tostring(r)..","..tostring(g)..","..tostring(b)..","..tostring(a))
for i,mark in ipairs(getElementsByType("marker")) do
local type = getMarkerType(mark)
if type == "corona" then
local data1 = getElementData(vehicle,"neonMarker1")
local data2 = getElementData(vehicle,"neonMarker2")
if data1 == mark or data2 == mark then
setMarkerColor(mark,r,g,b,80)
end
end
end
return true
end

function haveNeon(vehicle)
local data = getElementData(vehicle,"haveneon")
if data then
return true
else
return false
end
end

function addNeon(vehicle,state)
if getElementType(vehicle) == "vehicle" then
if state then
setElementData(vehicle,"haveneon",true)
x,y,z = getElementPosition(vehicle)
--
local exist = nil
for i,mark in ipairs(getElementsByType("marker")) do
data = getElementData(vehicle,"neonMarker1")
if data == mark then
local exist = mark
end
end
if not exist then
local marker1 = createMarker(x,y,z,"corona",2,0,0,0,0)
attachElements(marker1,vehicle,0,-1,-1.2)
setElementData(vehicle,"neonMarker1",marker1)
local marker2 = createMarker(x,y,z,"corona",2,0,0,0,0)
attachElements(marker2,vehicle,0,1,-1.2)
setElementData(vehicle,"neonMarker2",marker2)
end
--
return true
else
setElementData(vehicle,"haveneon",false)
setElementData(veh,"neonlight","off!!!")
--
for i,mark in ipairs(getElementsByType("marker")) do
local type = getMarkerType(mark)
if type == "corona" then
local data1 = getElementData(vehicle,"neonMarker1")
local data2 = getElementData(vehicle,"neonMarker2")
if data1 == mark or data2 == mark then
setMarkerColor(mark,0,0,0,0)
end
end
end
--
return true
end
else
return false
end
end
function canHaveNeon(veh)
model = getElementModel(veh)
    if veh and getElementType(veh) == "vehicle" then
    x = mayHaveNeon(model)
    return x
    else
    return false
    end
end

function mayHaveNeon(model)
if model ~= 592 and model ~= 511 and model ~= 584 and model ~= 512 and model ~= 593 and model ~= 417 and
model ~= 487 and model ~= 553 and model ~= 488 and model ~= 563 and model ~= 476 and model ~= 519 and
model ~= 460 and model ~= 469 and model ~= 513 and model ~= 472 and model ~= 473 and model ~= 493 and
model ~= 595 and model ~= 484 and model ~= 430 and model ~= 453 and model ~= 452 and model ~= 446 and
model ~= 454 and model ~= 403 and model ~= 514 and model ~= 443 and model ~= 515 and model ~= 455 and
model ~= 406 and model ~= 486 and model ~= 578 and model ~= 532 and model ~= 524 and model ~= 498 and
model ~= 609 and model ~= 568 and model ~= 457 and model ~= 508 and model ~= 571 and model ~= 539 and
model ~= 606 and model ~= 607 and model ~= 485 and model and model ~= 581 and model ~= 509 and 
model ~= 481 and model ~= 462 and model ~= 521 and model ~= 463 and model ~= 510 and model ~= 522 and 
model ~= 461 and model ~= 448 and model ~= 468 and model ~= 586 and model ~= 485 and model ~= 552 and
model ~= 431 and model ~= 438 and model ~= 437 and model ~= 574 and model ~= 525 and model ~= 408 and
model ~= 416 and model ~= 433 and model ~= 427 and model ~= 490 and model ~= 528 and model ~= 407 and 
model ~= 544 and model ~= 523 and model ~= 470 and model ~= 596 and model ~= 597 and model ~= 598 and 
model ~= 599 and model ~= 432 and model ~= 601 and model ~= 428 and model ~= 499 and model ~= 449 and 
model ~= 537 and model ~= 538 and model ~= 570 and model ~= 569 and model ~= 590 and model ~= 441 and 
model ~= 464 and model ~= 501 and model ~= 465 and model ~= 564 and model ~= 594 then
return true
else
return false
end
end


function deactivateNeon(vehicle)
if getElementType(vehicle) == "vehicle" then
setElementData(vehicle,"neonlight","off!!!")
for i,mark in ipairs(getElementsByType("marker")) do
local type = getMarkerType(mark)
if type == "corona" then
local data1 = getElementData(vehicle,"neonMarker1")
local data2 = getElementData(vehicle,"neonMarker2")
if data1 == mark or data2 == mark then
setMarkerColor(mark,0,0,0,0)
end
end
end
return true
else
return false
end
end

function openGui(plr)
local veh = getPedOccupiedVehicle(plr)
if haveNeon(veh) then
triggerClientEvent(plr,"openNeonGui",root)
end
end

addEventHandler("onPlayerJoin",root,function()
for i,veh in ipairs(getElementsByType("vehicle")) do
data = getElementData(veh,"neonlight")
setElementData(veh,"neonlight",data)
end
end)

for i,veh in ipairs(getElementsByType("vehicle")) do
deactivateNeon(veh)
end

addEvent("closeNeonGui",true)
addEventHandler("closeNeonGui",root,function(r,g,b)
local veh = getPedOccupiedVehicle(source)
setNeonColor(veh,r,g,b)
end)

 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...