Jump to content

help me


Recommended Posts

function setVelocity(player, command)
local veh = getPedOccuipedVehicle(player)
if (not veh or veh == nil or getPedOccuipedVehicleSeat(player) ~= 0 ) then return end
if (command=="1") then
setVehicleHandling(veh, "maxVelocity", 320)
outputChatBox("Sport Mod Enabled", veh, 255, 255, 0, true)
elseif (command=="2") then
setVehicleHandling(veh, "maxVelocity", 180)
outputChatBox("Business Mod Enabled", veh, 255, 255, 0, true)
end
end
addCommandHandler("1", setVelocity)
addCommandHandler("2", setVelocity)

 

why it doesn't work

Edited by FiGo
Link to post

when i press 1 it should make the speed of the car to 320 and when i press 2 it should make the speed 180 but nothing work

Link to post
1 minute ago, FiGo said:

when i press 1 it should make the speed of the car to 320 and when i press 2 it should make the speed 180 but nothing work

It works like you write it. Max Velocity it's maximum of velocity,  not acceleration.

For check your vehicle handling you can use something like this:

addCommandHandler("gethandling", function(thePlayer)
		local veh = getPedOccupiedVehicle(thePlayer)
		local handling = getVehicleHandling(veh)
		outputChatBox("maxVelocity is "..handling.maxVelocity, thePlayer, 255, 255, 255, true)
	end)

 

I guess you need "engineAcceleration". Just I never used that stuff.

Link to post

addCommandHandler("gethandling", function(thePlayer)
        local veh = getPedOccupiedVehicle(thePlayer)
        local handling = getVehicleHandling(veh)
        outputChatBox("maxVelocity is "..handling.maxVelocity, thePlayer, 255, 255, 255, true)
end)
-- Bullet -- (250km/h)
function setVelocity(player, command)
local veh = getPedOccuipedVehicle(player)
if (not veh or veh == nil or getPedOccuipedVehicleSeat(player) ~= 0 ) then return end
if (command=="1") then
setVehicleHandling(veh, "maxVelocity", 230)
outputChatBox("Sport Mod Enabled", veh, 255, 255, 0, true)
elseif (command=="2") then
setVehicleHandling(veh, "maxVelocity", 180)
outputChatBox("Business Mod Enabled", veh, 255, 255, 0, true)
end
end
addCommandHandler("1", setVelocity)
addCommandHandler("2", setVelocity)

Link to post
function setVehicleVelocity(player, command)
	local veh = getPedOccupiedVehicle(player)
	if (not veh or veh == nil or getPedOccupiedVehicleSeat(player) ~= 0 ) then return end
	if (command == "sportmod") then
		setVehicleHandling(veh, "maxVelocity", 320)
		outputChatBox("Sport Mod Enabled", player, 255, 255, 0, true)
	elseif (command == "business") then
		setVehicleHandling(veh, "maxVelocity", 180)
		outputChatBox("Business Mod Enabled", player, 255, 255, 0, true)
	end
end

addCommandHandler("sportmod", setVehicleVelocity)
addCommandHandler("business", setVehicleVelocity)

 

addCommandHandler("gethandling", function(thePlayer)
		local veh = getPedOccupiedVehicle(thePlayer)
		local handling = getVehicleHandling(veh)
		outputChatBox("maxVelocity is "..handling.maxVelocity, thePlayer, 255, 255, 255, true)
	end)

 

Edited by Erlkonig
Link to post
6 minutes ago, FiGo said:

can't use please make it and thanks

Try to do it yourself. If something will wrong, you can ask here about your issue. 

Edited by Erlkonig
Link to post
Posted (edited)

function playerPressedKey(button, press)
    if (press) then -- Only output when they press it down
        --outputChatBox("You pressed the "..button.." key!")
    end
end
addEventHandler("onClientKey", root, playerPressedKey)

