Arsilex Posted June 21, 2012 Share Posted June 21, 2012 Que debería hacer para que cuando pongan dararma pekio123 que le den el arma que el hombre tiene en la mano ._.? addCommandHandler( "dararma", function( player, commandName, otherPlayer ) local weapon = tonumber( weapon ) if otherPlayer and weapon and math.ceil( weapon ) == weapon and weapon > 1 then local other, name = exports.players:getFromName( player, otherPlayer ) if other then if player ~= other then local x, y, z = getElementPosition( player ) if getDistanceBetweenPoints3D( x, y, z, getElementPosition( other ) ) < 5 then outputChatBox( "Le diste " .. name .. " tu " .. weapon .. ".", player, 0, 255, 0 ) outputChatBox( getPlayerName( player ):gsub( "_", " " ) .. " te dio un " .. weapon .. ".", other, 0, 255, 0 ) else outputChatBox( "Estas lejos de " .. name .. ".", player, 255, 0, 0 ) end else outputChatBox( "No puedes darte arma a ti mismo.", player, 255, 0, 0 ) end end else outputChatBox( "Syntax: /" .. commandName .. " [player] [weapon]", player, 255, 255, 255 ) end end ) Link to comment
Castillo Posted June 21, 2012 Share Posted June 21, 2012 addCommandHandler ( "dararma", function ( player, commandName, otherPlayer ) local weapon = getPedWeapon ( player ) if ( otherPlayer and weapon and weapon > 1 ) then local other, name = exports.players:getFromName ( player, otherPlayer ) if ( other ) then if ( player ~= other ) then local x, y, z = getElementPosition ( player ) if ( getDistanceBetweenPoints3D ( x, y, z, getElementPosition ( other ) ) < 5 ) then giveWeapon ( other, weapon ) takeWeapon ( player, weapon ) outputChatBox ( "Le diste " .. name .. " tu " .. weapon .. ".", player, 0, 255, 0 ) outputChatBox ( getPlayerName ( player ):gsub ( "_", " " ) .. " te dio un " .. weapon .. ".", other, 0, 255, 0 ) else outputChatBox ( "Estas lejos de " .. name .. ".", player, 255, 0, 0 ) end else outputChatBox ( "No puedes darte arma a ti mismo.", player, 255, 0, 0 ) end end else outputChatBox ( "Syntax: /" .. commandName .. " [player] [weapon]", player, 255, 255, 255 ) end end ) Eso? Link to comment
Arsilex Posted June 21, 2012 Author Share Posted June 21, 2012 si thx aora lo pruebo y te cuento Link to comment
Arsilex Posted June 21, 2012 Author Share Posted June 21, 2012 olle pero cuando se lo doy solo le da 30 balas Link to comment
Castillo Posted June 21, 2012 Share Posted June 21, 2012 Eso es porque no le pusiste que le de las balas tambien. addCommandHandler ( "dararma", function ( player, commandName, otherPlayer ) local weapon = getPedWeapon ( player ) local ammo = getPedTotalAmmo ( player ) if ( otherPlayer and weapon and weapon > 1 ) then local other, name = exports.players:getFromName ( player, otherPlayer ) if ( other ) then if ( player ~= other ) then local x, y, z = getElementPosition ( player ) if ( getDistanceBetweenPoints3D ( x, y, z, getElementPosition ( other ) ) < 5 ) then giveWeapon ( other, weapon, ammo, true ) takeWeapon ( player, weapon ) outputChatBox ( "Le diste " .. name .. " tu " .. weapon .. ".", player, 0, 255, 0 ) outputChatBox ( getPlayerName ( player ):gsub ( "_", " " ) .. " te dio un " .. weapon .. ".", other, 0, 255, 0 ) else outputChatBox ( "Estas lejos de " .. name .. ".", player, 255, 0, 0 ) end else outputChatBox ( "No puedes darte arma a ti mismo.", player, 255, 0, 0 ) end end else outputChatBox ( "Syntax: /" .. commandName .. " [player] [weapon]", player, 255, 255, 255 ) end end ) Link to comment
Recommended Posts