Jump to content

¿Que significa este error?


depato123

Recommended Posts

Posted

Hola, queria saber que significa este error.

Error:

call: failed to call 'gui:hint' [string "?"]

Server side:

exports.gui:hint( "Este vehiculo no te pertenece" ) 

Lo que tendria que hacer el resource es que al entrar en un vehiculo apareciera como un gui "Este vehiculo pertenece a Usuario"

pero me sale el error antes mencionado.

Necesito ayuda¡¡¡

Posted
Quiere decir que el recurso "gui" no esta iniciado ( o no existe ), o puede querer decir que la funcion no esta exportada desde "gui".

El recurso "Gui" esta iniciado y funcionando, ¿como puedo verificar si la funcion no esta exportada desde gui?

Posted

encontre esto en el archivo meta.xml del resource gui.

eso significa que esta bien exportado? ¿ahora que debo hacer para que no salga el error?

pd el resource que tiene el exports.gui:hint( "Este vehiculo no te pertenece" ) esta en server side? debe ir si o si en client side?

Posted

Ah, ya entiendo el problema, vos estas usando el exports server side, pero como ves, la funcion solo esta exportada client side ( no existe server side ).

Posted

Gracias, ahora intente solucionarlo usando un triggedClientEvent:

Server

triggerClientEvent ( "gui", source) 

Client

function gui(source) 
    exports.gui:hint( "(( Este " .. getVehicleName( source ) .. " pertenece a " .. name .. ". ))" ) 
end 
addEvent( "gui", true ) 
addEventHandler( "gui", getRootElement(), gui) 

Pero no sirve, no salta ningun error en el debug script. ¿Que debo hacer?

Posted
Postea el client side.

Client side del resource de los vehiculos

function guiPertenecido(player) 
    exports.gui:hint( "(( Este " .. getVehicleName( source ) .. " pertenece a " .. name .. ". ))" ) 
end 
addEvent( "guiPertenecido", true ) 
addEventHandler( "guiPertenecido", getRootElement(), guiPertenecido) 

Client side de gui:

local screenX, screenY = guiGetScreenSize( ) 
local cursorX, cursorY = -1, -1 
local defaultWidth = 360 
local width = defaultWidth 
local height = 70 
local x = ( screenX - width ) / 2 
local y = screenY - height - 60 
local line_height = 16 
  
-- 
  
local title, text, icon, color, start, duration 
  
-- 
  
addEventHandler( "onClientRender", root, 
    function( ) 
        if start and duration then 
            local tick = getTickCount( ) 
            if tick > start + duration then 
                title = nil 
                text = nil 
                icon = nil 
                color = nil 
                start = nil 
                duration = nil 
            else 
                local alpha = 1 
                if start + duration / 2 < tick then 
                    alpha = ( start + duration - tick ) / duration * 2 
                end 
                 
                dxDrawRectangle( x - 5, y - 5, width + 10, height + 10, tocolor( color[1], color[2], color[3], color[4] * alpha ), true ) 
                dxDrawImage( x, y + ( height - 64 ) / 2, 64, 64, "images/" .. icon .. ".png", 0, 0, 0, tocolor( 255, 255, 255, 255 * alpha ), true ) 
                dxDrawText( title, x + 65, y, x + width, y + 18, tocolor( 255, 255, 255, 255 * alpha ), 0.6, "bankgothic", "left", "top", true, false, true ) 
                dxDrawText( text, x + 70, y + 18, x + width, y + height, tocolor( 255, 255, 255, 255 * alpha ), 1, "default", "left", "top", true, true, true ) 
            end 
        end 
    end 
) 
  
-- 
  
function hint( ti, te, ic, dur ) 
    if ic == 1 then 
        icon = "okay" 
        color = { 0, 93, 0, 193 } 
    elseif ic == 2 then 
        icon = "warning" 
        color = { 127, 97, 31, 193 } 
    elseif ic == 3 then 
        icon = "error" 
        color = { 127, 31, 31, 193 } 
    else 
        icon = "info" 
        color = { 31, 127, 127, 193 } 
    end 
     
    start = getTickCount( ) 
    if type( dur ) ~= "number" or dur < 500 then 
        duration = 10000 
    else 
        duration = dur 
    end 
     
    title = ti 
    text = te 
     
    return true 
