Jump to content

[Help] 3 errors i cant fix in my script


BieHDC

Recommended Posts

Hmmm i stuck now very hard :c

i managed some parts to work but the others i cant made.

Pls help and thx for help

[12:03:35] WARNING: [new]/vehcol/vehcolch.lua:12: Bad argument @ 'getVehicleOccu

pant'

[12:03:39] WARNING: [new]/vehcol/vehcolch.lua:24: Bad argument @ 'getPedOccupied

Vehicle'

[12:03:39] WARNING: [new]/vehcol/vehcolch.lua:25: Bad argument @ 'getElementHeal

th' [Expected element at argument 1, got boolean]

--serverside 
isitflickering = "false" 
  
function plssavemycolor ( thePlayer ) 
isitflickering = "false" 
    setTimer (plssavemycolor2, 15000, 1, thePlayer) 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), plssavemycolor ) 
  
function plssavemycolor2 ( root ) 
isitflickering = "false" 
car = getVehicleOccupant ( thePlayer ) 
    if ( car ) then 
            d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12 = getVehicleColor (car, true ) 
    end 
end 
  
function plsresetmycolor ( thePlayer ) 
setVehicleColor ( car, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12 ) 
isitflickering = "false" 
end 
  
function burningcar ( root ) 
    car = getPedOccupiedVehicle( thePlayer ) 
    vhealth = getElementHealth ( car ) 
    if ( car ) then 
            if vhealth <= 300 then 
                if isitflickering == "false" then 
                    setTimer ( flickit, 50, 1 ) 
                    isitflickering = "true" 
                elseif vhealth >= 1000 then 
                    isitflickering = "false" 
                    setTimer ( plsresetmycolor, 100, 1, player ) 
                end 
            end 
    end 
end 
addEventHandler("onVehicleDamage", root, burningcar ) 
  
function flickit ( player ) 
car = getVehicleOccupant ( player ) 
c = 1 
setVehicleColor ( car, c, c, c, c ) 
setTimer ( burcrd, 100, 1, thePlayer ) 
end 
  
function burcrd ( thePlayer ) 
car = getPedOccupiedVehicle( player ) 
vhealth = getElementHealth( car ) 
    if ( car ) then 
            if vhealth <= 300 then 
                local cc = 3 
                setVehicleColor ( car, cc, cc, cc, cc ) 
                setTimer ( flickit, 100, 1, thePlayer ) 
            elseif vhealth >= 1000 then 
                isitflickering = "false" 
                setTimer ( plsresetmycolor, 100, 1, player ) 
            end 
    end 
end 
  

Link to comment

I have read all tut again, but i still cant get these 3 errors out -.-

i give it up, pls can someone fix?

Edit: Do you think i shouldnt make it over players?

can i do all vehicles in the map in a table and set if for thevehicle without players included?

[12:54:03] WARNING: [new]/vehcol/vehcolch.lua:25: Bad argument @ 'getPedOccupied

Vehicle'

[12:54:04] WARNING: [new]/vehcol/vehcolch.lua:40: Bad argument @ 'getPedOccupied

Vehicle'

[12:54:04] WARNING: [new]/vehcol/vehcolch.lua:41: Bad argument @ 'getElementHeal

th' [Expected element at argument 1, got boolean]

  
function checkifcarburn ( thePlayer ) --this works, but only built in to check damage 
    local car2 = getPedOccupiedVehicle ( thePlayer ) 
    local vhealth = getElementHealth ( car2 ) 
    outputChatBox ( "Vehicle Health is " ..vhealth.. "." , thePlayer ) 
    setTimer ( checkifcarburn, 2000, 1, thePlayer) 
end 
addCommandHandler ( "fic", checkifcarburn ) 
  
--car = getPedOccupiedVehicle( player )  --some parameters i used client side (ignore them) 
--vhealth = getElementHealth( car ) 
--d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12 = getVehicleColor ( car, true ) 
  
isitflickering = "false" 
  
function plssavemycolor ( source ) 
isitflickering = "false" 
    setTimer ( plssavemycolor2, 15000, 1, thePlayer ) 
    outputChatBox ( "try to get color", thePlayer ) 
end 
addEventHandler ( "onPlayerSpawn", getRootElement(), plssavemycolor ) 
  
function plssavemycolor2 ( thePlayer ) 
isitflickering = "false" 
local car = getPedOccupiedVehicle ( player ) 
    if ( car ) then 
            d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12 = getVehicleColor ( car, true ) 
            outputChatBox ( "got colour?", thePlayer ) 
    else outputChatBox ( "no colour?", thePlayer ) 
    end 
end 
  
function plsresetmycolor ( thePlayer ) 
local car = getPedOccupiedVehicle( thePlayer ) 
    setVehicleColor ( car, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12 ) 
    isitflickering = "false" 
