Jump to content

Neon objects don't sync with other players.


koragg

Recommended Posts

Recently I kept receiving complains about this and I'm now sure it's problem with script. So basically, when a player joins my server he says he doesn't see neon but sees default gta objects attached to MY car. If he puts neon on HIS car he sees it as neon, but he sees other's neon as default objects. I never had any problem seeing other people's (or my) neon as neon tubes. I'm gonna mention this as it can have a difference, I'm playing on the same PC on which my server is hosted (is local server, for now). So I've got completely no idea what could be wrong, below's the code. If anyone knows a fix for this, please help :S

Client:

local sx, sy = guiGetScreenSize()
localPlayer = getLocalPlayer()
local visible = false
local key = "F2"

local neonname = {
[1] = "Red",
[2] = "Aqua",
[3] = "Green",
[4] = "Yellow",
[5] = "Orange",
[6] = "Disable"
}

local idModel = {
[1] = 2057,
[2] = 2058,
[3] = 2055,
[4] = 2059,
[5] = 2056
}



function openGui()
local xBtn = 75
local yBtn = 30
local wBtn = 150
local hBtn = 21
local space = 28
     window = guiCreateWindow(sx/2-650,sy/2-155,300,230,"Car Neon Panel",false)
     Btn1 = guiCreateButton(xBtn,yBtn,wBtn,hBtn,neonname[1],false, window)
     Btn2 = guiCreateButton(xBtn,yBtn+space,wBtn,hBtn,neonname[2],false, window)
     Btn3 = guiCreateButton(xBtn,yBtn+2*space,wBtn,hBtn,neonname[3],false, window)
     Btn4 = guiCreateButton(xBtn,yBtn+3*space,wBtn,hBtn,neonname[4],false, window)
     Btn5 = guiCreateButton(xBtn,yBtn+4*space,wBtn,hBtn,neonname[5],false, window)
     Btn6 = guiCreateButton(xBtn,yBtn+5*space,wBtn,hBtn,neonname[6],false, window)
     info = guiCreateLabel(100, 200, 300, 30,"Full effect at night!", false, window) 
     guiLabelSetColor (info, 255,0,0)
guiSetVisible(window, visible)
end


function start_cl_resource()
	openGui()
          if ( guiGetVisible(window) == true ) then
             showCursor(true)
          end
end
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),start_cl_resource)

function hideGui()
if getElementData ( localPlayer,'LoggedIn' ) ~= true then 
outputChatBox("You need to register and login in order to set neon on your cars!", 255,153,0)
return
end
  if (guiGetVisible(window) == false) then 
           guiSetVisible(window, true)
           showCursor(true)
   else
           guiSetVisible(window, false)
           showCursor(false)

  end
end

addCommandHandler("neon",hideGui)

