Jump to content

Porque el Error?


DefearT

Recommended Posts

Hola me pueden ayudar a solucionar este error del resource fuel de la comunidad.

[2012-09-03 16:08:17] WARNING: fuel\s.lua:20: Bad argument @ 'createBlip' 
[2012-09-03 16:23:01] ERROR: fuel\s.lua:72: attempt to compare string with number 

Aqui el Server-Side:

local carFuel = {}; 
local gasStations = {}; 
local gasStationsBlip = {}; 
local gasStationsMarkers = {}; 
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
    function() 
        local xml = xmlLoadFile("carData.xml"); 
        local xmlNodes = xmlNodeGetChildren(xml); 
        for i,node in ipairs(xmlNodes) do 
           carFuel[tonumber(xmlNodeGetAttribute(node,'id'))] = tonumber(xmlNodeGetAttribute(node,'fuel')); 
        end 
        xmlUnloadFile(xml); 
        local xml = xmlLoadFile("garageData.xml"); 
        local xmlNodes = xmlNodeGetChildren(xml); 
        for i,node in ipairs(xmlNodes) do 
            local name = xmlNodeGetAttribute(node,'name'); 
            local x = tonumber(xmlNodeGetAttribute(node,'x')); 
            local y = tonumber(xmlNodeGetAttribute(node,'y')); 
            local z = tonumber(xmlNodeGetAttribute(node,'z')); 
            gasStationsBlip[name] = createBlip(x,y,z,51,0,0,0,0,0,0,0); 
            local moreKids = xmlNodeGetChildren(node); 
            gasStationsMarkers[name] = {}; 
            for i,v in ipairs(moreKids) do 
                local mx = tonumber(xmlNodeGetAttribute(v,'x')); 
                local my = tonumber(xmlNodeGetAttribute(v,'y')); 
                local mz = tonumber(xmlNodeGetAttribute(v,'z')); 
                gasStationsMarkers[name][i] = createMarker(mx,my,mz,'corona',3,128,128,0,64); 
                setElementData(gasStationsMarkers[name][i],'gasStation',true); 
            end 
        end 
        xmlUnloadFile(xml); 
    end 
) 
  
function fuelUse(p) 
    local vehicle = getPedOccupiedVehicle(p); 
    if vehicle then 
        setTimer(fuelUse,1000,1,p); 
        if getVehicleType(vehicle) ~= 'Automobile' and getVehicleType(vehicle) ~= 'Bike' and getVehicleType(vehicle) ~= 'Monster Truck' and getVehicleType(vehicle) ~= 'Quad' then return end 
        if getVehicleController(vehicle) ~= p then return end --### 
        if getVehicleEngineState(vehicle) == false then return end --### 
         
        local fuel = getCarFuel(vehicle) 
        if fuel == 0 then setVehicleEngineState(vehicle,false); return end --### 
         
        --[[local speedX, speedY, speedZ = getElementVelocity(vehicle); 
        vel = (speedX^2 + speedY^2 + speedZ^2)^(0.5)+(math.random(100,1000)/25000);]] 
        local newX,newY,newZ = getElementPosition(vehicle); 
        local oldX = getElementData(vehicle,'oldX') or newX; 
        local oldY = getElementData(vehicle,'oldY') or newY; 
        local oldZ = getElementData(vehicle,'oldZ') or newZ; 
        local vel = (getDistanceBetweenPoints2D(oldX,oldY,newX,newY)/70)+(math.random(100,1000)/50000); 
         
        local oldX = setElementData(vehicle,'oldX',newX); 
        local oldY = setElementData(vehicle,'oldY',newY); 
        local oldZ = setElementData(vehicle,'oldZ',newZ) 
         
        --if vel < 0.01 then return end --### 
         
        local remainingFuel = takeCarFuel(vehicle,vel); 
        if remainingFuel < 0.001 then 
            remainingFuel = 0; 
            outputChatBox('Your car has ran out of fuel.',v); 
            setVehicleEngineState(vehicle,false); 
        end 
    end 
