Jump to content

hrtht

Members
  • Posts

    21
  • Joined

  • Last visited

Posts posted by hrtht

  1. function repairVehicle ( thePlayer, commandName)
        if ( isPedInVehicle ( thePlayer ) ) then
            local theVehicle = getPedOccupiedVehicle ( thePlayer)
            local succes = fixVehicle ( theVehicle )
            if ( succes ) then
                outputChatBox (" 1 ", thePlayer )
            outputChatBox ( "0", thePlayer )
        end
    end
    end
    addCommandHandler ( "rv", repairVehicle)

     

    Its serverside

  2. 3 hours ago, Patrick said:
    
    function ghostmode_on()
    	for i,v in pairs(getElementsByType("player")) do --LOOP through all players
    		setElementCollidableWith(v, localPlayer, false) -- Set the collison off with the other vehicles.
    	end
    	outputChatBox("You are now a Ghost")
    end
    addCommandHandler("ghostmode", ghostmode_on) -- Add the /ghostmode Command.
    

    Replace vehicle elements with players.

    How to add a output for saying that you're no longer Ghost?

  3. function ghostmode_on()
    	local playerVehicle = getPedOccupiedVehicle(localPlayer) -- Get the players vehicle
    	if(playerVehicle) then -- Check the return value.
    		for i,v in pairs(getElementsByType("vehicle")) do --LOOP through all vehicles
    			setElementCollidableWith(v, playerVehicle, false) -- Set the collison off with the other vehicles.
    		end
    		outputChatBox("You are now a Ghost")
    	end
    end
    addCommandHandler("ghostmode", ghostmode_on) -- Add the /ghostmode Command.

     

    What I need to change to get it working with players? I'm new help me man

  4. 3 hours ago, Patrick said:

    I think the only way if you hide the chat, with showChat
    Or cancel the keypress event:

    
    addEventHandler("onClientKey", root, function(key, state)
        if key == "t" and state then
            cancelEvent()
        end
    end)
    

     

    thanks man !

  5. 3 hours ago, iDannz [Breno] said:

    All you should do is get new look at coordinates -> send to server -> sync to others clients
    but remember; dont try to destroy your server's network :D
     

    
    --serverside
    addEvent('syncLookAt', true)
    addEventHandler('syncLookAt', root, function(x,y,z)
    	triggerLatentClientEvent("setLookAt", 30000, false, client, x,y,z)
    	-- triggerClientEvent("setLookAt", client, x,y,z)
    end)
    
    --clientside
    local screenW, screenH = guiGetScreenSize()
    
    setTimer(function()
        local x,y,z = getWorldFromScreenPosition(screenW*0.5, screenH*0.5, 10)
        triggerLatentServerEvent("syncLookAt", 30000, false, localPlayer, x,y,z)
    --    triggerServerEvent("syncLookAt", localPlayer, x,y,z)
    end, 200, 0)
    
    addEvent('setLookAt', true)
    addEventHandler('setLookAt', root, function(x,y,z)
        setPedLookAt(source, x,y,z)
    end)
    

     

    Still doesn't work, the head is stuck to the right, I want it for all not just local player man

  6. 3 hours ago, MrTasty said:

    You're setting everyone's look-at coordinates to the centre of the localPlayer's screen, not the respective player's screen. Also, last time I used setPedLookAt, it didn't work for remote players correctly. Also, read the Wiki notices (specifically the first one - don't run this on onClientRender):

    Note: Avoid calling setPedLookAt every frame as this can cause bugs like being invincible to burning.
    Note: For remote players, you have to use setPedAimTarget before setPedLookAt.

    I started days ago on this.. if you can send me the code it would be great man

  7. 3 hours ago, MrTasty said:

    Share the code that you need help with, or at least tell us which script it is if it's from MTASA community resources website.

    addEventHandler("onClientRender", getRootElement(), function()

    for k,player in ipairs(getElementsByType("player")) do
    if getElementHealth(player) >= 1 then
    local width, height = guiGetScreenSize ()
    local lx, ly, lz = getWorldFromScreenPosition ( width/2, height/2, 10 )
    setPedLookAt(player, lx, ly, lz)
    end 
    end
       
    end)

×
×
  • Create New...