end 
  
addEvent( "gui:hint", true ) 
addEventHandler( "gui:hint", getLocalPlayer( ), hint ) 

Posted
Postea el codigo tuyo al que queres agregarle el mensaje.

¿El client side del resource de los vehiculos? (el resource de los vehiculos es el que le quiero agregar exports.gui:hint( "Este vehiculo no te pertenece" ) )

Este es el client de los vehiculos

  
local engineState = nil 
local localPlayer = getLocalPlayer( ) 
  
addEventHandler( "onClientVehicleStartEnter", resourceRoot, 
    function( player, seat ) 
        -- save the state for when we're done entering, as GTA automatically turns the engines on 
        if seat == 0 and player == localPlayer then 
            engineState = { vehicle = source, state = getVehicleEngineState( source ) } 
        else 
            engineState = nil 
        end 
    end 
) 
addEventHandler( "onClientVehicleEnter", resourceRoot, 
    function( player, seat ) 
        -- restore the engine state 
        if engineState then 
            if seat == 0 and player == localPlayer and engineState.vehicle == source then 
                setVehicleEngineState( source, engineState.state ) 
            end 
            engineState = nil 
        end 
    end 
) 
  
function open(x, y, z) 
    sound = playSound3D( "open.mp3", x, y, z, false ) 
    setSoundMaxDistance( sound, 15 ) 
    setSoundVolume( sound, 3 ) 
end 
addEvent( "open", true ) 
addEventHandler( "open", getRootElement(), beepbeep) 
  
function guiPertenecido(player) 
    exports.gui:hint( "(( Este " .. getVehicleName( source ) .. " pertenece a " .. name .. ". ))" ) 
end 
addEvent( "guiPertenecido", true ) 
addEventHandler( "guiPertenecido", getRootElement(), guiPertenecido) 

Posted
Ese es el script donde querias agregar esto?
exports.gui:hint( "Este vehiculo no te pertenece" ) 

