SrGustavo_BRR Posted January 31, 2021 Posted January 31, 2021 markerPegar = createMarker(1221.0225830078, -1388.1735839844, 13.442749977112 -1, "cylinder", 1.5, 0,255,0,100) markerDestruir = createMarker(1223.1115722656, -1388.1994628906, 13.435565948486 -1, "cylinder", 1.5, 255,0,0,100) veh = {} function pegarVeiculo (source) for _, v in ipairs (getElementsByType("player")) do if getPedOccupiedVehicle(v) then return end if veh[source] and isElement(veh[source]) then destroyElement(veh[source]) end veh[source] = createVehicle(490, 1220.6763916016, -1398.3157958984, 13.185880661011) warpPedIntoVehicle(source, veh[source]) end end addEventHandler("onMarkerHit", markerPegar, pegarVeiculo) function dest (source) if veh[source] and isElement(veh[source]) then destroyElement (veh[source]) local name = getPlayerName(source) end end addEventHandler("onMarkerHit", markerDestruir, dest) function DestroyVeiculo () destroyElement (veh[source]) end addEventHandler ("onPlayerQuit", root, DestroyVeiculo)
Discord Moderators Tut Posted January 31, 2021 Discord Moderators Posted January 31, 2021 Hi @SrGustavo_BRR Thread's been moved into the Portuguese programming section. The section that you posted to is an English section.
noonbr Posted January 31, 2021 Posted January 31, 2021 function pegarVeiculo(hitElement) if getElementType(hitElement) == "player" then local vehicle = getPedOccupiedVehicle(hitElement) if not vehicle then local account = getPlayerAccount(hitElement) local accountName = getAccountName(account) if isObjectInACLGroup("user."..accountName, aclGetGroup("PF")) then if isElement(veh[hitElement]) then destroyElement(veh[hitElement]) end veh[hitElement] = createVehicle(490, 1220.6763916016, -1398.3157958984, 13.185880661011) warpPedIntoVehicle(hitElement, veh[hitElement]) else outputChatBox("Você não é membro da PF.", hitElement, 255,0,0) end end end end Você redefiniu source no seu script, naturalmente em onMarkerHit, source é o próprio elemento marker, e o primeiro parâmetro da função anexada ao evento "onMarkerHit" é o player que de fato entra no marker. Nem sempre source é o player.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now