Jump to content

Neon Script


Recommended Posts

I made script which add neons to vehicle, but only for peoples who have "AS|" in their nick. It's add neons, but for all cars.. ( I want to add only for Cheetah, Infernus and Tampa ) If player isn't in team this neon is in car and don't follow player, but it couldn't create this neon : | This is code..

function neons ( source, theElement ) 
    local theVehicle = getPedOccupiedVehicle ( source ) 
    local x, y, z = getElementPosition ( theVehicle ) 
    local id = getElementModel ( theVehicle ) 
    local neon = createObject ( 14399, x, y, z ) 
    local neon1 = createObject ( 14399, x, y, z ) 
    if (string.find(getPlayerName(source),"AS|")) then 
        if id == 415 then 
            attachElements ( neon1, theVehicle, 1, 0, -0.5 ) 
            attachElements ( neon, theVehicle, -1, 0, -0.5 ) 
                elseif id == 411 then 
                    attachElements ( neon1, theVehicle, 1.05, 0, -0.55 ) 
                    attachElements ( neon, theVehicle, -1.05, 0, -0.55 ) 
                        elseif id == 549 then 
                            attachElements ( neon1, theVehicle, 1, 0, -0.4 ) 
                            attachElements ( neon, theVehicle, -1, 0, -0.4 ) 
                        if not (string.find(getPlayerName(source),"AS|")) then 
                            detachElements ( neon1 ) 
                            detachElements ( neon ) 
                    end 
                end 
            end 
        end 
addEventHandler("onVehicleEnter", getRootElement(), neons) 

Edited by Guest
Link to comment

Well, you shouldn't create the neon if the model is not one of these.

local vehicles = 
    { 
        [ 415 ] = true, 
        [ 411 ] = true, 
        [ 549 ] = true 
    } 
  
function neons ( thePlayer ) 
    local x, y, z = getElementPosition ( source ) 
    local id = getElementModel ( source ) 
    if ( getPlayerName ( thePlayer ):find ( "AS|" ) ) then 
        if ( vehicles [ id ] ) then 
            local neon = createObject ( 14399, x, y, z ) 
            local neon1 = createObject ( 14399, x, y, z ) 
            if ( id == 415 ) then 
                attachElements ( neon1, source, 1, 0, -0.5 ) 
                attachElements ( neon, source, -1, 0, -0.5 ) 
            elseif ( id == 411 ) then 
                attachElements ( neon1, source, 1.05, 0, -0.55 ) 
                attachElements ( neon, source, -1.05, 0, -0.55 ) 
            elseif ( id == 549 ) then 
                attachElements ( neon1, source, 1, 0, -0.4 ) 
                attachElements ( neon, source, -1, 0, -0.4 ) 
            end 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), neons ) 

Link to comment

Now it doesn't working.. ( I replace this models :D )

  
[05:55:46] WARNING: neons\server.lua:9: Bad argument @ 'getElementPosition' [Expected element at argument 1, got nil] 
[05:55:46] WARNING: neons\server.lua:13: Bad argument @ 'createObject' [Expected number at argument 2, got boolean] 
[05:55:46] WARNING: neons\server.lua:14: Bad argument @ 'createObject' [Expected number at argument 2, got boolean] 
[05:55:46] WARNING: neons\server.lua:19: Bad argument @ 'attachElements' [Expected element at argument 1, got boolean] 
[05:55:46] WARNING: neons\server.lua:20: Bad argument @ 'attachElements' [Expected element at argument 1, got boolean] 

Link to comment

Thank you ! That's working , but I want to create neon on player hit pickup. ( my events doesn't working ; < ) How I can add neons to one account too?

