Jump to content

Correct code


d43dr4

Recommended Posts

Hello,

I got a code but it was not like i want

this script code makes every Infernus with a blip

but i want it to make only a blip for the car i am on it

So please correct this:

      
    addEventHandler ( "onResourceStart", resourceRoot, 
        function ( ) 
            for _, theVehicles in ipairs ( getElementsByType("vehicle") ) do 
                if string.find ( getElementModel ( theVehicles ), 411 ) then        
                    createBlipAttachedTo ( theVehicles, 55 ) 
                end 
            end 
        end 
    ) 
      

And if u can do a code to make me a blip on the map , my name on game if u need it #[iMr][E'rrOr]_N

THX

Link to comment
  • MTA Team

Perhaps this is what you want. Next time, look at your own code. Yours doesn't make sense.

Server-side

local serial = "" 
  
addEventHandler("onResourceStart", resourceRoot, 
    function() 
        for _,vehicle in ipairs(getElementsByType("vehicle")) do 
            if getVehicleController(vehicle) then 
                if getPlayerSerial(getVehicleController(vehicle)) == "" then 
                    createBlipAttachedTo(vehicle, 55, 2, 255, 255, 255, 255, 0, 190) 
                    break 
                end 
            end 
        end 
         
        for _,player in ipairs(getElementsByType("player")) do 
            if getPlayerSerial(player) == serial then 
                createBlipAttachedTo(player, 0, 2, 255, 150, 10, 255) 
                break 
            end 
        end 
    end 
) 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        if getPlayerSerial(source) == serial then 
            createBlipAttachedTo(source, 0, 2, 255, 150, 10, 255) 
        end 
    end 
) 
  
addEventHandler("onVehicleEnter", root, 
    function(player, seat, jacker) 
        if getPlayerSerial(player) == serial then 
            createBlipAttachedTo(source, 55, 2, 255, 255, 255, 255, 0, 190) 
        end 
    end 
) 
  
addEventHandler("onVehicleExit", root, 
    function(player, seat, jacked) 
        if getPlayerSerial(player) == serial then 
            for _,element in ipairs(getAttachedElements(source)) do 
                if getElementType(element) == "blip" then 
                    destroyElement(element) 
                    break 
                end 
            end 
        end 
    end 
) 

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