function onGuiClickPanel (button, state, absoluteX, absoluteY)
  if (source == Btn1) then
       setElementData( localPlayer, "neon", idModel[1] )
       outputChatBox("#FFFFFFYour neon color is now #FF0000Red", 255,255,255, true)
       local theVehicle = getPedOccupiedVehicle ( localPlayer )
       triggerServerEvent ("detachNeon", getLocalPlayer(), theVehicle)
       triggerServerEvent ("attachNeon", getLocalPlayer(), theVehicle)
  elseif (source == Btn2) then
       setElementData( localPlayer, "neon", idModel[2] )
       outputChatBox("#FFFFFFYour neon color is now #00FFFFAqua", 255,255,255, true)
       local theVehicle = getPedOccupiedVehicle ( localPlayer )
       triggerServerEvent ("detachNeon", getLocalPlayer(), theVehicle)
       triggerServerEvent ("attachNeon", getLocalPlayer(), theVehicle)
  elseif (source == Btn3) then
       setElementData( localPlayer, "neon", idModel[3] )
       outputChatBox("#FFFFFFYour neon color is now #00FF00Green", 255,255,255, true)
       local theVehicle = getPedOccupiedVehicle ( localPlayer )
       triggerServerEvent ("detachNeon", getLocalPlayer(), theVehicle)
       triggerServerEvent ("attachNeon", getLocalPlayer(), theVehicle)
  elseif (source == Btn4) then
       setElementData( localPlayer, "neon", idModel[4] )
       outputChatBox("#FFFFFFYour neon color is now #FFCC00Yellow", 255,255,255, true)
       local theVehicle = getPedOccupiedVehicle ( localPlayer )
       triggerServerEvent ("detachNeon", getLocalPlayer(), theVehicle)
       triggerServerEvent ("attachNeon", getLocalPlayer(), theVehicle)
  elseif (source == Btn5) then
       setElementData( localPlayer, "neon", idModel[5] )
       outputChatBox("#FFFFFFYour neon color is now #FFA500Orange", 255,255,255, true)
       local theVehicle = getPedOccupiedVehicle ( localPlayer )
       triggerServerEvent ("detachNeon", getLocalPlayer(), theVehicle)
       triggerServerEvent ("attachNeon", getLocalPlayer(), theVehicle)
  elseif (source == Btn6) then
       setElementData( localPlayer, "neon", 0 )
       outputChatBox("#FFFFFFYou have removed neon from your car!", 255,255,255, true)
       local theVehicle = getPedOccupiedVehicle ( localPlayer )
       triggerServerEvent ("detachNeon", getLocalPlayer(), theVehicle)
  end
end
addEventHandler ("onClientGUIClick", getRootElement(), onGuiClickPanel)

function replaceTXD()
dff = engineLoadDFF ( "models/RedNeon.dff", idModel[1] )
engineReplaceModel ( dff, idModel[1] ) 
dff = engineLoadDFF ( "models/BlueNeon.dff", idModel[2] )
engineReplaceModel ( dff, idModel[2] ) 
dff = engineLoadDFF ( "models/GreenNeon.dff", idModel[3] )
engineReplaceModel ( dff, idModel[3] ) 
dff = engineLoadDFF ( "models/YellowNeon.dff", idModel[4] )
engineReplaceModel ( dff, idModel[4] ) 
dff = engineLoadDFF ( "models/OrangeNeon.dff", idModel[5] )
engineReplaceModel ( dff, idModel[5] ) 
end
addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceTXD)

Server:

local validvehs =
{--Vehicles with neon
400, 401, 402, 404, 405, 409, 410, 411, 412, 415, 419, 420, 421, 426, 429, 436, 438, 439, 442, 445, 451, 
458, 466, 467, 474, 475, 477, 478, 479, 480, 489, 490, 491, 492, 494, 496, 500, 502, 503, 505, 506, 507, 
516, 517, 518, 526, 527, 529, 533, 534, 535, 536, 540, 541, 542, 543, 545, 546, 547, 549, 550, 551, 554, 
555, 558, 559, 560, 561, 562, 565, 566, 567, 576, 579, 580, 585, 587, 589, 600, 602, 603, 604, 605, 422,
474, 478, 575,
--Vehicles without neon
403, 406, 407, 408, 413, 414, 416, 417, 418, 423, 424, 425, 427, 428, 430, 431, 432, 433, 434, 435, 437,
440, 441, 443, 444, 446, 447, 448, 449, 450, 452, 453, 454, 455, 456, 457, 459, 460, 461, 462, 463, 464,
465, 468, 469, 470, 471, 472, 473, 476, 481, 482, 483, 484, 485, 486, 487, 488, 493, 495, 497, 498, 499,
501, 504, 508, 509, 510, 511, 512, 513, 514, 515, 519, 520, 521, 522, 523, 524, 525, 528, 530, 531, 532,
537, 538, 539, 544, 548, 552, 553, 556, 557, 563, 564, 568, 569, 570, 571, 572, 573, 574, 577, 578, 581,
582, 583, 584, 586, 588, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 601, 606, 607, 608, 609, 610,
611
}

