Hi there,
How detach this cellphone?
Phone can be attached and removed by DeleteObject(phoneProp)
nicely, but if i restart script with phone in hands this bug happening, how to remove it?
Attach:
phoneProp = CreateObject(phoneModel, 1.0, 1.0, 1.0, 1, 1, 0)
AttachEntityToEntity(phoneProp, ped, bone, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0, 0, 2, 1)
I found function GetEntityAttachedTo
but it return zero
DetachEntity(phoneProp, 1, true)
?
After script restart all variables are nil, i cant detach and delete this way, need to get all attached props to ped and delete they, but i dont know how.
1 Like
Did you found solution on this one?
Is there any command to create to reset player , (Detach All Entity)
1 Like
You can detach using SetPlayerModel, this will change the model of the player and detach all the objects attached.
1 Like
i think this works
RegisterCommand('detatch', function(source, args)
obj = args[1]
local position = GetEntityCoords(GetPlayerPed(PlayerId()), false)
local object = GetClosestObjectOfType(position.x, position.y, position.z, 15.0, GetHashKey(obj), false, false, false)
if object ~= 0 then
DeleteObject(object)
end
end)
RegisterCommand('detatchphone', function(source)
local position = GetEntityCoords(GetPlayerPed(PlayerId()), false)
local object = GetClosestObjectOfType(position.x, position.y, position.z, 15.0, GetHashKey("YOUR PHONE MODEL HERE e.g. prop_npc_phone_02"), false, false, false)
if object ~= 0 then
DeleteObject(object)
end
end)
this only drops the prop dont delete
Well, You can’t delete the prop once you restart your resource
You can of course detach your prop by using SetPlayerModel for e.g
but to delete the prop what you can do is to use
SetEntityAsNoLongerNeeded(object)
when creating your object, like this once the game will no need it anymore it will delete the prop automaticaly.