Jump to content

SaNoR

Members
  • Posts

    45
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by SaNoR

  1. function engine()
    	local vehicle = getPedOccupiedVehicle(localPlayer)
    	if isElement(vehicle) and getPedOccupiedVehicleSeat(localPlayer) == 0 then
    		local state = getVehicleEngineState(vehicle)
    		if not state then
    			startTimer = 
    			setTimer(
    				function()
    					if isElement(vehicle) and getPedOccupiedVehicleSeat(localPlayer) == 0 then
    						setVehicleEngineState(vehicle, true)
    					end
    				end
    			, 2000, 1)
    		else
    			setVehicleEngineState(vehicle, false)
    		end
    	end
    end
    
    function resetEngine()
    	if isTimer(startTimer) then killTimer(startTimer) end
    end
    
    bindKey("2", "down", engine)
    bindKey("2", "up", resetEngine)

     

  2. Server side:

    addCommandHandler("vcp",
    function(player)
    	local vehicle = getPedOccupiedVehicle(player)
    	if isElement(vehicle) then
    		triggerClientEvent(root, "syncVehicleComponents", vehicle)
    	end
    end)

    Client side:

    addEvent("syncVehicleComponents", true)
    addEventHandler("syncVehicleComponents", root,
    function()
    	if isElement(source) and getElementType(source) == "vehicle" then	    
                local x, y, z = getVehicleComponentPosition(source, "wheel_rf_dummy")
                setVehicleComponentPosition(source, "wheel_rf_dummy", x+0.15, y, z)
    
                local x, y, z = getVehicleComponentPosition(source, "wheel_rb_dummy")
                setVehicleComponentPosition(source, "wheel_rb_dummy", x+0.15, y, z)
    
                local x, y, z = getVehicleComponentPosition(source, "wheel_lf_dummy")
                setVehicleComponentPosition(source, "wheel_lf_dummy", x-0.15, y, z)
    
                local x, y, z = getVehicleComponentPosition(source, "wheel_lb_dummy")
                setVehicleComponentPosition(source, "wheel_lb_dummy", x-0.15, y, z)
    	end
    end)

     

  3. Server:

    function getShops()
    	for k, v in ipairs(shops) do
    		triggerClientEvent("getshopsClient", root, shops[k][4])
    	end
    end
    addEvent("getshops", true)
    addEventHandler("getshops", getRootElement(), getShops)

    Client:

    local cost = 0
    addEvent("getshopsClient", true)
    addEventHandler("getshopsClient", root,
    function(value)
    	cost = value
    end)
    
    ...
    dxDrawText("#ffffffCost: #6ad622"..cost.. " $" ,x/2+ 10,  y/2+index*58+18.5, panelSize[1], 25*2.3, tocolor(66, 244, 220, 255), 0.8, font2, "left", "top", false, false, false, true)
    ...

     

  4. function func()
    	local text = ""
    	for index, player in ipairs(getElementsByType("player")) do
    		if getElementData(player,"Money") == 10000 then
    			local len = string.len(text)
    			local name = getPlayerName(player)
    			if len == 0 then
    				text = name
    			elseif len > 0 and len <= 256 then
    				if (len + string.len(tostring(", "..name))) > 256 then
    					outputChatBox(text, player)
    					text = name
    				else
    					text = text..", "..name
    				end
    			end
    		end
    	end
    	if string.len(text) > 0 then
    		outputChatBox(text, player)		
    	end
    end

     

    • Thanks 1
  5. tbl = {"function", "local", "if", "elseif", "else", "then", "end", "print", "math.random", "math.max"}
    
    local text = 
    [[function test()
        local x = 2
        if x == 2 then
            print(x)
            math.random(1, 10)
            math.max(2, 9, 1, 4)
        end
    end]]
    
    addEventHandler("onClientRender", root,
    function()
    	local color = "#FFFFFF"
    	for i,v in ipairs(tbl) do
    		if text:find(" "..v) or text:find(v.." ") then
    			if i > 0 and i <= 7 then
    				color = "#0000FF"
    			elseif i > 7 then
    				color = "#A6E22D"
    			end
    			text = text:gsub(v, color..v.."#FFFFFF")
    		end
    	end
    	dxDrawText(text, 15, sh/3,_,_,_, 2, "default-bold", "left", "top", false, false, false, true)
    end)
    Spoiler

    dW368QS.png

     

    • Haha 1
    • Confused 1
  6. addCommandHandler("createvehicle",
    function(player, cmd, id, numberplate)
    	if isElement(player) and id then
    		local matrix = getElementMatrix(player)
    		local x = 3 * matrix[1][1] + 0 * matrix[2][1] - 0 * matrix[3][1] + matrix[4][1]
    		local y = 3 * matrix[1][2] + 0 * matrix[2][2] - 0 * matrix[3][2] + matrix[4][2]
    		local z = 3 * matrix[1][3] + 0 * matrix[2][3] - 0 * matrix[3][3] + matrix[4][3]
    		local rX, rY, rZ = getElementRotation(player)
    
    		local vehicle = createVehicle(id, x, y, z, rX, rY, rZ, numberplate)
    
    		if isElement(vehicle) then
    			outputChatBox("You have created a "..getVehicleNameFromModel(id), player, 0, 255, 0)
    		else
    			outputChatBox("Wrong id", player, 255, 0, 0)
    		end
    	else
    		outputChatBox("/createvehicle [id] [numberplate] (createvehicle 415 X001UY)", player, 255, 0, 0)
    	end
    end)

     

×
×
  • Create New...