local neons_ = {}
function neons (theVehicle)
    local playeraccount = getPlayerAccount ( source )
	if playeraccount and isGuestAccount(playeraccount) then return end
    local pla = getVehicleController(theVehicle)
    if not neons_[pla] then
	neons_[pla] = {_0=false,_1=false,_2=false,_3=false}
    end
    local NeonType = getElementData(source, "neon")
    if not NeonType or ( NeonType == 0 ) then return end
    local x, y, z = getElementPosition ( theVehicle )
    if not x or not y or not z then return end
    local id = getElementModel (theVehicle)

				if isElement (neons_[pla]._0) then destroyElement(neons_[pla]._0) end -- to solve some problems
				if isElement (neons_[pla]._1) then destroyElement(neons_[pla]._1) end
				if isElement (neons_[pla]._2) then destroyElement(neons_[pla]._2) end
				if isElement (neons_[pla]._3) then destroyElement(neons_[pla]._3) end
				neons_[pla]._0 = createObject ( NeonType, x, y, z )
				neons_[pla]._1 = createObject ( NeonType, x, y, z )
				neons_[pla]._2 = createObject ( NeonType, x, y, z )
				neons_[pla]._3 = createObject ( NeonType, x, y, z )
				local neon,neon1,neon2,neon3 = neons_[pla]._0,neons_[pla]._1,neons_[pla]._2,neons_[pla]._3
				if ( id == 401 ) then
					destroyElement(neon2)
					destroyElement(neon3)
					attachElements ( neon1, theVehicle or source, 0.99, 0, -0.55 )
					attachElements ( neon, theVehicle or source, -0.99, 0, -0.55 )
				elseif ( id == 411 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.55, -0.6, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.25, -0.55, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.97, 0, -0.59 )
					attachElements ( neon, theVehicle or source, -0.97, 0, -0.59 )
				elseif ( id == 429 ) then
					attachElements ( neon3, theVehicle or source, 0, 2, -0.5, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.25, -0.45, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.88, 0, -0.5 )
					attachElements ( neon, theVehicle or source, -0.88, 0, -0.5 )
				elseif ( id == 445 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.25, -0.55, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.65, -0.52, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.95, 0, -0.55 )
					attachElements ( neon, theVehicle or source, -0.95, 0, -0.55 )
				elseif ( id == 535 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.35, -0.55, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.55, -0.5, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.09, 0, -0.6 )
					attachElements ( neon, theVehicle or source, -1.09, 0, -0.6 )
				elseif ( id == 536 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.3, -0.5, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.95, -0.5, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.95, 0, -0.6 )
					attachElements ( neon, theVehicle or source, -0.95, 0, -0.6 )
				elseif ( id == 496 ) then
					destroyElement(neon2)
					destroyElement(neon3)
					attachElements ( neon1, theVehicle or source, 0.87, 0, -0.5 )
					attachElements ( neon, theVehicle or source, -0.87, 0, -0.5 )
				elseif ( id == 602 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.35, -0.58, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.45, -0.55, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.04, 0, -0.6 )
					attachElements ( neon, theVehicle or source, -1.04, 0, -0.6 )
				elseif ( id == 518 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.7, -0.45, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.6, -0.42, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.06, 0, -0.48 )
					attachElements ( neon, theVehicle or source, -1.06, 0, -0.48 )
				elseif ( id == 402 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.5, -0.55, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.55, -0.44, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.03, 0, -0.6 )
					attachElements ( neon, theVehicle or source, -1.03, 0, -0.6 )
				elseif ( id == 541 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.15, -0.43, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.04, -0.35, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.92, 0, -0.45 )
					attachElements ( neon, theVehicle or source, -0.92, 0, -0.45 )
				elseif ( id == 438 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.6, -0.68, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.6, -0.68, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.95, 0, -0.72 )
					attachElements ( neon, theVehicle or source, -0.95, 0, -0.72 )
				elseif ( id == 527 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.4, -0.34, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.05, -0.34, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.92, 0.15, -0.47 )
					attachElements ( neon, theVehicle or source, -0.92, 0.15, -0.47 )
				elseif ( id == 415 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.45, -0.54, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.15, -0.52, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.96, 0, -0.57 )
					attachElements ( neon, theVehicle or source, -0.96, 0, -0.57 )
				elseif ( id == 542 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.55, -0.37, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.65, -0.32, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.94, 0, -0.59 )
					attachElements ( neon, theVehicle or source, -0.94, 0, -0.59 )
				elseif ( id == 466 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.55, -0.43, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.85, -0.41, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.02, 0, -0.54 )
					attachElements ( neon, theVehicle or source, -1.02, 0, -0.54 )
				elseif ( id == 604 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.55, -0.43, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.85, -0.41, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.02, 0, -0.54 )
					attachElements ( neon, theVehicle or source, -1.02, 0, -0.54 )
				elseif ( id == 589 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.3, -0.38, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.25, -0.33, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.92, 0.1, -0.43 )
					attachElements ( neon, theVehicle or source, -0.92, 0.1, -0.43 )
				elseif ( id == 480 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.15, -0.53, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.35, -0.48, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.95, 0, -0.53 )
					attachElements ( neon, theVehicle or source, -0.95, 0, -0.53 )
				elseif ( id == 507 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.75, -0.56, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -3, -0.56, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.12, 0, -0.62 )
					attachElements ( neon, theVehicle or source, -1.12, 0, -0.62 )
				elseif ( id == 562 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.35, -0.48, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.1, -0.4, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.98, 0.05, -0.45 )
					attachElements ( neon, theVehicle or source, -0.98, 0.05, -0.45 )
				elseif ( id == 419 ) then
					destroyElement(neon3)
					attachElements ( neon2, theVehicle or source, 0, -2.9, -0.45, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.98, 0.1, -0.58 )
					attachElements ( neon, theVehicle or source, -0.98, 0.1, -0.58 )
				elseif ( id == 587 ) then
					destroyElement(neon3)
					attachElements ( neon2, theVehicle or source, 0, -2.5, -0.45, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.07, -0.05, -0.53 )
					attachElements ( neon, theVehicle or source, -1.07, -0.05, -0.53 )
				elseif ( id == 533 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.45, -0.32, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.5, -0.32, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.96, 0, -0.47 )
					attachElements ( neon, theVehicle or source, -0.96, 0, -0.47 )
				elseif ( id == 565 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.05, -0.45, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -1.95, -0.3, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.85, 0.1, -0.45 )
					attachElements ( neon, theVehicle or source, -0.85, 0.1, -0.45 )
				elseif ( id == 526 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.47, -0.48, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.4, -0.43, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.93, 0, -0.58 )
					attachElements ( neon, theVehicle or source, -0.93, 0, -0.58 )
			    elseif ( id == 492 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.57, -0.42, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.77, -0.42, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.93, 0, -0.5 )
					attachElements ( neon, theVehicle or source, -0.93, 0, -0.5 )
				elseif ( id == 494 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.4, -0.67, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -3, -0.53, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.92, -0.05, -0.68 )
					attachElements ( neon, theVehicle or source, -0.92, -0.05, -0.68 )
				elseif ( id == 502 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.5, -0.69, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.7, -0.49, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.92, -0.05, -0.67 )
					attachElements ( neon, theVehicle or source, -0.92, -0.05, -0.67 )
				elseif ( id == 503 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.5, -0.67, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.7, -0.51, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.92, -0.05, -0.67 )
					attachElements ( neon, theVehicle or source, -0.92, -0.05, -0.67 )
			    elseif ( id == 579 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 0.97, 0.05, -0.55 )
					attachElements ( neon, theVehicle or source, -0.97, 0.05, -0.55 )
				elseif ( id == 545 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 0.96, 0, -0.6 )
					attachElements ( neon, theVehicle or source, -0.96, 0, -0.6 )
				elseif ( id == 546 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 1.06, -0.1, -0.53 )
					attachElements ( neon, theVehicle or source, -1.06, -0.1, -0.53 )
				elseif ( id == 559 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.6, -0.42, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.3, -0.28, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.97, 0, -0.48 )
					attachElements ( neon, theVehicle or source, -0.97, 0, -0.48 )
				elseif ( id == 400 ) then
					destroyElement(neon2)
					destroyElement(neon3)
					attachElements ( neon1, theVehicle or source, 0.95, 0, -0.67 )
					attachElements ( neon, theVehicle or source, -0.95, 0, -0.67 )
				elseif ( id == 517 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 1, 0.1, -0.58 )
					attachElements ( neon, theVehicle or source, -1, 0.1, -0.58 )
				elseif ( id == 410 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 0.91, 0, -0.43 )
					attachElements ( neon, theVehicle or source, -0.91, 0, -0.43 )
				elseif ( id == 551 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.6, -0.48, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -3, -0.43, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.98, 0, -0.6 )
					attachElements ( neon, theVehicle or source, -0.98, 0, -0.6 )
				elseif ( id == 500 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 1.02, 0.2, -0.6 )
					attachElements ( neon, theVehicle or source, -1.02, 0.2, -0.6 )
				elseif ( id == 516 ) then
					destroyElement(neon3)
					attachElements ( neon2, theVehicle or source, 0, -2.63, -0.53, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1, 0, -0.65 )
					attachElements ( neon, theVehicle or source, -1, 0, -0.65 )
				elseif ( id == 467 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.6, -0.43, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.9, -0.4, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1, 0, -0.55 )
					attachElements ( neon, theVehicle or source, -1, 0, -0.55 )
				elseif ( id == 404 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 0.85, 0, -0.46 )
					attachElements ( neon, theVehicle or source, -0.85, 0, -0.46 )
				elseif ( id == 603 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.41, -0.61, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.5, -0.5, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.97, 0, -0.65 )
					attachElements ( neon, theVehicle or source, -0.97, 0, -0.65 )
				elseif ( id == 600 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.67, -0.38, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.7, -0.36, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1, 0.15, -0.53 )
					attachElements ( neon, theVehicle or source, -1, 0.15, -0.53 )
				elseif ( id == 426 ) or ( id == 420 ) then
					destroyElement(neon3)
					attachElements ( neon2, theVehicle or source, 0, -2.7, -0.42, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.02, 0, -0.5 )
					attachElements ( neon, theVehicle or source, -1.02, 0, -0.5 )
				elseif ( id == 489 ) or ( id == 505 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 1.25, 0.1, -0.75 )
					attachElements ( neon, theVehicle or source, -1.25, 0.1, -0.75 )
				elseif ( id == 436 ) or ( id == 547 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 0.95, 0, -0.51 )
					attachElements ( neon, theVehicle or source, -0.95, 0, -0.51 )
				elseif ( id == 479 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.5, -0.38, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.66, -0.38, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.9, 0, -0.49 )
					attachElements ( neon, theVehicle or source, -0.9, 0, -0.49 )
				elseif ( id == 534 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.9, -0.58, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.8, -0.45, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1, 0, -0.6 )
					attachElements ( neon, theVehicle or source, -1, 0, -0.6 )
				elseif ( id == 442 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.8, -0.58, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -3.1, -0.45, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.02, 0, -0.65 )
					attachElements ( neon, theVehicle or source, -1.02, 0, -0.65 )
				elseif ( id == 475 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 0.93, 0, -0.58 )
					attachElements ( neon, theVehicle or source, -0.93, 0, -0.58 )
				elseif ( id == 605 ) or ( id == 543 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 0.98, 0, -0.47 )
					attachElements ( neon, theVehicle or source, -0.98, 0, -0.47 )
				elseif ( id == 567 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.8, -0.55, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.84, -0.54, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.1, 0.25, -0.65 )
					attachElements ( neon, theVehicle or source, -1.1, 0.25, -0.65 )
				elseif ( id == 405 ) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 0.93, 0, -0.65 )
					attachElements ( neon, theVehicle or source, -0.93, 0, -0.65 )
				elseif ( id == 458 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.45, -0.52, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.65, -0.56, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.95, 0, -0.65 )
					attachElements ( neon, theVehicle or source, -0.95, 0, -0.65 )
				elseif ( id == 580 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.57, -0.44, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.7, -0.41, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.1, 0, -0.53 )
					attachElements ( neon, theVehicle or source, -1.1, 0, -0.53 )
				elseif ( id == 439 ) then
					destroyElement(neon3)
					attachElements ( neon2, theVehicle or source, 0, -2.35, -0.45, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.9, 0.15, -0.68 )
					attachElements ( neon, theVehicle or source, -0.9, 0.15, -0.68 )
				elseif ( id == 561 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.6, -0.53, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.58, -0.48, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.95, 0, -0.6 )
					attachElements ( neon, theVehicle or source, -0.95, 0, -0.6 )
				elseif ( id == 409 ) then
					attachElements ( neon3, theVehicle or source, 0.9, 1, -0.53 )
					attachElements ( neon2, theVehicle or source, -0.9, 1, -0.53 )
					attachElements ( neon1, theVehicle or source, 0.9, -1, -0.53 )
					attachElements ( neon, theVehicle or source, -0.9, -1, -0.53 )
				elseif ( id == 560 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.5, -0.4, 0, 0, 90  )
					attachElements ( neon2, theVehicle or source, 0, -2.25, -0.29, 0, 0, 90  )
					attachElements ( neon1, theVehicle or source, 0.98, 0.05, -0.49 )
					attachElements ( neon, theVehicle or source, -0.98, 0.05, -0.49 )
				elseif ( id == 550 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.6, -0.64, 0, 0, 90  )
					attachElements ( neon2, theVehicle or source, 0, -2.6, -0.63, 0, 0, 90  )
					attachElements ( neon1, theVehicle or source, 1.1, 0, -0.63 )
					attachElements ( neon, theVehicle or source, -1.1, 0, -0.63 )
				elseif ( id == 506 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.08, -0.52, 0, 0, 90  )
					attachElements ( neon2, theVehicle or source, 0, -2.3, -0.44, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.94, -0.15, -0.53 )
					attachElements ( neon, theVehicle or source, -0.94, -0.15, -0.53 )
				elseif ( id == 451 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.45, -0.57, 0, 0, 90  )
					attachElements ( neon2, theVehicle or source, 0, -2.1, -0.48, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1, -0.15, -0.55 )
					attachElements ( neon, theVehicle or source, -1, -0.15, -0.55 )
				elseif ( id == 566 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.67, -0.39, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -3.03, -0.34, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1, -0.15, -0.52 )
					attachElements ( neon, theVehicle or source, -1, -0.15, -0.52 )
				elseif ( id == 549 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.45, -0.41, 0, 0, 90  )
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 0.97, 0, -0.46 )
					attachElements ( neon, theVehicle or source, -0.97, 0, -0.46 )
				elseif ( id == 576 ) then
					destroyElement(neon3)
					attachElements ( neon2, theVehicle or source, 0, -3.1, -0.33, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.03, 0, -0.45 )
					attachElements ( neon, theVehicle or source, -1.03, 0, -0.45 )
				elseif ( id == 558 ) then
					destroyElement(neon3)
					attachElements ( neon2, theVehicle or source, 0, -2.35, -0.29, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.95, -0.05, -0.4 )
					attachElements ( neon, theVehicle or source, -0.95, -0.05, -0.4 )
				elseif ( id == 540 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.55, -0.62, 0, 0, 90  )
					attachElements ( neon2, theVehicle or source, 0, -2.65, -0.56, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.05, 0, -0.68 )
					attachElements ( neon, theVehicle or source, -1.05, 0, -0.68 )
				elseif ( id == 491 ) then
					destroyElement(neon3)
					attachElements ( neon2, theVehicle or source, 0, -2.83, -0.47, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.9, 0, -0.62 )
					attachElements ( neon, theVehicle or source, -0.9, 0, -0.62 )
				elseif ( id == 412 ) then
					attachElements ( neon3, theVehicle or source, 0, 2.63, -0.45, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -3.42, -0.42, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1, -0.2, -0.63 )
					attachElements ( neon, theVehicle or source, -1, -0.2, -0.63 )
				elseif ( id == 421 ) then
					destroyElement(neon3)
					attachElements ( neon2, theVehicle or source, 0, -2.96, -0.49, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.95, 0.1, -0.63 )
					attachElements ( neon, theVehicle or source, -0.95, 0.1, -0.63 )
				elseif ( id == 529 ) then
					destroyElement(neon3)
					attachElements ( neon2, theVehicle or source, 0, -2.53, -0.32, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1, -0.05, -0.43 )
					attachElements ( neon, theVehicle or source, -1, -0.05, -0.43 )
				elseif ( id == 555) then
					destroyElement(neon3)
					destroyElement(neon2)
					attachElements ( neon1, theVehicle or source, 0.8, 0, -0.47 )
					attachElements ( neon, theVehicle or source, -0.8, 0, -0.47 )
				elseif ( id == 554) then
					attachElements ( neon3, theVehicle or source, 0, 2.49, -0.55, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.75, -0.51, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.2, 0, -0.47 )
					attachElements ( neon, theVehicle or source, -1.2, 0, -0.47 )
				elseif ( id == 477) then
					attachElements ( neon3, theVehicle or source, 0, 2.56, -0.52, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.7, -0.37, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.02, 0, -0.56 )
					attachElements ( neon, theVehicle or source, -1.02, 0, -0.56 )
				elseif ( id == 585) then
					attachElements ( neon3, theVehicle or source, 0, 2.8, -0.3, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.9, -0.22, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1.05, 0, -0.4 )
					attachElements ( neon, theVehicle or source, -1.05, 0, -0.4 )
				elseif ( id == 422) then
					attachElements ( neon3, theVehicle or source, 0, 2.1, -0.6, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.4, -0.65, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.88, 0, -0.65 )
					attachElements ( neon, theVehicle or source, -0.88, 0, -0.65 )
				elseif ( id == 474) then
					attachElements ( neon3, theVehicle or source, 0, 2.57, -0.55, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.75, -0.55, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1, 0, -0.6 )
					attachElements ( neon, theVehicle or source, -1, 0, -0.6 )
				elseif ( id == 478) then
					attachElements ( neon3, theVehicle or source, 0, 2.1, -0.58, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.3, -0.48, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 0.95, 0.3, -0.65 )
					attachElements ( neon, theVehicle or source, -0.95, 0.3, -0.65 )
				elseif ( id == 575) then
					attachElements ( neon3, theVehicle or source, 0, 2.15, -0.32, 0, 0, 90 )
					attachElements ( neon2, theVehicle or source, 0, -2.6, -0.32, 0, 0, 90 )
					attachElements ( neon1, theVehicle or source, 1, 0, -0.38 )
					attachElements ( neon, theVehicle or source, -1, 0, -0.38 )
				else -- if vehicle doesn't have neon then you don't need the object
					destroyElement(neon)
					destroyElement(neon1)
					destroyElement(neon2)
					destroyElement(neon3)
				end
