Jump to content

Captain Cody

Members
  • Posts

    2,753
  • Joined

  • Last visited

  • Days Won

    18

Posts posted by Captain Cody

  1. setElementRotation(theVeh,"steer"rotX,rotY,rotX*10)

    Well that's completely wrong, and even if it was the right function; you missed a comma after "steer"

    setVehicleComponentRotation(theVeh,'steer',rotX,rotY,rotX*10)

     

  2. I'd recommend using table based functions for organization.

    functions = {}
    functions['RoomA'] = {}
    functions['RoomB'] = {}
    
    functions['RoomA'].test = function ()
      
    end
    
    
    functions['RoomB'].test = function ()
      
    end
    
    functions['RoomA'].test()
    functions['RoomB'].test()

     

    • Like 1
  3. https://wiki.multitheftauto.com/wiki/EngineLoadIFP

    https://wiki.multitheftauto.com/wiki/EngineReplaceAnimation

    swordAnimations = {
    'sword_1',
    'sword_2',
    'sword_3',
    'sword_4',
    'sword_block',
    'sword_hit_1',
    'sword_hit_2',
    'sword_hit_3',
    'sword_idle',
    'sword_part'
    }
    
    
    local IFP = engineLoadIFP( "sword.ifp", 'sword.custom' )
    
    if IFP then
    	for i,v in pairs(swordAnimations) do
    		engineReplaceAnimation( localPlayer, "sword", v, 'sword.custom', v )
    	end
    else
    	print('Failed to load - ','Sword.ipf')
    end

    Not tested, but should work, ensure to define it in meta properly and run that client side for everyone.

  4. local playerHitCorona = {}
    local coronaElement = {}
    
    coronaElement[1] = createMarker(3955.6198730469, -1604.9947509766, 56.082000732422, "corona", 15, 0, 0, 255)
    coronaElement[2] = createMarker(3222.6970214844, -1473.5163574219, -1.5256999731064, "corona", 40, 0, 0, 255)
    coronaElement[3] = createMarker(3465.4184570313, -505.55020141602, 6.6930999755859, "corona", 15, 0, 0, 255)
    coronaElement[4] = createMarker(3788.0246582031, -807.74267578125, 110.54779815674, "corona", 10, 0, 0, 255) -- corona before hunter pickup
    -- and so on
    
    --[[ addEventHandler( "onClientMarkerHit", root, MarkerHit ) ]]--// Defined as markerHit and before the function move to line 31
    function markerHit (element)--function MarketHit (player) // Was defined as MarketHit, switched to markerHit()
    	if element == localPlayer then --// Just switched player to element because who knows what'll go through
    		if source == coronaElement[1] then -- you check that the player hit the first corona
    			playerHitCorona[1] = true -- set it to true, that means that the player hit the corona
    		elseif source == coronaElement[2] then -- same as above
        		playerHitCorona[2] = true 
        	elseif source == coronaElement[3] then -- on this corona, you check that the player hit all previous coronas
        		playerHitCorona[3] = true --playerHitCorona[1] = true playerHitCorona[2] = true // Set to playerHitCorona[3], used 1 and 2 before
        	elseif source == coronaElement[4] then
        		if playerHitCorona[1] and playerHitCorona[2] and playerHitCorona[3] then -- Correcto
        			-- player hit all coronas, do nothing
        		else
    				local vehicle = getPedOccupiedVehicle(localPlayer) 
    				outputChatBox("#ADD8E6AW#FFFFFFOL: You're not worthy")
    				blowVehicle(vehicle)
    			end
    		end
    	end
    end
    --) // ) should not be there because this is in a full function
    addEventHandler( "onClientMarkerHit", root, markerHit )--< addEventHandler should be moved here

    That goes through and explains what exactly was wrong the code, I'd say mostly just typos and misunderstandings how lua works.

    coronaInformation = {}
    coronaInformation[1] = {3955.6198730469, -1604.9947509766, 56.082000732422, "corona", 15, 0, 0, 255}
    coronaInformation[2] = {3222.6970214844, -1473.5163574219, -1.5256999731064, "corona", 40, 0, 0, 255}
    coronaInformation[3] = {3465.4184570313, -505.55020141602, 6.6930999755859, "corona", 15, 0, 0, 255}
    coronaInformation[4] = {3788.0246582031, -807.74267578125, 110.54779815674, "corona", 10, 0, 0, 255}
    
    function prep()
    	if not running then
    		running = true
    		if coronaElement then
    			for i,v in pairs(coronaElement) do
    				if isElement(v) then
    					destroyElement(v)
    				end
    			end
    		end
    		playerHitCorona = {}
    		coronaElement = {}
    		for i,v in pairs(coronaInformation) do
    			coronaElement[i] = createMarker(unpack(v))
    		end
    		addEventHandler( "onClientMarkerHit", root, markerHit )
    	end
    end
    
    function verifyScore(count)
    	for i=1,(count or #coronaElement) do
    		if not playerHitCorona[i] then
    			return false -- # If a marker was not hit then return false
    		end
    	end
    	return true --# If none of the above passes, return true
    end
    
    function markerHit (player)
           if player == localPlayer then
    		for i,v in pairs(coronaElement) do
    			if (source == v) then
    				if (i == 1) or verifyScore(i-1) then --# Checks if marker is 1, and if not checks if you scored the previous ones.
    					playerHitCorona[i] = true
    					destroyElement(v) --# Removes the marker when you hit it
    					if (i == #coronaElement) then  -- # If this is the last one, try to score
    						doScore()
    					end
    				end
    			end
    		end
    	end
    end
    
    function doScore()
    	if verifyScore() then -- # If all markers have been hit then continue
    		-- Score
    	else	-- If a marker was not hit then blow em to peices
    		local veh = getPedOccupiedVehicle(localPlayer)
    		outputChatBox("#ADD8E6AW#FFFFFFOL: You're not worthy")
    		blowVehicle(veh)
    	end
    	removeEventHandler( "onClientMarkerHit", root, markerHit )
    	running = nil
    end
    prep()

    Here's 'better' way of doing it that'll allow you to place more markers in the list and still have the function work 100% (Untested)

×
×
  • Create New...