function neons ( thePlayer ) 
    local x, y, z = getElementPosition ( source ) 
    local id = getElementModel ( source ) 
    if ( getPlayerName ( thePlayer ):find ( "AS|" ) ) then 
        if ( vehicles [ id ] ) then 
            local neon = createObject ( 14403, x, y, z ) 
            local neon1 = createObject ( 14403, x, y, z ) 
            if ( id == 415 ) then 
                attachElements ( neon1, source, 1, 0, -0.5 ) 
                attachElements ( neon, source, -1, 0, -0.5 ) 
            elseif ( id == 411 ) then 
                attachElements ( neon1, source, 1.05, 0, -0.55 ) 
                attachElements ( neon, source, -1.05, 0, -0.55 ) 
            elseif ( id == 549 ) then 
                attachElements ( neon1, source, 1, 0, -0.4 ) 
                attachElements ( neon, source, -1, 0, -0.4 ) 
            end 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), neons ) 
addEventHandler ( "onPlayerPickUpRacePickup", getRootElement(), neons ) 
addEventHandler ( "onPlayerReachCheckpoint", getRootElement(), neons ) 

Link to comment

https://wiki.multitheftauto.com/wiki/SetAccountData

https://wiki.multitheftauto.com/wiki/GetAccountData

function neons ( thePlayer ) 
    local account = getPlayerAccount(source) 
    if getAccountData (account,"haveNeons") == true or 1 then 
        local x, y, z = getElementPosition ( source ) 
        local id = getElementModel ( source ) 
        if ( getPlayerName ( thePlayer ):find ( "AS|" ) ) then 
            if ( vehicles [ id ] ) then 
                local neon = createObject ( 14403, x, y, z ) 
                local neon1 = createObject ( 14403, x, y, z ) 
                if ( id == 415 ) then 
                    attachElements ( neon1, source, 1, 0, -0.5 ) 
                    attachElements ( neon, source, -1, 0, -0.5 ) 
                elseif ( id == 411 ) then 
                    attachElements ( neon1, source, 1.05, 0, -0.55 ) 
                    attachElements ( neon, source, -1.05, 0, -0.55 ) 
                elseif ( id == 549 ) then 
                    attachElements ( neon1, source, 1, 0, -0.4 ) 
                    attachElements ( neon, source, -1, 0, -0.4 ) 
                end 
            end 
        end 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), neons ) 
addEventHandler ( "onPlayerPickUpRacePickup", getRootElement(), neons ) 
addEventHandler ( "onPlayerReachCheckpoint", getRootElement(), neons ) 

Server-Side only

Ofc you need set account data "haveNeons"

Link to comment

why you need attach new neons when player got checkpoint or pickup?

use

onNotifyPlayerReady 

event( if you use race)

local vehicles = 
{ 
    [ 415 ] = true, 
    [ 411 ] = true, 
    [ 549 ] = true 
} 
  
function neons () 
    local account = getPlayerAccount(source) 
    if not account then return end 
    if getAccountData (account,"haveNeons") == true or 1 then 
        local theVehicle = getPedOccupiedVehicle ( source ) 
        if theVehicle then 
            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 ( 14403, x, y, z ) 
                local neon1 = createObject ( 14403, x, y, z ) 
                if ( id == 415 ) then 
                    attachElements ( neon1, theVehicle or source, 1, 0, -0.5 ) 
                    attachElements ( neon, theVehicle or source, -1, 0, -0.5 ) 
                elseif ( id == 411 ) then 
                    attachElements ( neon1, theVehicle or source, 1.05, 0, -0.55 ) 
                    attachElements ( neon, theVehicle or source, -1.05, 0, -0.55 ) 
                elseif ( id == 549 ) then 
                    attachElements ( neon1, theVehicle or source, 1, 0, -0.4 ) 
                    attachElements ( neon, theVehicle or source, -1, 0, -0.4 ) 
                end 
            end 
        end 
    end 
end 
addEventHandler("onNotifyPlayerReady",getRootElement(),neons) 
addEventHandler ( "onPlayerPickUpRacePickup", getRootElement(), neons ) 
addEventHandler ( "onPlayerReachCheckpoint", getRootElement(), neons ) 

later detach and destroyElement

mm.. "onPlayerWasted"

and as i know object 14403 it's element of library rofl

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...