end
addEventHandler( "onPlayerVehicleEnter",getRootElement(),neons )
addEvent( "attachNeon", true )
addEventHandler( "attachNeon", getRootElement(), neons )

function detachNeon( theVehicle )
    local attachedElements = getAttachedElements ( theVehicle )
    for i,v in ipairs ( attachedElements ) do
        detachElements ( v, theVehicle )
        destroyElement ( v )
    end
end
addEventHandler( "onPlayerVehicleExit", getRootElement(), detachNeon )
addEvent( "detachNeon", true )
addEventHandler( "detachNeon", getRootElement(), detachNeon )

local vehmodel = {}
function onPlayerQuit()
vehmodel[source] = nil
if neons_[source] ~= nil then
if neons_[source] and neons_[source]._0 and isElement (neons_[source]._0) then destroyElement(neons_[source]._0) end -- to solve some problems
if neons_[source] and neons_[source]._1 and isElement (neons_[source]._1) then destroyElement(neons_[source]._1) end
if neons_[source] and neons_[source]._2 and isElement (neons_[source]._2) then destroyElement(neons_[source]._2) end
if neons_[source] and neons_[source]._3 and isElement (neons_[source]._3) then destroyElement(neons_[source]._3) end
neons_[source] = nil
end
local playeraccount = getPlayerAccount ( source )
  if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
     local getNeonType = getElementData(source, "neon")
     if ( getNeonType ) then
       setAccountData ( playeraccount, "neon", getNeonType)
       local theVehicle = getPedOccupiedVehicle ( source )
       if ( getNeonType ~= 0 ) and ( theVehicle ) then
          detachNeon( theVehicle )
       end
     end
  end
