Arsilex Posted September 8, 2012 Share Posted September 8, 2012 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 ? Link to comment
Arsilex Posted September 8, 2012 Author Share Posted September 8, 2012 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 Link to comment
Castillo Posted September 8, 2012 Share Posted September 8, 2012 Algun error en el debug? Postea la funcion: "give". Link to comment
Arsilex Posted September 8, 2012 Author Share Posted September 8, 2012 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 Link to comment
Alexs Posted September 9, 2012 Share Posted September 9, 2012 No mire bien, pero give posee 4 argumentos pero tu solo usas 2. Link to comment
Castillo Posted September 9, 2012 Share Posted September 9, 2012 Aca no ayudamos a los que roban el trabajo de los demas. Tema cerrado. Link to comment
Recommended Posts