addEventHandler( "onClientKey", root, function(button,press) 
    if button == "1" then
    triggerServerEvent("sportmod", localPlayer)
    elseif button == "2" then
    triggerServerEvent("business", localPlayer)
        return true
    end
    return false
end )

 

it says [2021-04-13 14:31:03] ERROR: Client (FiGo) triggered serverside event sportmod, but event is not added serverside

anyone please

Edited by FiGo
Link to post

AddEvent on the serverside-script.

addEvent("sportmod", true)
addEvent("business", true)

addEventHandel("sportmod", root, setVehicleVelocity(sportmod))
addEventHandel("business", root, setVehicleVelocity(business))

Of course you should to edit setVehicleVelocity function.

Link to post
function playerPressedKey(button, press)
    if (press) then -- Only output when they press it down
        --outputChatBox("You pressed the "..button.." key!")
    end
end
addEventHandler("onClientKey", root, playerPressedKey)

addEventHandler( "onClientKey", root, function(button,press) 
    if button == "1" then
    triggerServerEvent("sportmod", localPlayer)
    elseif button == "2" then
    triggerServerEvent("business", localPlayer)
        return true
    end
    return false
end )
function setVehicleVelocity(player, command)
	local veh = getPedOccupiedVehicle(player)
	if (not veh or veh == nil or getPedOccupiedVehicleSeat(player) ~= 0 ) then return end
	if (command == "sportmod") then
		setVehicleHandling(veh, "maxVelocity", 320)
		setVehicleHandling(veh, "engineAcceleration", 20)
		setVehicleHandling(veh, "driveType", "awd")
		 setVehicleHandling(veh, "handlingFlags", 0x1008000)
		outputChatBox("Sport Mod Enabled", player, 255, 255, 0, true)
	elseif (command == "business") then
		setVehicleHandling(veh, "maxVelocity", 180)
		setVehicleHandling(veh, "engineAcceleration", 20)
		setVehicleHandling(veh, "driveType", "awd")
		 setVehicleHandling(veh, "handlingFlags", 0x1008000)
		outputChatBox("Business Mod Enabled", player, 255, 255, 0, true)
	end
end
addCommandHandler("sportmod", setVehicleVelocity)
addCommandHandler("business", setVehicleVelocity)
addEvent("sportmod", true)
addEvent("business", true)
addEventHandel("sportmod", root, setVehicleVelocity(sportmod))
addEventHandel("business", root, setVehicleVelocity(business))

server side

 

Link to post
-- YOUR CLIENT:

addEventHandler( "onClientKey", root, function(button,press) 
    if button == "1" then
    	triggerServerEvent("sportmod", localPlayer)
    elseif button == "2" then
    	triggerServerEvent("business", localPlayer)
    end
end )

-- SERVER:
function setVehicleVelocity(player, mode)
	local veh = getPedOccupiedVehicle(player)
	if (not veh) or getPedOccupiedVehicleSeat(player) ~= 0 ) then return end
	if (mode == "sportmod") then
		setVehicleHandling(veh, "maxVelocity", 320)
		setVehicleHandling(veh, "engineAcceleration", 20)
		setVehicleHandling(veh, "driveType", "awd")
		setVehicleHandling(veh, "handlingFlags", 0x1008000)
		outputChatBox("Sport Mod Enabled", player, 255, 255, 0, true)
	elseif (mode == "business") then
		setVehicleHandling(veh, "maxVelocity", 180)
		setVehicleHandling(veh, "engineAcceleration", 20)
		setVehicleHandling(veh, "driveType", "awd")
		setVehicleHandling(veh, "handlingFlags", 0x1008000)
		outputChatBox("Business Mod Enabled", player, 255, 255, 0, true)
	end
end
addCommandHandler("sportmod", setVehicleVelocity)
addCommandHandler("business", setVehicleVelocity)
addEvent("sportmod", true)
addEvent("business", true)
addEventHandel("sportmod", root, setVehicleVelocity("sportmod"))
addEventHandel("business", root, setVehicleVelocity("business"))

I am note sure but try this.

Link to post

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...