end
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit )

addEventHandler( 'onPlayerJoin',root,
	function (	)
		setElementData ( source,'LoggedIn',false )
	end
)

function onPlayerLogin (_, playeraccount )
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then
          local getNeonTypeAccData = getAccountData ( playeraccount, "neon" )
		  local theVehicle = getPedOccupiedVehicle ( source )
		  if not isGuestAccount( playeraccount ) then
			setElementData ( source,'LoggedIn',true )
		  end
             if ( getNeonTypeAccData ~= 0 ) then
                   setElementData(source, "neon", getNeonTypeAccData)
				   neons(theVehicle)
             end
      end
end
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin )

function onPlayerLogout (_, playeraccount)
if (playeraccount) then
local getNeonType = getElementData(source, "neon")
if ( getNeonType ) then
local theVehicle = getPedOccupiedVehicle ( source )
setElementData ( source,'LoggedIn',false )
       if ( getNeonType ~= 0 ) and ( theVehicle ) then
          detachNeon( theVehicle )
       end
     end
	 end
end
addEventHandler ( "onPlayerLogout", getRootElement ( ), onPlayerLogout )

addEvent("onPlayerReachCheckpoint",true) -- vehicle change
addEventHandler("onPlayerReachCheckpoint",root,function()
    local playeraccount = getPlayerAccount ( source )
	if isGuestAccount(playeraccount) then
	return
	end
	local veh = getPedOccupiedVehicle(source)
	if isElement(veh) then
		modelver (veh,source)
	end
end)