end 
  
function startFuelUse(p,seat,jacked) 
    if getVehicleType(source) ~= 'Automobile' and getVehicleType(source) ~= 'Bike' and getVehicleType(source) ~= 'Monster Truck' and getVehicleType(source) ~= 'Quad' then return end 
    if seat ~= 0 then return end 
    if getCarFuel(source) <= 0 then setVehicleEngineState(source,false); end 
    setTimer(fuelUse,1000,1,p); 
end 
addEventHandler("onVehicleEnter",getRootElement(),startFuelUse) 
  
function switchEngine(playerSource) 
    local theVehicle = getPedOccupiedVehicle(playerSource); 
    if theVehicle and getVehicleController(theVehicle) == playerSource then 
        local state = getVehicleEngineState(theVehicle) 
        if state then 
            setVehicleEngineState(theVehicle, false); 
            outputChatBox('Car engine turned off.',playerSource); 
        else 
            if getCarFuel(theVehicle) <= 0 then return end 
            setVehicleEngineState(theVehicle, true); 
            outputChatBox('Car engine turned on.',playerSource); 
        end 
    end 
end 
addCommandHandler("engine",switchEngine); 
  
addEvent('pedSyphonVehicle',true); 
function pedSyphon(v) 
    if getCarFuel(source) >= carFuel[-1] then outputChatBox("You are holding as much fuel as you can carry.",source); return end 
    local n = math.random(100,200)/1000; 
    local left = takeCarFuel(v,n); 
    local total = addCarFuel(source,n); 
    if left <= 0 then outputChatBox("That car has no more fuel left.",source); return end 
    triggerClientEvent("onPedSyphonFuel",source); 
end 
addEventHandler('pedSyphonVehicle',getRootElement(),pedSyphon); 
  
addEvent('pedRefuelVehicle',true); 
function pedSyphon(v) 
    if getCarFuel(source) <= 0 then outputChatBox("You have no more fuel left.",source); return end 
    local maxFuel = carFuel[0]; 
    if carFuel[getElementModel(v)] then 
        maxFuel = getFuel[getElementModel(v)]; 
    end 
    if getCarFuel(v) >= maxFuel then 
        outputChatBox("That car is fully refueled.",source); return 
    end 
    local n = math.random(100,200)/1000; 
    local left = takeCarFuel(source,n); 
    local total = addCarFuel(v,n); 
    triggerClientEvent("onPedReFuel",source); 
end 
addEventHandler('pedRefuelVehicle',getRootElement(),pedSyphon); 
  
addEvent('onVehicleRefuel',true); 
function vehicleRefuel(v,m) 
    if not getElementData(m,'gasStation') then return end 
    if getElementType(v) ~= 'vehicle' then return end 
    if getVehicleType(v) ~= 'Automobile' and getVehicleType(v) ~= 'Bike' and getVehicleType(v) ~= 'Monster Truck' and getVehicleType(v) ~= 'Quad' then return end 
    local driver = getVehicleOccupants(v); 
    if not driver[0] then return end 
    if not isElementWithinMarker(v,m) then return end --### 
    local maxFuel = carFuel[0]; 
    if getPlayerMoney(driver[0]) < 25 then outputChatBox("You can't afford any more fuel.",p); return end 
    if carFuel[getElementModel(v)] then 
        maxFuel = carFuel[getElementModel(v)]; 
    end 
    if getCarFuel(v) >= maxFuel then return end 
    addCarFuel(v,15); 
    takePlayerMoney(driver[0],25); 
    if getCarFuel(v) >= maxFuel then outputChatBox("Your car has been fully refueled.",p); takeCarFuel(v,getCarFuel(v)-maxFuel); return end 
    setTimer(vehicleRefuel,500,1,v,m); 
end 
addEventHandler('onVehicleRefuel',getRootElement(),vehicleRefuel); 
function hitTheMarker(e) 
    setTimer(vehicleRefuel,1500,1,e,source); 
