Jump to content
  • 0

Train speed problem


acp___(PL)

Question

I have a problem in the game with the train, I would like to use train on some maps to collect check points which are on the tracks, but when I am useing the train it is going something strange:

first of all, sometimes when I ride on some straight parts of track's, train begins to accelerate without pressing acceleration button, to the huge speed and I must brake to not fall out of the track's. This happens only on some straight parts of track's, but always in the same place's, and I don't know why.

second, it is similar problem, sometimes when train is in the track turn I have problem with accelerate, train accelerate but very very slowly.

Problem is when I use any type of train or tram.

I don't know is it a known problem? Maybe someone have already this problem and knows what's going on.

Link to comment

5 answers to this question

Recommended Posts

  • 0

I try to somehow solve the problem of the maximum speed

I tested the first method but unfortunately it does not work and I do not know why

local gMe = getLocalPlayer()
local g_rot = getRootElement()
 
function trainLimits()
addEventHandler ("onClientRender", g_rot, uruchomLimity)
end
function uruchomLimity()
local vehicle = getPedOccupiedVehicle(gMe)
if vehicle and getVehicleType(vehicle) == "Train" then
	local actualspeed = getTrainSpeed(vehicle)
	if actualspeed >= 160*161 then
		setTrainSpeed(vehicle, 159*161)
	elseif actualspeed <= -160*161 then
		setTrainSpeed(vehicle, -159*161)
	end 
end
end
addEvent ( "onClientMapStarting", true )
addEventHandler ( "onClientMapStarting", g_rot, trainLimits)
addEventHandler ( "onPlayerJoin", g_rot, trainLimits)

the other was not checked, but if the while loop is correct this should give an effect

local gMe = getLocalPlayer()
local g_rot = getRootElement()
 
function uruchomLimity()
local vehicle = getPedOccupiedVehicle(gMe)
if vehicle then
	local speedx, speedy, speedz = getElementVelocity(vehicle)
	local actualspeed = math.sqrt(speedx^2 + speedy^2 + speedz^2)*161
	if actualspeed > 160 then
		local i_vmax = 1
		local newactualspeed = actualspeed
		local newSpeedx, newSpeedy, newSpeedz = speedx, speedy, speedz
		while newactualspeed > 160 do
			newSpeedx = speedx - (speedx*i_vmax/10)
			newSpeedy = speedy - (speedy*i_vmax/10)
			newSpeedz = speedz - (speedz*i_vmax/10)
			newactualspeed = math.sqrt(newSpeedx^2 + newSpeedy^2 + newSpeedz^2)*161
			i_vmax = i_vmax + 1
		end
		setElementVelocity(vehicle, newSpeedx, newSpeedy, newSpeedz)
	end
end
end
function trainLimits()
setTimer(uruchomLimity, 100, 0)
end
addEvent ( "onClientMapStarting", true )
addEventHandler ( "onClientMapStarting", g_rot, trainLimits)
addEventHandler ( "onPlayerJoin", g_rot, trainLimits)

Link to comment
  • 0

Stop coding in Polish - it's very annoying for people who are trying to read your code, and coding in a 50-50 Polish-English blend doesn't really serve any purpose.

That being said, any "countermeasure" (cough.. hack) you can put in place here will most likely be ugly and ineffective. Better wait for the devs to actually solve the underlying problem.

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