ajam, al principio queria agregarlo en serverside pero luego me dijiste que no se podia, por lo tanto intente hacer un triggedClientEvent pero sigo sin poder hacerlo. :(

Posted
Pero tu script es client side, para que necesitas server side?

Nononono, el script no esta solo en client side, sino que esta server side y client side. Por eso intente trigearlo

Posted

Server side

  
local vehiclesIgnoringLocked =
{
    [448] = true, [461] = true, [462] = true, [463] = true, [481] = true, [509] = true, [510] = true, [521] = true, [522] = true, [581] = true, [586] = true, -- bikes
    [430] = true, [446] = true, [452] = true, [453] = true, [454] = true, [472] = true, [473] = true, [484] = true, [493] = true, [595] = true, -- boats
    [424] = true, [457] = true, [471] = true, [539] = true, [568] = true, [571] = true -- recreational vehicles
}
 
--
 
local addCommandHandler_ = addCommandHandler
      addCommandHandler  = function( commandName, fn, restricted, caseSensitive )
    -- add the default command handlers
    if type( commandName ) ~= "table" then
        commandName = { commandName }
    end
    for key, value in ipairs( commandName ) do
        if key == 1 then
            addCommandHandler_( value, fn, restricted, caseSensitive )
        else
            addCommandHandler_( value,
                function( player, ... )
                    -- check if he has permissions to execute the command, default is not restricted (aka if the command is restricted - will default to no permission; otherwise okay)
                    if hasObjectPermissionTo( player, "command." .. commandName[ 1 ], not restricted ) then
                        fn( player, ... )
                    end
                end
            )
        end
    end
   
    -- check for alternative handlers, such as gotovehicle = gotoveh, gotocar
    for k, v in ipairs( commandName ) do
        if v:find( "vehicle" ) then
            for key, value in pairs( { "veh", "car" } ) do
                local newCommand = v:gsub( "vehicle", value )
                if newCommand ~= v then
                    -- add a second (replaced) command handler
                    addCommandHandler_( newCommand,
                        function( player, ... )
                            -- check if he has permissions to execute the command, default is not restricted (aka if the command is restricted - will default to no permission; otherwise okay)
                            if hasObjectPermissionTo( player, "command." .. commandName[ 1 ], not restricted ) then
                                fn( player, ... )
                            end
                        end
                    )
                end
            end
        end
    end
end
 
--
 
local p = { }
 
local getPedOccupiedVehicle_ = getPedOccupiedVehicle
      getPedOccupiedVehicle = function( ped )
    local vehicle = isPedInVehicle( ped ) and getPedOccupiedVehicle_( ped )
    if vehicle and ( p[ ped ] and p[ ped ].vehicle == vehicle or getElementParent( vehicle ) ~= getResourceDynamicElementRoot( resource ) ) then
        return vehicle
    end
    return false
end
 
local function isPedEnteringVehicle( ped )
    return getPedOccupiedVehicle_( ped ) and not getPedOccupiedVehicle( ped )
end
 
--
 
local vehicleIDs = { }
local vehicles = { }
 
addEventHandler( "onResourceStart", resourceRoot,
    function( )
        -- Looking at it from a technical point of view, loading vehicles on a non-existant table makes only limited sense
        if not exports.sql:create_table( 'vehicles',
            {
                { name = 'vehicleID', type = 'int(10) unsigned', auto_increment = true, primary_key = true },
                { name = 'model', type = 'int(10) unsigned' },
                { name = 'posX', type = 'float' },
                { name = 'posY', type = 'float' },
                { name = 'posZ', type = 'float' },
                { name = 'rotX', type = 'float' },
                { name = 'rotY', type = 'float' },
                { name = 'rotZ', type = 'float' },
                { name = 'interior', type = 'tinyint(3) unsigned', default = 0 },
                { name = 'dimension', type = 'int(10) unsigned', default = 0 },
                { name = 'respawnPosX', type = 'float' },
                { name = 'respawnPosY', type = 'float' },
                { name = 'respawnPosZ', type = 'float' },
                { name = 'respawnRotX', type = 'float' },
                { name = 'respawnRotY', type = 'float' },
                { name = 'respawnRotZ', type = 'float' },
                { name = 'respawnInterior', type = 'int(10) unsigned', default = 0 },
                { name = 'respawnDimension', type = 'int(10) unsigned', default = 0 },
                { name = 'numberplate', type = 'varchar(8)' },
                { name = 'health', type = 'int(10) unsigned', default = 1000 },
                { name = 'color1', type = 'tinyint(3) unsigned', default = 0 },
                { name = 'color2', type = 'tinyint(3) unsigned', default = 0 },
                { name = 'characterID', type = 'int(11)', default = 0 },
                { name = 'locked', type = 'tinyint(3) unsigned', default = 0 },
                { name = 'engineState', type = 'tinyint(3) unsigned', default = 0 },
                { name = 'lightsState', type = 'tinyint(3) unsigned', default = 0 },
                { name = 'tintedWindows', type = 'tinyint(3) unsigned', default = 0 },
                { name = 'fuel', type = 'float unsigned', default = 100 },
            } ) then cancelEvent( ) return end
       
        -- load all vehicles
        local result = exports.sql:query_assoc( "SELECT * FROM vehicles ORDER BY vehicleID ASC" )
        if result then
            for key, data in ipairs( result ) do
                local vehicle = createVehicle( data.model, data.posX, data.posY, data.posZ, data.rotX, data.rotY, data.rotZ, numberplate )
               
                -- tables for ID -> vehicle and vehicle -> data
                vehicleIDs[ data.vehicleID ] = vehicle
                vehicles[ vehicle ] = { vehicleID = data.vehicleID, respawnInterior = data.respawnInterior, respawnDimension = data.respawnDimension, characterID = data.characterID, engineState = not doesVehicleHaveEngine( vehicle ) or data.engineState == 1, tintedWindows = data.tintedWindows == 1, fuel = data.fuel }
               
                -- some properties
                setElementHealth( vehicle, data.health )
                if data.health <= 300 then
                    setVehicleDamageProof( vehicle, true )
                    vehicles[ vehicle ].engineState = false
                end
                setVehicleColor( vehicle, data.color1, data.color2, data.color1, data.color2 ) -- most vehicles don't use second/third color anyway
                setVehicleRespawnPosition( vehicle, data.respawnPosX, data.respawnPosY, data.respawnPosZ, data.respawnRotX, data.respawnRotY, data.respawnRotZ )
                setElementInterior( vehicle, data.interior )
                setElementDimension( vehicle, data.dimension )
                setVehicleLocked( vehicle, data.locked == 1 )
                setVehicleEngineState( vehicle, data.engineState == 1 )
                setVehicleOverrideLights( vehicle, data.lightsState + 1 )
                setElementData( vehicle, "fuel", data.fuel )
                if data.upgrade0 then
                addVehicleUpgrade (vehicle, data.upgrade0 )
                end
                if data.upgrade1 then
                addVehicleUpgrade (vehicle, data.upgrade1 )
                end
                if data.upgrade2 then
                addVehicleUpgrade (vehicle, data.upgrade2 )
                end
                if data.upgrade3 then
                addVehicleUpgrade (vehicle, data.upgrade3 )
                end
                if data.upgrade4 then
                addVehicleUpgrade (vehicle, data.upgrade4 )
                end
                if data.upgrade5 then
                addVehicleUpgrade (vehicle, data.upgrade5 )
                end
                if data.upgrade6 then   
                addVehicleUpgrade (vehicle, data.upgrade6 )
                end
                if data.upgrade7 then
                addVehicleUpgrade (vehicle, data.upgrade7 )
                end
                if data.upgrade8 then
                addVehicleUpgrade (vehicle, data.upgrade8 )
                end
                if data.upgrade9 then
                addVehicleUpgrade (vehicle, data.upgrade9 )
                end
                if data.upgrade10 then
                addVehicleUpgrade (vehicle, data.upgrade10 )
                end
                if data.upgrade11 then
                addVehicleUpgrade (vehicle, data.upgrade11 )
                end
                if data.upgrade12 then
                addVehicleUpgrade (vehicle, data.upgrade12 )
                end
                if data.upgrade13 then
                addVehicleUpgrade (vehicle, data.upgrade13 )
                end
                if data.upgrade14 then
                addVehicleUpgrade (vehicle, data.upgrade14 )
                end
                if data.upgrade15 then
                addVehicleUpgrade (vehicle, data.upgrade15 )
                end
                if data.upgrade16 then
                addVehicleUpgrade (vehicle, data.upgrade16 )
                end
                if data.paintjob then
                setVehiclePaintjob ( vehicle, data.paintjob )
                end
            end
        end
       
        -- bind a key for everyone
        for key, value in ipairs( getElementsByType( "player" ) ) do
            bindKey( value, "num_3", "down", "lockvehicle" )
            bindKey( value, "num_1", "down", "toggleengine" )
            bindKey( value, "num_2", "down", "togglelights" )
        end
       
        --
       
        -- Fuel update
        setTimer(
            function( )
                for vehicle, data in pairs( vehicles ) do
                    if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then
                        vehicles[ vehicle ] = nil
                    elseif data.engineState and data.fuel and not isVehicleEmpty( vehicle ) and doesVehicleHaveEngine( vehicle ) and doesVehicleHaveFuel( vehicle ) then
                        local vx, vy, vz = getElementVelocity( vehicle )
                        local speed = math.sqrt( vx * vx + vy * vy )
                        local loss = ( speed > 0.65 and 2 * speed or speed ) * 0.1 + 0.005
                       
                        data.fuel = math.max( data.fuel - loss, 0 )
                        if math.floor( data.fuel + 0.5 ) ~= getElementData( vehicle, "fuel" ) then
                            setElementData( vehicle, "fuel", math.floor( data.fuel + 0.5 ) )
                        end
                       
                        if data.fuel == 0 then
                            setVehicleEngineState( vehicle, false )
                            for seat = 0, getVehicleMaxPassengers( vehicle ) do
                                local player = getVehicleOccupant( vehicle, seat )
                                if player then
                                    triggerClientEvent( player, "gui:hint", player, "Out of Fuel", "Your " .. getVehicleName( vehicle ) .. " ran out of fuel!\nTo prevent this from happening, refill it regulary.", 3 )
                                end
                            end
                        end
                    end
                end
            end,
            2000,
            0
        )
    end
)
 
addCommandHandler( { "createvehicle", "makevehicle" },
    function( player, commandName, ... )
        model = table.concat( { ... }, " " )
        model = getVehicleModelFromName( model ) or tonumber( model )
        if model then
            local x, y, z, rz = getPositionInFrontOf( player )
           
            local vehicle = createVehicle( model, x, y, z, 0, 0, rz )
            if vehicle then
                local color1, color2 = getVehicleColor( vehicle )
                local vehicleID, error = exports.sql:query_insertid( "INSERT INTO vehicles (model, posX, posY, posZ, rotX, rotY, rotZ, numberplate, color1, color2, respawnPosX, respawnPosY, respawnPosZ, respawnRotX, respawnRotY, respawnRotZ, interior, dimension, respawnInterior, respawnDimension) VALUES (" .. table.concat( { model, x, y, z, 0, 0, rz, '"%s"', color1, color2, x, y, z, 0, 0, rz, getElementInterior( player ), getElementDimension( player ), getElementInterior( player ), getElementDimension( player ) }, ", " ) .. ")", getVehiclePlateText( vehicle ) )
                if vehicleID then
                    -- tables for ID -> vehicle and vehicle -> data
                    vehicleIDs[ vehicleID ] = vehicle
                    vehicles[ vehicle ] = { vehicleID = vehicleID, respawnInterior = getElementInterior( player ), respawnDimension = getElementDimension( player ), characterID = 0, engineState = false, tintedWindows = false, fuel = 100 }
                   
                    -- some properties
                   
Posted
addEventHandler( "onVehicleEnter", resourceRoot, 
    function( player ) 
        if isVehicleLocked( source ) then 
            cancelEvent( ) 
            removePedFromVehicle( player ) 
            --outputChatBox( "(( Este " .. getVehicleName( source ) .. " esta cerrado. ))", player, 255, 0, 0 ) 
            triggerClientEvent ( player, "gui:hint", player, "Vehiculo", "(( Este " .. getVehicleName( source ) .. " pertenece a " .. name .. ". ))", 3 ) 
        else 
            local data = vehicles[ source ] 
            if data then 
                if data.characterID > 0 then 
                    local name = exports.players:getCharacterName( data.characterID ) 
                    if name then 
                        triggerClientEvent ( player, "gui:hint", player, "Vehiculo", "(( Este " .. getVehicleName( source ) .. " pertenece a " .. name .. ". ))", 3 ) 
                    else 
                        outputDebugString( "Vehicle " .. data.vehicleID .. " (" .. getVehicleName( source ) .. ") has an invalid owner.", 2 ) 
                    end 
                elseif data.characterID < 0 then 
                    outputChatBox( "(( Este " .. getVehicleName( source ) .. " pertenece a " .. tostring( exports.factions:getFactionName( -data.characterID ) ) .. ". ))", player, 255, 204, 0 ) 
                end 
                
                if not p[ player ] then 
                    p[ player ] = { } 
                end 
                p[ player ].vehicle = source 
                
                setVehicleEngineState( source, not doesVehicleHaveEngine( source ) or data.engineState ) 
                
                if hasTintedWindows( source ) then 
                    exports.players:updateNametag( player ) 
                end 
            end 
        end 
    end 
) 

  • Recently Browsing   0 members

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