end 
addEventHandler('onMarkerHit',getRootElement(),hitTheMarker); 
  
function getCarFuel(v) 
    if getElementType(v) == 'vehicle' then 
        if getVehicleType(v) == 'Automobile' or getVehicleType(v) == 'Bike' or getVehicleType(v) == 'Monster Truck' or getVehicleType(v) == 'Quad' then 
            local fuel = getElementData(v,'fuel'); 
            local model = getElementModel(v); 
            if not carFuel[model] then model = 0; end 
            if not fuel then 
                if carFuel[model] then 
                    fuel = carFuel[model]; 
                    setElementData(v,'fuel',carFuel[model]); 
                else 
                    fuel = carFuel[0]; 
                    setElementData(v,'fuel',carFuel[0]); 
                end 
            end 
            return fuel; 
        end 
    elseif getElementType(v) == 'player' then 
        local fuel = getElementData(v,'fuel'); 
        if not fuel then 
            setElementData(v,'fuel',0); 
            return 0; 
        end 
        return fuel; 
    end 
end 
  
function addCarFuel(v,a) 
    if getElementType(v) == 'vehicle' then 
        if getVehicleType(v) == 'Automobile' or getVehicleType(v) == 'Bike' or getVehicleType(v) == 'Monster Truck' or getVehicleType(v) == 'Quad' then 
            local fuel = getElementData(v,'fuel'); 
            local model = getElementModel(v); 
            if not carFuel[model] then model = 0; end 
            if not fuel then 
                if carFuel[model] then 
                    fuel = carFuel[model]; 
                    setElementData(v,'fuel',carFuel[model]); 
                else 
                    fuel = carFuel[0]; 
                    setElementData(v,'fuel',carFuel[0]); 
                end 
            end 
            fuel = fuel + a; 
            if fuel > carFuel[model] then fuel = carFuel[model]; end 
            setElementData(v,'fuel',fuel); 
            return fuel; 
        end 
    elseif getElementType(v) == 'player' then 
        local fuel = getElementData(v,'fuel'); 
        if not fuel then 
            fuel = 0; 
        end 
        fuel = fuel + a; 
        if fuel > carFuel[-1] then fuel = carFuel[-1]; end 
        setElementData(v,'fuel',fuel); 
        return fuel; 
    end 
end 
  
function takeCarFuel(v,a) 
    if getElementType(v) == 'vehicle' then 
        if getVehicleType(v) == 'Automobile' or getVehicleType(v) == 'Bike' or getVehicleType(v) == 'Monster Truck' or getVehicleType(v) == 'Quad' then 
            local fuel = getElementData(v,'fuel'); 
            local model = getElementModel(v); 
            if not carFuel[model] then model = 0; end 
                if not fuel then 
                if carFuel[model] then 
                    fuel = carFuel[model]; 
                    setElementData(v,'fuel',carFuel[model]); 
                else 
                    fuel = carFuel[0]; 
                    setElementData(v,'fuel',carFuel[0]); 
                end 
            end 
            fuel = fuel - a; 
            if fuel < 0 then fuel = 0; end 
            setElementData(v,'fuel',fuel); 
            return fuel; 
        end 
    elseif getElementType(v) == 'player' then 
        local fuel = getElementData(v,'fuel'); 
        if not fuel then 
            fuel = 0; 
        end 
        fuel = fuel - a; 
        if fuel < 0 then fuel = 0; end 
        setElementData(v,'fuel',fuel); 
        return fuel; 
    end 
end 
  
addEvent('giveVehicleFuelOnSpawn',true); 
addEventHandler('giveVehicleFuelOnSpawn',getRootElement(),function() 
    getCarFuel(source); 
end); 

Otra cosa como se hace para poner un blip en el radar sin que salga en el radar, solo que se vuelva visible cuando esta serca del blip! Se entiende?

Gracias de ante mano! :D

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...