end 
  
function burningcar ( source ) 
    local car = getPedOccupiedVehicle( thePlayer ) 
    local vhealth = getElementHealth ( car ) 
    if ( car ) then 
            if vhealth <= 300 then 
                if isitflickering == "false" then 
                    setTimer ( flickit, 50, 1 ) 
                    isitflickering = "true" 
                elseif vhealth >= 1000 then 
                    isitflickering = "false" 
                    setTimer ( plsresetmycolor, 100, 1, thePlayer ) 
                end 
            end 
    end 
end 
addEventHandler("onVehicleDamage", root, burningcar ) 
  
function flickit ( thePlayer ) 
local car = getVehicleOccupant ( thePlayer ) 
local c = 1 
    setVehicleColor ( car, c, c, c, c ) 
    setTimer ( burcrd, 100, 1, thePlayer ) 
end 
  
function burcrd ( thePlayer ) 
local car = getPedOccupiedVehicle( thePlayer ) 
local vhealth = getElementHealth( car ) 
    if ( car ) then 
            if vhealth <= 300 then 
                local cc = 3 
                setVehicleColor ( car, cc, cc, cc, cc ) 
                setTimer ( flickit, 100, 1, thePlayer ) 
            elseif vhealth >= 1000 then 
                isitflickering = "false" 
                setTimer ( plsresetmycolor, 100, 1, thePlayer ) 
            end 
    end 
end 
  
  
  

Link to comment
  • Moderators

it depends if you are going to change all vehicles or only the ones that got controlled by the player.

I would punt the player as key and the vehicle + colours as data.

vehicleTable = {} 
  
addCommandHandler ( "check",  
function( thePlayer ) 
    local car = getPedOccupiedVehicle ( thePlayer ) 
    if car then 
        local d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12 = getVehicleColor ( car, true ) 
        vehicleTable[thePlayer] = {car = car, oldColours ={d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11, d12} } 
    end 
end) 
  
addCommandHandler ( "check2",  
function( thePlayer ) 
    local vehiclePlayertable = vehicleTable[thePlayer] 
    if vehiclePlayertable then 
        local car = vehiclePlayertable.car 
        if isElement(car) then  
            local oldColours = vehiclePlayertable.oldColours 
            if oldColours then 
                setVehicleColor ( car,unpack(oldColours)) 
            end 
        else 
            vehicleTable[thePlayer]= nil -- remove it from the table 
        end 
    end 
end) 
  
addEventHandler("onPlayerQuit",root, 
function () 
    if vehicleTable[source] then 
        vehicleTable[source] = nil 
    end 
end) 

Link to comment

i already got this working sucsessfully on clientside but there were the colours not synced :c

and what if isElement not player?

edit: starting at the first part to get colour player isnt element...so not working :C

i managed 6 errors with player as element but these i dont get to work :S

do i need a combination of client and server?

and if yes how to get the player serverside or how to get colour synced?

Link to comment
  • Moderators
well serverside syncs the colours, clientside is easier because you don't have to store for each player, just only for your self.

When you want to calculate and manage the colours client side, you use triggerServerEvent or use elementdata.

It is even possible to write it all client side and use elementdata as data sharer. (or a g_ table, but I never used that before)

A player is a element, when he leaves and a timer is running and contains the player userdata, you can't use it any more. To be sure the player element remains in the server, we check that with isElement.

But still I would script it serverside, to prevent the latency of players. But also direct changes at the gamemode can be faster solved there, cause of no/low ping /fps/cpu latency.
Link to comment

i found out something interesting...

i have had a look at freeroam resource and there is colour also ONLY clientside, BUT the colour is updated with on client render :o

if i simple add an update color handler with on client render maybe it works? :o

edit:

function updateColor() 
    if (not colorPicker.isSelectOpen) then return end 
    local r, g, b = colorPicker.updateTempColors() 
    if (editingVehicle and isElement(editingVehicle)) then 
        local r1, g1, b1, r2, g2, b2 = getVehicleColor(editingVehicle, true) 
        if (guiCheckBoxGetSelected(checkColor1)) then 
            r1, g1, b1 = r, g, b 
        end 
        if (guiCheckBoxGetSelected(checkColor2)) then 
            r2, g2, b2 = r, g, b 
        end 
        if (guiCheckBoxGetSelected(checkColor3)) then 
            setVehicleHeadLightColor(editingVehicle, r, g, b) 
        end 
        setVehicleColor(editingVehicle, r1, g1, b1, r2, g2, b2) 
    end 
end 
addEventHandler("onClientRender", root, updateColor) 

Link to comment
  • Moderators

nope, this is for direct updating the vehicle colours, when you are busy with your colour picker.

Learn lua and then come back asking for help for things like this.

I showed you how to do this, but you wanted to stick with your own way.

Good luck,

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