Jump to content

HELP PLEASE :-\


~DarkRacer~

Recommended Posts

Hi, i'm a beginner in LUA scripting, i've made a code and i don't know what's wrong...?

  
function changeCar( player ) 
    if ( getPlayerTeam ( player ) ) then 
        local r, g, b = getTeamColor ( getPlayerTeam ( player ) ) 
        setVehicleColor ( source, r, g, b ) 
    end 
end 
  
addEventHandler( "onVehicleEnter", root,changeCar) 
  

the code is so simple it makes your car's color as same as your team's color.

BTW i make it only for race (DM)

this is the meta:

  
<meta> 
    <info name="CarCOLOR" description="blaBla" author="DarkRACER" type="script" version="1.0" /> 
    <script scr="car.lua" /> 
</meta> 
  

please if you noticed anything wrong in this code reply as soon as you can,

thanks.

Link to comment

 >    name="CarCOLOR" description="blaBla" author="DarkRACER" type="script" version="1.0" />    ="car.lua" type="server"/>> 

+

  
  
addEventHandler('onVehicleEnter', root, 
function(player) 
if (getPlayerTeam (player) ) then 
local r, g, b = getTeamColor (getPlayerTeam( player )) 
setVehicleColor( player, r, g, b) 
outputChatBox('Car Color Has Been Set!', player, 255, 0 ,0) 
  end 
end 
) 

How outputChatBox will fix any thing -_-" ??!!!

Link to comment
 >    name="CarCOLOR" description="blaBla" author="DarkRACER" type="script" version="1.0" />    ="car.lua" type="server"/>> 

+

  
  
addEventHandler('onVehicleEnter', root, 
function(player) 
if (getPlayerTeam (player) ) then 
local r, g, b = getTeamColor (getPlayerTeam( player )) 
setVehicleColor( player, r, g, b) 
outputChatBox('Car Color Has Been Set!', player, 255, 0 ,0) 
  end 
end 
) 

How outputChatBox will fix any thing -_-" ??!!!

If a 'script' node doesn't have type defined, it is defaulted to server so there is no need to add " type='server' ", neither it's going to fix anything.

Link to comment

It didn't work :( this is the code:

  
addEventHandler( "onPlayerPickUpRacePickup", root, 
    function() 
        if ( getPlayerTeam ( getLocalPlayer() ) ) then 
            local r, g, b = getTeamColor ( getPlayerTeam ( getLocalPlayer ) ) 
            setVehicleColor ( getPedOccupiedVehicle(getLocalPlayer()), r, g, b ) 
        end 
    end 
) 
  

Link to comment
It didn't work :( this is the code:
  
addEventHandler( "onPlayerPickUpRacePickup", root, 
    function() 
        if ( getPlayerTeam ( getLocalPlayer() ) ) then 
            local r, g, b = getTeamColor ( getPlayerTeam ( getLocalPlayer ) ) 
            setVehicleColor ( getPedOccupiedVehicle(getLocalPlayer()), r, g, b ) 
        end 
    end 
) 
  

Wrong for three reasons:

1. "getLocalPlayer" is client-side only.

2. You must check if the pickup is "vehiclechange" (unless it's changing color when picking any kind of pickup).

3. You need to add the event with addEvent, since it's not a MTA predefined event (perhaps it's not needed in newer MTA versions, I'm not sure about now but before it was).

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