De esa manera nunca va a funcionar, porque tendrias que haber creando una tabla con todas las armas, y insertar cada ves que alguien la tira y ahi ponerle otra tabla para poner al jugador al tocar un colshape y luego al usar el comando verificas si esta sobre uno.
id = {}
id[1] = 331
id[2] = 333
id[3] = 334
id[4] = 335
id[5] = 336
id[6] = 337
id[7] = 338
id[8] = 339
id[9] = 341
id[22] = 346
id[23] = 347
id[24] = 348
id[25] = 349
id[26] = 350
id[27] = 351
id[28] = 352
id[29] = 353
id[32] = 372
id[30] = 355
id[31] = 356
id[33] = 357
id[34] = 358
id[16] = 342
id[17] = 343
id[18] = 344
id[39] = 363
id[41] = 365
id[42] = 366
id[43] = 367
id[14] = 325
id2 = {}
id2[331] = 1
id2[333] = 2
id2[334] = 3
id2[335] = 4
id2[336] = 5
id2[337] = 6
id2[338] = 7
id2[339] = 8
id2[341] = 9
id2[346] = 22
id2[347] = 23
id2[348] = 24
id2[349] = 25
id2[350] = 26
id2[351] = 27
id2[352] = 28
id2[353] = 29
id2[372] = 32
id2[355] = 30
id2[356] = 31
id2[357] = 33
id2[358] = 34
id2[342] = 16
id2[343] = 17
id2[344] = 18
id2[363] = 39
id2[365] = 41
id2[366] = 42
id2[367] = 43
id2[325] = 14
weapons = { }
onColShape = { }
function getWeaponObjectFromID( id_ )
if id_ then
object = id[id_]
if object then
return object
else
return false
end
else
return false
end
end
function getWeaponObjectFromIDD( idD_ )
if idD_ then
object = id2[idD_]
if object then
return object
else
return false
end
else
return false
end
end
function createWeaponOnFloor ( id, ammo, x, y, z )
local id = getWeaponObjectFromID ( id )
local object = createObject ( id, x, y, z - 0.9 )
local colshape = createColTube ( x, y, z, 0.5, 0.5 )
table.insert (
weapons,
{
object,
colshape
}
)
setElementData ( colshape, "WeaponID", id )
setElementData ( colshape, "WeaponAmmo", ammo )
setElementData ( colshape, "TableID", #weapons )
addEventHandler ( "onColShapeHit", colshape, ColShape )
addEventHandler ( "onColShapeLeave", colshape, ColShape )
end
addEvent ( "createWeaponOnFloor", true )
addEventHandler ( "createWeaponOnFloor", getRootElement(), createWeaponOnFloor )
function tirararma ( source )
local Arma = getPedWeapon ( source )
local Municion = getPedTotalAmmo ( source )
if takeWeapon ( source, Arma ) then
exports.chat:me ( source, "deja algo en el suelo." )
setPedAnimation ( source, "BOMBER", "BOM_Plant", 3000, false )
triggerClientEvent ( source, "getThePosition", source, Arma, Municion, getElementPosition ( source ) )
else
outputChatBox ( "No tienes un arma.", getRootElement(), 255, 255, 255, true )
end
end
addCommandHandler ( "tirararma", tirararma )
function ColShape ( thePlayer )
if ( eventName == "onColShapeHit" ) then
onColShape [ thePlayer ] = source
else
onColShape [ thePlayer ] = nil
end
end
addCommandHandler ( "recogerarma",
function ( thePlayer )
local colshape = onColShape [ thePlayer ]
if ( colshape and isElement ( colshape ) ) then
local detection = isElementWithinColShape ( thePlayer, colshape )
if ( detection ) then
local ID = getElementData ( colshape, "WeaponID" )
local Ammo = getElementData ( colshape, "WeaponAmmo" )
local tableID = getElementData ( colshape, "TableID" )
local IIDD = getWeaponObjectFromIDD ( ID )
exports.chat:me ( thePlayer, "recoge algo del suelo." )
setPedAnimation ( thePlayer, "BOMBER", "BOM_Plant", 3000, false )
giveWeapon ( thePlayer, IIDD, Ammo )
if ( isElement ( weapons [ tableID ] [ 1 ] ) ) then
destroyElement ( weapons [ tableID ] [ 1 ] )
end
if ( isElement ( weapons [ tableID ] [ 2 ] ) ) then
destroyElement ( weapons [ tableID ] [ 2 ] )
end
else
outputChatBox ( "No estás cerca de ningún arma.", thePlayer, 255, 255, 255, true )
end
end
end
)