Jump to content

AJUDA: marker para destruir veiculo


Recommended Posts

esse é o script, a primeira parte, do spawn do veiculo funciona, a segunda ja não

local Marker1 = createMarker (119.86518859863, -1832.1979980469, 5, "cylinder", 1.25, 0, 250, 0, 50)
local Marker2 = createMarker (127.06451416016, -1848.4306640625, 5, "cylinder", 3, 0, 250, 0, 50)

veh = {}

function Vehicle1 ( hitPlayer, getPlayerVehicle )
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then
        if isElement(Veh1) then
            destroyElement(Veh1)
        end
        local Veh1 = createVehicle(525, 132.57461547852, -1815.671875, 5.795524597168, 0, 0, 270)
        warpPedIntoVehicle ( hitPlayer, Veh1 )
    else
        outputChatBox ("Você não é um Mecanico", hitPlayer, 0, 0, 0)
    end
end
addEventHandler( "onMarkerHit", Marker1, Vehicle1)

function Vehicle2 (hitPlayer)
    if isElementWithinMarker(player, Marker2) then
        player = nil
        if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then
            if isPedInVehicle(veh[player]) then
                destroyElement(vehicle)
            else
                outputChatBox("Você não esta em um veículo", hitPlayer, 0, 0, 0)
            end
        end
    end
end

addEventHandler("onMarkerHit", Marker2, Vehicle2)

 

no console aparece isto 

WARNING: Oficina-Mecanica\spawn.Lua:20: Bad argument @ 'isElementWithinMarker' [Expected element at argument 1, got nil]

Link to comment
  • Moderators

Você não vai precisar de isElementWithinMarker no evento "onMarkerHit". Use hitPlayer em vez de player e veh[hitPlayer] em vez de vehicle, também verifique se o hitPlayer é um elemento player com getElementType.

Além disso, o vehicle não está sendo adicionado na table 'veh' na função Vehicle1.

  • Thanks 1
Link to comment

continua n funcionando '-'

local Marker1 = createMarker (119.86518859863, -1832.1979980469, 5, "cylinder", 1.25, 0, 250, 0, 50)
local Marker2 = createMarker (127.06451416016, -1848.4306640625, 5, "cylinder", 3, 0, 250, 0, 50)

veh = {}

function Vehicle1 ( hitPlayer, getPlayerVehicle )
	if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then
		if isElement(Veh1) then
			destroyElement(Veh1)
		end
		local Veh1 = createVehicle(525, 132.57461547852, -1815.671875, 5.795524597168, 0, 0, 270)
		warpPedIntoVehicle ( hitPlayer, Veh1 )
	else
		outputChatBox ("Você não é um Mecanico", hitPlayer, 0, 0, 0)
	end
end
addEventHandler( "onMarkerHit", Marker1, Vehicle1)

function Vehicle2 ( hitPlayer )
	if getElementType( hitPlayer ) == "player" then
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then
			if isPedInVehicle( veh[hitPlayer] ) then
				destroyElement( veh[hitPlayer] )
				veh[hitPlayer] = nil
			else
				outputChatBox("Você não esta em um veículo", hitPlayer, 0, 0, 0)
			end
		end
	end
end

addEventHandler("onMarkerHit", Marker2, Vehicle2)

[13:41:59] WARNING: Oficina-Mecanica\spawn.Lua:23: Bad argument @ 'destroyElement' [Expected element at argument 1, got nil]

 

Edited by EW1611
Link to comment

continua não funcionando, 

local Marker1 = createMarker (119.86518859863, -1832.1979980469, 5, "cylinder", 1.25, 0, 250, 0, 50)
local Marker2 = createMarker (127.06451416016, -1848.4306640625, 5, "cylinder", 3, 0, 250, 0, 50)

veh = {}

function Vehicle1 ( hitPlayer, getPlayerVehicle )
	if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then
		if isElement(Veh1) then
			destroyElement(Veh1)
		end
		local Veh1 = createVehicle(525, 132.57461547852, -1815.671875, 5.795524597168, 0, 0, 270)
		warpPedIntoVehicle ( hitPlayer, Veh1 )
	else
		outputChatBox ("Você não é um Mecanico", hitPlayer, 0, 0, 0)
	end
end
addEventHandler( "onMarkerHit", Marker1, Vehicle1)

function Vehicle2 (hitPlayer)
	if getElementType(hitPlayer) == "player" then
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then
			if getPedOccupiedVehicle(hitPlayer) then
				destroyElement(veh[hitPlayer])
				veh[hitPlayer] = nil
			else
				outputChatBox("Você não esta em um veículo", hitPlayer, 0, 0, 0)
			end
		end
	end
end

addEventHandler("onMarkerHit", Marker2, Vehicle2)

 

Edited by EW1611
Link to comment
  • Moderators

Assim:

function Vehicle2 (hitPlayer)
	if getElementType(hitPlayer) == "player" then
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(hitPlayer)), aclGetGroup("Mecanico")) then
			local vehicle = getPedOccupiedVehicle(hitPlayer)
			if vehicle and veh[hitPlayer] and vehicle == veh[hitPlayer] then
				destroyElement(veh[hitPlayer])
				veh[hitPlayer] = nil
			else
				outputChatBox("Você não esta em um veículo", hitPlayer, 0, 0, 0)
			end
		end
	end
end

addEventHandler("onMarkerHit", Marker2, Vehicle2)

Na função Vehicle1 você deve trocar Veh1 por veh[hitPlayer].

  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...