addEvent("onPlayerPickUpRacePickup",true)
addEventHandler("onPlayerPickUpRacePickup",root,function(id,ptype)
    local playeraccount = getPlayerAccount ( source )
	if isGuestAccount(playeraccount) then
	return
	end
	if ptype == "vehiclechange" then
		local veh = getPedOccupiedVehicle(source)
		if isElement(veh) then
			modelver (veh,source)
		end
	end
end)

addEvent("onPlayerFinish",true)
addEventHandler("onPlayerFinish",root,function()
    local playeraccount = getPlayerAccount ( source )
	if isGuestAccount(playeraccount) then
	return
	end
	local veh = getPedOccupiedVehicle(source)
	if isElement(veh) then
		modelver (veh,source)
	end
end)

function modelver (veh,pla)
	local model = getElementModel(veh)
	if vehmodel[pla] == nil then
		neons (veh)
		vehmodel[pla] = model
	elseif vehmodel[pla] ~= model then
		neons (veh)
		vehmodel[pla] = model
	end
end

meta:

<meta>
    <info author="Kostya/MegasXLR/Wojak" name="Neon Panel" type="script" version="0.0.3"/>

    <script src='server.lua' type='server' />
    <script src='client.lua' type='client' />
	
	<export function="hideGui" type="client"/>

    <file src='models/AquaNeon.dff' />
    <file src='models/GreenNeon.dff' />
    <file src='models/OrangeNeon.dff' />
    <file src='models/RedNeon.dff' />
    <file src='models/YellowNeon.dff' />
</meta>

 

Edited by koragg
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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