Jump to content

Items


Arsilex

Recommended Posts

Posted

Bueno tengo esto

addEvent( "items:present", true ) 
addEventHandler( "items:present", root, 
function( slot, item, playerto ) 
    local item = get( source )[ slot ] 
    if item then 
        local id = item.item 
        local name = item.name or getName( id ) 
        give(  playerto, slot ) 
        exports.chat:me( source, "tiro su " .. name .. "." ) 
    end 
end 
  
) 

-- El codigo... 
window = guiCreateWindow(376,591,270,143,"Dar item",false) 
guiSetVisible( window, false ) 
memo = guiCreateEdit(54,59,158,36,"t",false,window) 
label = guiCreateLabel(52,21,164,34,"Escribe el nombre del jugador\n al que le quieres dar el item",false,window) 
guiLabelSetColor(label,0,200,0) 
guiLabelSetVerticalAlign(label,"top") 
guiLabelSetHorizontalAlign(label,"left",false) 
aceptar = guiCreateButton(22,107,96,26,"Aceptar",false,window) 
cancelar = guiCreateButton(153,107,96,26,"Cancelar",false,window) 
--------------- 
-- funciones -- 
--------------- 
function openGiveItemGUI( player, item ) 
    guiSetVisible( window, true ) 
    showCursor( true ) 
    guiSetInputEnabled( true ) 
    setElementData( player, "item", item ) 
    guiSetText( memo, "" ) 
end 
  
function onAccept() 
    item = getElementData( getLocalPlayer(), "item" ) 
    playerto = guiGetText( memo ):gsub( " ", "_" ) 
    playerto = tostring( playerto ) 
    outputDebugString( playerto ) 
    triggerServerEvent( "items:present", getLocalPlayer(), item, playerto ) 
    guiSetVisible( window, false ) 
    --showCursor( false ) 
    guiSetInputEnabled( false ) 
end 
addEventHandler( "onClientGUIClick", aceptar, onAccept, false ) 
  
function onCancel() 
    guiSetVisible( window, false ) 
    --showCursor( false ) 
    guiSetInputEnabled( false ) 
end 
addEventHandler( "onClientGUIClick", cancelar, onCancel, false ) 

por que al poner el id se quita el item pero no se le pone al otro :S?

rsilex.png.0e6ad382b3fdc3cbe6390e3e847572c9.png
Posted

alguen tiene alguna idea de como hacerlo

addEvent( "items:present", true ) 
addEventHandler( "items:present", root, 
function( slot, item, playerto ) 
    local item = get( source )[ slot ] 
    if item then 
        local id = item.item 
        local name = item.name or getName( id ) 
        give(  playerto, slot ) 
        exports.chat:me( source, "tiro su " .. name .. "." ) 
    end 
end 
  
) 

es lo que me me falla que no le da el item a playerto

rsilex.png.0e6ad382b3fdc3cbe6390e3e847572c9.png
Posted

Algun error en el debug?

Postea la funcion: "give".

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
function give( element, item, value, name ) 
    -- we need a base to work on 
    if load( element ) then 
        -- we need at least item and value 
        if type( item ) == 'number' and ( type( value ) == "number" or type( value ) == "string" ) then 
            -- name can be optional, though if it's not, we need to escape it 
            name2 = "NULL" 
            if name then 
                name2 = "'" .. exports.sql:escape_string( tostring( name ) ) .. "'" 
            else 
                name = nil 
            end 
             
            -- we need to know our item index 
            local index, error = exports.sql:query_insertid( "INSERT INTO items (owner, item, value, name) VALUES (" .. getID( element ) .. ", " .. item .. ", '%s', " .. name2 .. ")", value ) 
            if index then 
                -- add at the last position as a new item 
                table.insert( data[ element ].items, { index = index, item = item, value = value, name = name } ) 
                 
                -- tell everyone who wants to know 
                notify( element ) 
                 
                return true 
            end 
            return false, "MySQL Query failed" 
        end 
        return false, "Invalid Parameters" 
    end 
    return false, "Unable to load element" 
end 

Ningun error

rsilex.png.0e6ad382b3fdc3cbe6390e3e847572c9.png
Posted

Aca no ayudamos a los que roban el trabajo de los demas.

Tema cerrado.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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