xSrTorino Posted November 9, 2017 Share Posted November 9, 2017 (edited) Hola, perdon por la molestia, estoy aprendiendo de un poco a hacer un par de guiones, lo cual encontré uno en la comunidad y decidí editarlo. A lo que me lleva un problema, el script se trata sobre neón en los vehículos, lo cual me gustaría que al desaparecer el vehículo, desaparezca el neón junto a él, el problema es que al desaparecer el vehículo, el neón queda flotando en el aire, un ejemplo claro de lo que hablo, es por ejemplo un Modshop, que al comprar ruedas de un carro, éste se queda guardado en el vehículo, si apareces o desapareces un vehículo (de mi panel de F5, que es vehículos propios comprados en concesionarias) las ruedas permanecen en él. en fin, espero haber sido lo suficientemente específico y que me hayan entendido y me puedan ayudar! desde ya, muchas gracias, espero puedan ayudarme! Aquí el Client.lua: local sx, sy = guiGetScreenSize() localPlayer = getLocalPlayer() local visible = false local key = "F1" local neonname = { [1] = "Red Neon ($20.000)", [2] = "Blue Neon ($20.000)", [3] = "Green Neon ($20.000)", [4] = "Yellow Neon ($20.000)", [5] = "Pink Neon ($20.000)", [6] = "White Neon ($20.000)", [7] = "Reset" } local idModel = { [1] = 14399, [2] = 14400, [3] = 14401, [4] = 14402, [5] = 14403, [6] = 14404 } function openGui() window = guiCreateWindow(418, 128, 422, 433, "NeonShop", false) guiWindowSetSizable(window, false) guiSetAlpha(window, 0.65) Btn1 = guiCreateButton(19, 28, 385, 47, "Neón Rojo", false, window) Btn2 = guiCreateButton(19, 313, 385, 47, "Neón Azúl", false, window) Btn3 = guiCreateButton(19, 256, 385, 47, "Neón Verde", false, window) Btn4 = guiCreateButton(19, 199, 385, 47, "Neón Amarillo", false, window) Btn5 = guiCreateButton(19, 142, 385, 47, "Neón Rosa", false, window) Btn6 = guiCreateButton(19, 85, 385, 47, "Neón Blanco", false, window) Btn7 = guiCreateButton(19, 370, 385, 47, "Quitar neón", false, window) guiLabelSetColor (info, 0,0,255) guiSetVisible (ventana, visible) final function start_cl_resource () openGui () if (guiGetVisible (window) == true) luego showCursor (true) end end addEventHandler ("onClientResourceStart", getResourceRootElement (getThisResource ()), start_cl_resource) function hideGui () if (guiGetVisible (window) == false) luego guiSetVisible (ventana, true) showCursor (true) else guiSetVisible (ventana, falso) showCursor (false) end end bindKey (clave, "abajo", ocultarGui) function onGuiClickPanel (button, state, absoluteX, absoluteY) if (source == Btn1) then setElementData (localPlayer, "neon", idModel [1]) outputChatBox ("Colocaste neón Rojo", 255,0,0, true) local theVehicle = getPedOccupiedVehicle (localPlayer) triggerServerEvent ("detachNeon", getLocalPlayer (), theVehicle) triggerServerEvent ("attachNeon", getLocalPlayer (), theVehicle) elseif (source == Btn2) then setElementData (localPlayer, "neon", idModel [2]) outputChatBox ("Colocaste neón Azúl", 0,0,255, verdadero) local theVehicle = getPedOccupiedVehicle (localPlayer) triggerServerEvent ("detachNeon",getLocalPlayer (), theVehicle) triggerServerEvent ("attachNeon", getLocalPlayer (), theVehicle) elseif (source == Btn3) then setElementData (localPlayer, "neon", idModel [3]) outputChatBox ("Colocaste neón Verde", 0,255,0, verdadero) local theVehicle = getPedOccupiedVehicle (localPlayer) triggerServerEvent ("detachNeon", getLocalPlayer (), theVehicle) triggerServerEvent ("attachNeon", getLocalPlayer (), theVehicle) elseif (source == Btn4) then setElementData (localPlayer, "neon", idModel [4]) outputChatBox ("Colocaste neón Amarillo", 255,255,0,true) local theVehicle = getPedOccupiedVehicle (localPlayer) triggerServerEvent ("detachNeon", getLocalPlayer (), theVehicle) triggerServerEvent ("attachNeon", getLocalPlayer (), theVehicle) elseif (source == Btn5) then setElementData (localPlayer, "neon", idModel [5]) outputChatBox ("Colocaste neón Rosa", 255,100,200, verdadero) local theVehicle = getPedOccupiedVehicle ( localPlayer) triggerServerEvent ("detachNeon", getLocalPlayer (), theVehicle) triggerServerEvent ("attachNeon", getLocalPlayer (), theVehicle) elseif (source == Btn6) then setElementData (localPlayer, "neon", idModel [6]) outputChatBox (" Colocaste neón Blanco ", 255,255,255,true) local theVehicle = getPedOccupiedVehicle (localPlayer) triggerServerEvent ("detachNeon", getLocalPlayer (), theVehicle) triggerServerEvent ("attachNeon", getLocalPlayer (), theVehicle) elseif (source == Btn7) then setElementData (localPlayer, "neon", 0) outputChatBox ("Quitaste tu neón", 255,255,255, verdadero) local theVehicle = getPedOccupiedVehicle (localPlayer) triggerServerEvent ("detachNeon", getLocalPlayer (), theVehicle) end end addEventHandler ("onClientGUIClick", getRootElement (), onGuiClickPanel) function replaceTXD() txd = engineLoadTXD ( "models/MatTextures.txd" ) engineImportTXD ( txd, idModel[1] ) engineImportTXD ( txd, idModel[2] ) engineImportTXD ( txd, idModel[3] ) engineImportTXD ( txd, idModel[4] ) engineImportTXD ( txd, idModel[5] ) engineImportTXD ( txd, idModel[6] ) col = engineLoadCOL("models/RedNeonTube1.col") engineReplaceCOL(col, idModel[1]) col = engineLoadCOL("models/BlueNeonTube1.col") engineReplaceCOL(col, idModel[2]) col = engineLoadCOL("models/GreenNeonTube1.col") engineReplaceCOL(col, idModel[3]) col = engineLoadCOL("models/YellowNeonTube1.col") engineReplaceCOL(col, idModel[4]) col = engineLoadCOL("models/PinkNeonTube1.col") engineReplaceCOL(col, idModel[5]) col = engineLoadCOL("models/WhiteNeonTube1.col") engineReplaceCOL(col, idModel[6]) dff = engineLoadDFF ( "models/RedNeonTube1.dff", idModel[1] ) engineReplaceModel ( dff, idModel[1] ) dff = engineLoadDFF ( "models/BlueNeonTube1.dff", idModel[2] ) engineReplaceModel ( dff, idModel[2] ) dff = engineLoadDFF ( "models/GreenNeonTube1.dff", idModel[3] ) engineReplaceModel ( dff, idModel[3] ) dff = engineLoadDFF ( "models/YellowNeonTube1.dff", idModel[4] ) engineReplaceModel ( dff, idModel[4] ) dff = engineLoadDFF ( "models/PinkNeonTube1.dff", idModel[5] ) engineReplaceModel ( dff, idModel[5] ) dff = engineLoadDFF ( "models/WhiteNeonTube1.dff", idModel[6] ) engineReplaceModel ( dff, idModel[6] ) end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceTXD) Server.lua: local vehicles = { [ 400 ] = true, [ 401 ] = true, [ 402 ] = true, [ 403 ] = true, [ 404 ] = true, [ 405 ] = true, [ 409 ] = true, [ 410 ] = true, [ 415 ] = true, [ 411 ] = true, [ 412 ] = true, [ 413 ] = true, [ 415 ] = true, [ 416 ] = true, [ 418 ] = true, [ 419 ] = true, [ 421 ] = true, [ 422 ] = true, [ 423 ] = true, [ 425 ] = true, [ 426 ] = true, [ 428 ] = true, [ 429 ] = true, [ 431 ] = true, [ 432 ] = true, [ 434 ] = true, [ 436 ] = true, [ 437 ] = true, [ 438 ] = true, [ 439 ] = true, [ 440 ] = true, [ 442 ] = true, [ 445 ] = true, [ 446 ] = true, [ 451 ] = true, [ 458 ] = true, [ 459 ] = true, [ 466 ] = true, [ 467 ] = true, [ 470 ] = true, [ 474 ] = true, [ 475 ] = true, [ 477 ] = true, [ 479 ] = true, [ 480 ] = true, [ 482 ] = true, [ 483 ] = true, [ 487 ] = true, [ 488 ] = true, [ 489 ] = true, [ 490 ] = true, [ 491 ] = true, [ 492 ] = true, [ 494 ] = true, [ 495 ] = true, [ 496 ] = true, [ 498 ] = true, [ 499 ] = true, [ 500 ] = true, [ 502 ] = true, [ 503 ] = true, [ 504 ] = true, [ 505 ] = true, [ 506 ] = true, [ 507 ] = true, [ 508 ] = true, [ 516 ] = true, [ 517 ] = true, [ 518 ] = true, [ 519 ] = true, [ 520 ] = true, [ 521 ] = true, [ 525 ] = true, [ 526 ] = true, [ 527 ] = true, [ 528 ] = true, [ 529 ] = true, [ 533 ] = true, [ 534 ] = true, [ 535 ] = true, [ 536 ] = true, [ 540 ] = true, [ 541 ] = true, [ 542 ] = true, [ 543 ] = true, [ 545 ] = true, [ 546 ] = true, [ 547 ] = true, [ 549 ] = true, [ 550 ] = true, [ 551 ] = true, [ 552 ] = true, [ 554 ] = true, [ 555 ] = true, [ 558 ] = true, [ 559 ] = true, [ 560 ] = true, [ 561 ] = true, [ 562 ] = true, [ 565 ] = true, [ 566 ] = true, [ 567 ] = true, [ 568 ] = true, [ 575 ] = true, [ 576 ] = true, [ 579 ] = true, [ 580 ] = true, [ 582 ] = true, [ 585 ] = true, [ 587 ] = true, [ 588 ] = true, [ 589 ] = true, [ 596 ] = true, [ 597 ] = true, [ 598 ] = true, [ 599 ] = true, [ 600 ] = true, [ 602 ] = true, [ 603 ] = true, [ 604 ] = true, [ 605 ] = true, [ 609 ] = true } function neons (theVehicle) 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 ( vehicles [ id ] ) then local neon = createObject ( NeonType, x, y, z ) local neon1 = createObject ( NeonType, x, y, z ) local neon2 = createObject ( NeonType, x, y, z ) local neon3 = createObject ( NeonType, x, y, z ) if ( id == 401 ) then destroyElement(neon2) destroyElement(neon3) attachElements ( neon1, theVehicle or source, 0.9, 0, -0.55 ) attachElements ( neon, theVehicle or source, -0.9, 0, -0.55 ) elseif ( id == 411 ) then attachElements ( neon3, theVehicle or source, 0, 1.25, -0.63, 0, 0, 90 ) attachElements ( neon2, theVehicle or source, 0, -1.25, -0.63, 0, 0, 90 ) attachElements ( neon1, theVehicle or source, 0.95, 0, -0.63 ) attachElements ( neon, theVehicle or source, -0.95, 0, -0.63 ) elseif ( id == 432 ) then end end end 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 addEvent( "detachNeon", true ) addEventHandler( "detachNeon", getRootElement(), detachNeon ) function onPlayerQuit() 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 end end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) function onPlayerLogin (_, playeraccount) if (playeraccount) luego local getNeonTypeAccData = getAccountData (playeraccount, "neon") if (getNeonTypeAccData ~ = 0) then setElementData (fuente, "neon", getNeonTypeAccData) end end end addEventHandler ("onPlayerLogin", getRootElement (), onPlayerLogin) Edited November 10, 2017 by .:CiBeR:. Formato de post Link to comment
MTA Team 0xCiBeR Posted November 10, 2017 MTA Team Share Posted November 10, 2017 Movido a la sección correcta. Por favor, usa el code tags <> para insertar código Lua. 1 Link to comment
Rose Posted November 10, 2017 Share Posted November 10, 2017 Debes usar onElementDestroy o onVehicleExit, así cuando se destruya el auto o un jugador salga del auto haces que se destruya el neon Link to comment
-Rex- Posted November 10, 2017 Share Posted November 10, 2017 6 hours ago, Rose said: Debes usar onElementDestroy o onVehicleExit, así cuando se destruya el auto o un jugador salga del auto haces que se destruya el neon onVehicleExit no tiene nada que ver con lo que quiere hacer, debe usar este evento https://wiki.multitheftauto.com/wiki/OnVehicleExplode Link to comment
Rose Posted November 11, 2017 Share Posted November 11, 2017 9 hours ago, -Rex- said: onVehicleExit no tiene nada que ver con lo que quiere hacer, debe usar este evento https://wiki.multitheftauto.com/wiki/OnVehicleExplode Cierto, me equivoqué, creo que ese script ya trae por defecto que se destruya el neon al salir del auto Link to comment
xSrTorino Posted November 15, 2017 Author Share Posted November 15, 2017 On 10/11/2017 at 20:51, -Rex- said: onVehicleExit no tiene nada que ver con lo que quiere hacer, debe usar este evento https://wiki.multitheftauto.com/wiki/OnVehicleExplode Perdón por las molestias, a lo que voy es que al momento de desaparecer el vehículo que contiene puesto el neón, desaparezca el neón también, porque cuando desaparezco un vehículo que tiene neón, el neón queda flotando en el aire, hace bastante tiempo que vengo intentando hacerlo y no pude... si puedes modificarlo te lo agradecería mucho! Graciss de antemano Link to comment
Calculador Posted November 23, 2017 Share Posted November 23, 2017 On 15/11/2017 at 00:44, xSrTorino said: Perdón por las molestias, a lo que voy es que al momento de desaparecer el vehículo que contiene puesto el neón, desaparezca el neón también, porque cuando desaparezco un vehículo que tiene neón, el neón queda flotando en el aire, hace bastante tiempo que vengo intentando hacerlo y no pude... si puedes modificarlo te lo agradecería mucho! Graciss de antemano Eso es porque la función de desaparecer el vehículo se encuentra en otro sistema, y probablemente el sistema que tienes de vehículos no lo desaparezca destruyéndolo y por eso sea inútil lo que ya has hecho. Para hacer lo que quieres tienes que editar también el código de tu sistema de vehículos. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now