O.G Kash Posted May 15, 2019 Posted May 15, 2019 Estou fazendo um sistema que ao passar pelo marker e apertar "e", spawnaria um veiculo, porem esta spawnando 2 veiculos (quando aperta e quando solta a tecla), mas queria que spawnasse apenas quando apertasse. O código esta assim: local g1 = createMarker (1517.796, -694.59, 92.00, "cylinder", 3.0, 184,0,0, 150) addEventHandler ("onClientMarkerHit", g1, function() addEventHandler ("onClientKey", root, function (button, press) if isElementWithinMarker (localPlayer, g1) then if button == "e" then createVehicle ( 402, 1517.172, -690.4, 94.75, 0, 0, 100) end end end ) end )
Jonas^ Posted May 15, 2019 Posted May 15, 2019 local g1 = createMarker (1517.796, -694.59, 92.00, "cylinder", 3.0, 184,0,0, 150) addEventHandler ("onClientKey", root, function (btn, press) if isElementWithinMarker (localPlayer, g1) and press then if btn == "e" then createVehicle (402, 1517.172, -690.4, 94.75, 0, 0, 100) end end end) pressOrRelease: This refers to whether they were pressing or releasing the key, true when pressing, false when releasing. É necessário verificar se a tecla esta pressionada ou solta.
O.G Kash Posted May 15, 2019 Author Posted May 15, 2019 3 minutes ago, Jonas^ said: local g1 = createMarker (1517.796, -694.59, 92.00, "cylinder", 3.0, 184,0,0, 150) addEventHandler ("onClientKey", root, function (btn, press) if isElementWithinMarker (localPlayer, g1) and press then if btn == "e" then createVehicle (402, 1517.172, -690.4, 94.75, 0, 0, 100) end end end) pressOrRelease: This refers to whether they were pressing or releasing the key, true when pressing, false when releasing. É necessário verificar se a tecla esta pressionada ou solta. Obrigado! Porem ele esta spawnando o veiculo mas não estou conseguindo entrar. É bug do meu mta ou do codigo?
Other Languages Moderators Lord Henry Posted May 15, 2019 Other Languages Moderators Posted May 15, 2019 O script é client-side?
Jonas^ Posted May 15, 2019 Posted May 15, 2019 2 minutes ago, Lord Henry said: O script é client-side? Sim, onClientKey é somente client-side. -- @PlaKS Acho que seja bug no seu MTA.
O.G Kash Posted May 15, 2019 Author Posted May 15, 2019 1 minute ago, Lord Henry said: O script é client-side? sim Just now, Jonas^ said: Sim, onClientKey é somente client-side. -- @PlaKS Acho que seja bug no seu MTA. ok, obrigado
Other Languages Moderators Lord Henry Posted May 15, 2019 Other Languages Moderators Posted May 15, 2019 (edited) Veículos criados client-side servem somente para visualização. Não são utilizáveis pelos jogadores. Quote Note: Vehicles (and other elements) created client-side are only seen by the client that created them, aren't synced and players cannot enter them. They are essentially for display only. Edited May 15, 2019 by Lord Henry 1
Jonas^ Posted May 15, 2019 Posted May 15, 2019 Putz é verdade asuhasuaashuas @Lord Henry nunca criei veículo client-side nem sabia que era apenas ' enfeite '.
Other Languages Moderators Lord Henry Posted May 15, 2019 Other Languages Moderators Posted May 15, 2019 Só usar um triggerServerEvent na hora de criar o veículo. 1
#DeltaSCR Posted May 15, 2019 Posted May 15, 2019 @PlaKS você pode fazer esse código no server-side tbm, usando bindKey 1
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