-
Posts
122 -
Joined
-
Last visited
Everything posted by acp___(PL)
-
This script works, but often results in restarting the server or crash the game Simply download and launch the server, I have a long fight but I do not know if the issue of error in the code, and how much the MTA On the main page, I saw that such a snake from the trailer - which is why he writes here, I can can fix this my script
-
you were write that the table can be sent in triggerClientEvent and server-side I do not have the error but the client side does not work what I'm doing wrong, how to draw nick and points from this table the entire table client-side is empty? or bad draw from the table information? server side: function pointsMM_endRace (rank_mm) local allPlayersPointsMM = executeSQLQuery( "SELECT player_nick, player_points FROM stats_mm WHERE player_points > 0" ) triggerClientEvent ( "onPlayerReSortMeTableRankMM", g_Root, allPlayersPointsMM) end addEvent('onPlayerFinish') addEventHandler('onPlayerFinish', g_Root , pointsMM_endRace) addEvent('onPlayerFinish') addEventHandler('onPlayerFinish', g_Root , pointsMM_endRace) client side: local listaTop10name = {} local listaTop10points = {} function playerReSortMeTableRankMM(the_allPlayersPointsMM) for i, k in ipairs(listaTop10points) do listaTop10points[i] = nil end local playersCountedInMM = 0 for i, playerdata in ipairs(the_allPlayersPointsMM) do listaTop10name = playerdata[player_nick] listaTop10points = playerdata[player_points] playersCountedInMM = i outputDebugString("function playerReSortMeTableRankMM(the_allPlayersPointsMM) - nick: " ..playerdata[player_nick].. "/points: " ..playerdata[player_points], 3, 255, 0, 255) end algorytmSortowania(playersCountedInMM) end addEvent( "onPlayerReSortMeTableRankMM", true ) addEventHandler( "onPlayerReSortMeTableRankMM", g_Root, playerReSortMeTableRankMM ) error on the client side:
-
1) it must work: local allPlayersPointsMM = executeSQLQuery( "SELECT player_nick, player_points FROM stats_mm WHERE player_points > 0" ) triggerClientEvent ( "onPlayerReSortMeTableRankMM", g_Root, allPlayersPointsMM) 2) client-side: local tablePlayersInMM = {} for i, playerdata in ipairs(allPlayersPointsMM) do tablePlayersInMM[i] = {} tablePlayersInMM[i][1] = playerdata[player_nick] tablePlayersInMM[i][2] = playerdata[player_points] outputDebugString("function pointsMM_endRace (rank_mm) - nick: " ..playerdata[player_nick].. "/points: " ..playerdata[player_points], 3, 255, 0, 255) end
-
my table: how it will look like Table: allPlayersPointsMM local allPlayersPointsMM = executeSQLQuery( "SELECT player_nick, player_points FROM stats_mm WHERE player_points > 0" ) to do so as described above post does I need to use this: local allPlayersPointsMMpoints = executeSQLQuery( "SELECT player_nick FROM stats_mm WHERE player_points > 0" ) local allPlayersPointsMMnick = executeSQLQuery( "SELECT player_points FROM stats_mm WHERE player_points > 0" )
-
is it the correct way to export table?? script still not working, but did not notify me of errors ... server side: function pointsMM_endRace (rank_mm) local allPlayersPointsMM = executeSQLQuery( "SELECT player_nick, player_points FROM stats_mm WHERE player_points > 0" ) local countPlayersInMM = 0 local tablePlayersInMMnick = {} local tablePlayersInMMpoints = {} for i, playerdata in ipairs(allPlayersPointsMM) do tablePlayersInMMnick[i] = playerdata[player_nick] tablePlayersInMMpoints[i] = playerdata[player_points] countPlayersInMM = countPlayersInMM + 1 end setElementData ( source, "Points MM", playerPointsMMresult ) triggerClientEvent ( source, "onPlayerShowIlePunktowZaWyscigInMM", g_Root, playerPointsInMM, placesInMM ) triggerClientEvent ( "onPlayerReSortMeTableRankMM", g_Root, countPlayersInMM, unpack(tablePlayersInMMnick), unpack(tablePlayersInMMpoints)) triggerClientEvent ( source, "onPlayerShowMeTableRankMM", g_Root, 30 ) outputDebugString("IV MM: " ..namePlayerMM.. " has finisched " ..placesInMM.. "/" ..playerPointsInMM.. "/" ..playerPointsMMresult, 3, 0, 0, 255) end end client side: function playerReSortMeTableRankMM (theCountPlayersInMM, ...) for i, k in ipairs(listaTop10points) do listaTop10points[i] = nil end local arg = {...} local j = 1 for i,v in ipairs(arg) do if i <= theCountPlayersInMM then listaTop10name[i] = arg[i] else listaTop10points[j] = arg[i] j = j + 1 end end algorytmSortowania(theCountPlayersInMM) end addEvent( "onPlayerReSortMeTableRankMM", true ) addEventHandler( "onPlayerReSortMeTableRankMM", g_Root, playerReSortMeTableRankMM )
-
table to?? executeSQLQuery( "SELECT player_nick, player_points FROM stats_mm WHERE player_points > 0" ) 1. wants all the rows in which the players have some points 2. I am interested in the column: player_nick, player_points 3. table called: stats_mm server side line 13 - triggerClientEvent ( "onPlayerReSortMeTableRankMM", g_Root, countPlayersInMM, tablePlayersInMM ) function pointsMM_endRace (rank_mm) local allPlayersPointsMM = executeSQLQuery( "SELECT player_nick, player_points FROM stats_mm WHERE player_points > 0" ) local countPlayersInMM = 0 local tablePlayersInMM = {} for i, playerdata in ipairs(allPlayersPointsMM) do tablePlayersInMM[i] = {} tablePlayersInMM[i][1] = playerdata[player_nick] tablePlayersInMM[i][2] = playerdata[player_points] countPlayersInMM = countPlayersInMM + 1 end setElementData ( source, "Points MM", playerPointsMMresult ) triggerClientEvent ( source, "onPlayerShowIlePunktowZaWyscigInMM", g_Root, playerPointsInMM, placesInMM ) triggerClientEvent ( "onPlayerReSortMeTableRankMM", g_Root, countPlayersInMM, tablePlayersInMM ) triggerClientEvent ( source, "onPlayerShowMeTableRankMM", g_Root, 30 ) outputDebugString("IV MM: " ..namePlayerMM.. " has finisched " ..placesInMM.. "/" ..playerPointsInMM.. "/" ..playerPointsMMresult, 3, 0, 0, 255) else end end client side both the value in line 20 do not exist line 20 - while countBombelkowanie > 0 and sortBombelkowanieEnd > 0 do function algorytmSortowania (the_numberActivPlayersInMM, the_the_table) local countPlayersInMM = 0 for i, k in ipairs(listaTop10points) do listaTop10points[i] = nil end local playerValue = the_numberActivPlayersInMM while playerValue > 0 do countPlayersInMM = countPlayersInMM + 1 listaTop10name[countPlayersInMM] = the_the_table[playerValue][1] listaTop10points[countPlayersInMM] = the_the_table[playerValue][2] playerValue = playerValue - 1 end local countBombelkowanie = countPlayersInMM - 1 local sortBombelkowanieEnd = countBombelkowanie - 1 local iterowanieBombelkowania = 0 while countBombelkowanie > 0 and sortBombelkowanieEnd > 0 do iterowanieBombelkowania = iterowanieBombelkowania + 1 outputConsole("algorytmSortowania while countBombelkowanie > 0 and sortBombelkowanieEnd > 0 do - c=" ..countBombelkowanie.. "/s=" ..sortBombelkowanieEnd.. "/i=" ..iterowanieBombelkowania ) countBombelkowanie = countBombelkowanie - 1 if listaTop10points[iterowanieBombelkowania] < listaTop10points[iterowanieBombelkowania + 1] then local tempNick = listaTop10name[iterowanieBombelkowania] local tempPoints = listaTop10points[iterowanieBombelkowania] listaTop10name[iterowanieBombelkowania] = listaTop10name[iterowanieBombelkowania + 1] listaTop10points[iterowanieBombelkowania] = listaTop10points[iterowanieBombelkowania + 1] listaTop10name[iterowanieBombelkowania + 1] = tempNick listaTop10points[iterowanieBombelkowania + 1] = tempPoints end if countBombelkowanie == 0 then countBombelkowanie = sortBombelkowanieEnd sortBombelkowanieEnd = sortBombelkowanieEnd - 1 iterowanieBombelkowania = 0 end end end function playerReSortMeTableRankMM (theCountPlayersInMM, the_table) algorytmSortowania(theCountPlayersInMM, the_table) end addEvent( "onPlayerReSortMeTableRankMM", true ) addEventHandler( "onPlayerReSortMeTableRankMM", g_Root, playerReSortMeTableRankMM )
-
I misunderstood how this command ... but I want to solve it differently function pomalujSamochodGracza() local blip = blipPlayerListTable[source] local playerName = getPlayerName(source) if playerName == "[2RT]acp___(PL)" then if not blip then blipPlayerListTable[source] = createBlipAttachedTo(source, 0, 1, 0, 0, 255, 255, 0, 400) outputDebugString("createBlipAttachedTo" ..playerName, 3, 255, 0, 0) else attachElements(blipPlayerListTable[source], source) end end end function usunGraczZTabeliBipow() if blipPlayerListTable[source] then destroyElement(blipPlayerListTable[source]) end end addEventHandler('onPlayerQuit', g_Root , usunGraczZTabeliBipow) addEvent('onPlayerReachCheckpoint') addEventHandler('onPlayerReachCheckpoint', g_Root , pomalujSamochodGracza) addEvent('onPlayerPickUpRacePickup') addEventHandler('onPlayerPickUpRacePickup', g_Root , pomalujSamochodGracza) how to remove blips? It just does not work: function usunGraczZTabeliBipow() if blipPlayerListTable[source] then destroyElement(blipPlayerListTable[source]) end end
-
I wrote a script which adds a blip in the color of the player, but I do not know why it added more than once ... local g_Root = getRootElement() local g_ResRoot = getResourceRootElement(getThisResource()) function pomalujSamochodGracza() if getPlayerName(source) == "[2RT]acp___(PL)" then setVehicleColor(getPedOccupiedVehicle(source), 79, 79, 79, 79) local blip = getElementAttachedTo(source) if not blip or ( blip and getElementType(blip) == "blip" and getBlipIcon(blip) ~= 0 and getBlipSize(blip) ~= 4 ) then createBlipAttachedTo(source, 0, 1, 0, 0, 255, 255, 0, 400) outputDebugString("createBlipAttachedTo" ..getPlayerName(source), 3, 255, 0, 0) end elseif getPlayerName(source) == "[2RT]Wojak[PL]" then setVehicleColor(getPedOccupiedVehicle(source), 65, 65, 65, 65) local blip = getElementAttachedTo(source) if not blip or ( blip and getElementType(blip) == "blip" and getBlipIcon(blip) ~= 0 and getBlipSize(blip) ~= 4 ) then createBlipAttachedTo(source, 0, 1, 153, 150, 26, 255, 0, 400) outputDebugString("createBlipAttachedTo" ..getPlayerName(source), 3, 255, 0, 0) end end end addEvent('onPlayerReachCheckpoint') addEventHandler('onPlayerReachCheckpoint', g_Root , pomalujSamochodGracza)
-
What and where do I add that I had disappeared this message? WARNING: player.lua: Access denied @ 'getClientIP' - Line: 10 This applies to: "webpanel/script" resource 90% of warnings and errors in the server logs to this message I know that you can change: local IP = true to local IP = false I do not know exactly for what is needed this IP ...
-
Problem with no collision (race version="0.8.3")
acp___(PL) replied to acp___(PL)'s topic in Scripting
I tried in this way: - Server-side Event is added after the creation trailer - Client-side turn collisions, but there is no collisions - collisions are only between the trailers of two players server side function atachTrailerToPlayerVehicle(the_source) (...) trailerList[the_source] = createVehicle(435, trailerX, trailerY, trailerZ, vehicleRX, vehicleRY, vehicleRZ) (...) attachTrailerToVehicle(vehicleList[the_source], trailerList[the_source]) setTimer(function() triggerClientEvent ( "onClientColOn", g_rot, the_source, trailerList[the_source] ) outputConsole("triggerClientEvent ( onClientColOn, g_rot )" ..getPlayerName(the_source)) end, 5000, 1) end addEventHandler ( "onPlayerSpawn", g_rot, function () timerList[source] = setTimer(atachTrailerToPlayerVehicle, 500, 120, source) outputConsole("addEventHandler ( onPlayerSpawn, g_rot,: " ..getPlayerName(source)) end ) client side addEvent ( "onClientColOn", true ) addEventHandler ( "onClientColOn", g_rot, function(the_source, the_trailer) if the_source == gMe then for i, veh in ipairs (getElementsByType("vehicle")) do setElementCollidableWith(the_trailer, veh, true) end else setElementCollidableWith(getPedOccupiedVehicle(gMe), the_trailer, true) end end) -
<info name="Race" description="arc_'s MTA Race implementation" author="arc_" type="gamemode" version="0.8.3" build="r497 26Nov09" edf:definition="edf/race.edf"/> Problem is the lack of collisions between objects from outside the resource race I have a script for the race with a trailer, if someone loses a trailer when entering the checkpoint explodes You can of course try to connect a car with a trailer, but with out collision is sometimes not possible when the trailer is set in a wall direction How to make objects that were added by the script collisions with other objects? In the film you can see what the problem: - collisions are only between cars - there is no collision between a trailer and a car player or the rival car - there is a problem when connecting a trailer to the car
-
1. race.zip/modes/base.lua -- Finish reached RaceMode.setPlayerIsFinished(player) finishActivePlayer( player ) setPlayerStatus( player, nil, "finished" ) if rank == 1 then gotoState('SomeoneWon') showMessage('You have won the race!', 0, 255, 0, player) if self.rankingBoard then -- Remove lingering labels self.rankingBoard:destroy() end self.rankingBoard = RankingBoard:create() if g_MapOptions.duration then self:setTimeLeft( g_MapOptions.timeafterfirstfinish ) --2paq edit end else 2. race.zip/racemap.lua g_MapSettingNames = table.create( {'time', 'weather', 'respawn', 'respawntime', 'duration', 'timeafterfirstfinish', 'skins', 'bikehats', 'bikehatchance', 'carhats', 'carhatchance', 'hairstyles', 'glasses', 'glasseschance', 'shirts', 'trousers', 'shoes', 'ghostmode', 'vehicleweapons', 'autopimp', 'firewater', 'cachemodels', 'classicchangez'}, true ) --2paq edit 3. race.zip/race_server.lua function cacheMapOptions(map) g_MapOptions = {} g_MapOptions.duration = map.duration and tonumber(map.duration) > 0 and map.duration*1000 or g_GameOptions.defaultduration g_MapOptions.timeafterfirstfinish = map.timeafterfirstfinish and tonumber(map.timeafterfirstfinish) > 0 and map.timeafterfirstfinish*1000 or g_GameOptions.timeafterfirstfinish -- 2paq edit if g_MapOptions.duration > 86400000 then g_MapOptions.duration = 86400000 end (...) end function loadMap(res) local map = RaceMap.load(res) if not map then outputDebugString( 'Error loading map ' .. tostring(getResourceName(res)) ) outputChatBox( 'Error loading map ' .. tostring(getResourceName(res)) ) return false end -- set options g_MapInfo = {} g_MapInfo.name = map.info['name'] or 'unnamed' g_MapInfo.resname = map.info['resname'] or getResourceName(res) g_SavedMapSettings = {} g_SavedMapSettings.duration = map.duration g_SavedMapSettings.timeafterfirstfinish = map.timeafterfirstfinish --2paq edit g_SavedMapSettings.respawn = map.respawn (...) end 4. example: race-2paq1001.zip meta.xml: <meta> <include resource="2paq_driftmeter" /> <info type="map" gamemodes="race" name="2paq1001" /> <map src="2paq1001.map" /> <settings> <setting name="#time" value="6:0" /> <setting name="*timeafterfirstfinish" value="120" /> <setting name="*ghostmode" value="false" /> <setting name="*ghostalpha" value="false" /> <setting name="*vehicleweapons" value="true" /> <setting name="*autopimp" value="true" /> <setting name="#duration" value="1215" /> </settings> </meta>
-
why files are checked in the editor? this can not be disable!
-
hopes that it will be sooner rather than later I wrote about this issue on a forum in the days of the MTA: SA Race https://forum.multitheftauto.com/viewtop ... 04#p253804 very hard to explain to people that like everyone else playing the same handling.cfg is despite the fact the he is not original it is not cheating of course my modification is not to increase the speed of all vehicles on the contrary, some of the vehicles is much slower than in the original but it is accelerating sports cars as they should had and no ABS
-
Very good that someone noticed the problem of cheating by use of non-standard settings in some files In version Multi Theft Auto : San Andreas - 1.0.3 introduced blockade. Blockade by me is not the answer, administrator should decide on your settings! On my server we are using the same handling.cfg - but this handling is different than the original I don't want to dwell on the why, what is the difference and explain that it is not about cheating the other ... I will give an else example: sometimes I start server to drift, there is no difference whether one wins or loses. Why be limited to the original handling.cfg forced to admin and players? A better solution would be if the client has been downloaded from server this file, or the file was compared with a file that is on the server - one or few model file (original so that everyone could join server and by administrator settings) I am against cheating, but as an admin I would like also to have possible, in cases such as discussed above to have a choice of handling.cfg that players use on my server
-
Now I have confidence: [attachment=0]client_Release_11192009_2200.rar[/attachment] ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory ERROR: not enough memory
-
After about 3 hours of play on one of my maps I no longer collect Checkpoints At this time unless an error occurred [client log file]: ERROR: not enough memory When selecting solutions from the server MTA came to Windows ... [attachment=0]client_Release_11182009_2133.rar[/attachment]
-
you should change outputConsol to outputChatBox. than they will be fixed. What pills do you take? mars, what difference does it make? See any difference? Different outputs? I added a timer and now script work (see my last post)
-
I added a timer local g_rot = getRootElement() local trailerList = {} local vehicleList = {} function atachTrailerToPlayerVehicle(the_source) vehicleList[the_source] = getPedOccupiedVehicle(the_source) outputConsole("function atachTrailerToPlayerVehicle(the_source): " ..getPlayerName(the_source)) if vehicleList[the_source] and getElementModel(vehicleList[the_source]) == 515 then local vehicleX, vehicleY, vehicleZ = getElementPosition(vehicleList[the_source]) local vehicleRX, vehicleRY, vehicleRZ = getVehicleRotation(vehicleList[the_source]) local trailerX = vehicleX + 5 local trailerY = vehicleY + 5 local trailerZ = vehicleZ + 1 trailerList[the_source] = createVehicle(435, trailerX, trailerY, trailerZ, vehicleRX, vehicleRY, vehicleRZ) attachTrailerToVehicle(vehicleList[the_source], trailerList[the_source]) outputConsole("if vehicleList[the_source] and getElementModel(vehicleList[the_source]) == 515 then:" ..getPlayerName(the_source)) end end addEventHandler ( "onPlayerSpawn", g_rot, function () setTimer(atachTrailerToPlayerVehicle, 500, 10, source) outputConsole("addEventHandler ( onPlayerSpawn, g_rot,: " ..getPlayerName(source)) end )
-
no errors/warnings, but doesn't work in console sea only line: 8, 36 local g_rot = getRootElement() local trailerList = {} local vehicleList = {} local timerBlowList = {} addEventHandler ( "onPlayerSpawn", g_rot, function () vehicleList[source] = getPedOccupiedVehicle(source) outputConsole("addEventHandler ( onPlayerSpawn, g_rot,: " ..getPlayerName(source)) if vehicleList[source] and getElementModel(vehicleList[source]) == 515 then local vehicleX, vehicleY, vehicleZ = getElementPosition(vehicleList[source]) local vehicleRX, vehicleRY, vehicleRZ = getElementRotation(vehicleList[source]) local trailerX = vehicleX + 5 local trailerY = vehicleY + 5 local trailerZ = vehicleZ + 1 trailerList[source] = createVehicle(435, trailerX, trailerY, trailerZ, vehicleRX, vehicleRY, vehicleRZ) attachTrailerToVehicle(vehicleList[source], trailerList[source]) outputConsole("if vehicleList[source] and getElementModel(vehicleList[source]) == 515 then:" ..getPlayerName(source)) end end ) function blowTheVehicle(the_vehicle,the_player) blowVehicle(the_vehicle, true) end function checkIsVehicleTowedByVehicle() for i, k_player in ipairs(getElementsByType("Player")) do local k_vehicle = getPedOccupiedVehicle(k_player) if k_vehicle and not getVehicleTowedByVehicle(k_vehicle) then timerBlowList[k_player] = setTimer(blowTheVehicle, 5000, 1, k_vehicle, k_player) outputConsole("if k_vehicle and not getVehicleTowedByVehicle(k_vehicle) then:" ..getPlayerName(k_player).. " petla:" ..i) end outputConsole("for i, k_player in ipairs(getElementsByType(Player)) do:" ..getPlayerName(k_player).. " petla:" ..i) end end function timerIsVehicleTowedByVehicle() setTimer(checkIsVehicleTowedByVehicle, 1000, 0) outputConsole("function timerIsVehicleTowedByVehicle()") end addEvent('onMapStarting') addEventHandler('onMapStarting', g_rot , timerIsVehicleTowedByVehicle) <map edf:definitions="race"> <spawnpoint id="spawnpoint (NRG-500) (1)" vehicle="515" interior="0" posX="2179.8828125" posY="-1926.6389160156" posZ="16.185919761658" rotX="0" rotY="0" rotZ="141" /> <checkpoint id="checkpoint (1)" type="ring" color="#00F9" size="20" interior="0" posX="1754.7119140625" posY="-2656.4423828125" posZ="266" rotX="0" rotY="0" rotZ="0" /> </map>
-
It is possible to add tools / functions in a simple way to allow control of the vehicle or / and pedostrian for a given path? Allowed to is the addition of pseudo-street traffic, and make race harder Asks a question, because I do not know exactly how the vehicles are driven in the game, but it seems to me that after some path
-
and there is a chance that this fix?
-
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)
-
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.
-
thanks Buffalo, this is a much simpler way, but it works the same and in both cases are some angle extent is difficult to eliminate confusion ... Now I use the mix of the two method local driftPlayerVehicle = getPedOccupiedVehicle(gMe) if getVehicleType(driftPlayerVehicle) == "Automobile" then myX, myY = getElementPosition(gMe) local speedXdrift, speedYdrift, speedZdrift = getElementVelocity (driftPlayerVehicle) local driftSpeed = math.sqrt(speedXdrift^2 + speedYdrift^2 + speedZdrift^2) * 161 --2paq method local driftX0 = driftX1 local driftY0 = driftY1 driftX1 = myX driftY1 = myY local myRX, myRY, myRZ = getElementRotation(driftPlayerVehicle) local distVectorNorth = getDistanceBetweenPoints2D(driftX0, driftY0, driftX0, driftY1) local distVectorSpeed = getDistanceBetweenPoints2D(driftX0, driftY0, driftX1, driftY1) local cosinusDrift = distVectorNorth / distVectorSpeed local angelDriftBezwzgledny = math.acos(cosinusDrift) local angelDriftAbs = angelDriftBezwzgledny * (180 / math.pi) --Inclusion of a quadrant of the coordinate system if driftY1 < driftY0 and driftX1 < driftX0 then angelDriftAbs = 180 - angelDriftAbs elseif driftY1 < driftY0 and driftX1 > driftX0 then angelDriftAbs = 180 + angelDriftAbs elseif driftY1 > driftY0 and driftX1 > driftX0 then angelDriftAbs = 360 - angelDriftAbs end local angelDrift = math.floor(math.abs(myRZ - angelDriftAbs)) --Inclusion of a quadrant of the coordinate system and direction of drifting if angelDrift > 5 then if driftY1 > driftY0 and driftX1 < driftX0 and myRZ > 180 then angelDrift = angelDrift - 180 elseif driftY1 > driftY0 and driftX1 > driftX0 and myRZ < 180 then angelDrift = angelDrift - 180 end end --Buffalo method local nxDrift,nyDrift = speedXdrift * 50 + myX, speedYdrift * 50 + myY local staticRotInDrift = ( 360 - math.deg ( math.atan2 ( ( nxDrift - myX ), ( nyDrift - myY ) ) ) ) % 360 local angelDriftBuffalo = math.floor(math.abs(staticRotInDrift - myRZ)) --Restrictions 2paq method if driftSpeed <= 25 or (angelDrift/driftSpeed) >= 1.5 then angelDrift = 0 elseif angelDrift <= 5 then angelDrift = 0 end --Restrictions Buffalo method if driftSpeed <= 25 or (angelDriftBuffalo/driftSpeed) >= 1.5 then angelDriftBuffalo = 0 elseif angelDriftBuffalo <= 5 then angelDriftBuffalo = 0 end --Restrictions if math.abs(angelDriftBuffalo - angelDrift) > 15 then angelDrift = 0 end if myRX > 30 or myRY > 30 then angelDrift = 0 end angelDrift = ( angelDrift + angelDriftBuffalo ) / 2 if driftSpeed < 1 or driftSpeed > 350 then driftSpeed = 0 end --Time interval between drifts ~3s (limit FPS = 36) if angelDrift >= 18 then driftTime = 150 elseif angelDrift > 5 then driftTimeTP = 150 end if driftTime >= 0 then driftTime = driftTime - 1 end if driftTimeTP >= 0 then driftTimeTP = driftTimeTP - 1 end --Reset factor and temporary points after a time if driftTime == 0 or driftTimeTP == 0 then if bestDriftPoints < driftPointsTEMP then bestDriftPoints = driftPointsTEMP end driftFactor = 1 driftPointsTEMP = 0 driftKolorR = 255 driftKolorG = 255 driftKolorB = 0 --Icrement factor 1s after last drift (limit FPS = 36) elseif driftTime == 132 and driftCpTimer > 0 and driftFactor <= 12 then driftFactor = driftFactor + 1 if driftFactor > 11 then driftKolorR = 255 driftKolorB = 0 elseif driftFactor > 8 then driftKolorB = driftKolorB + 51 elseif driftFactor > 6 then driftKolorB = driftKolorB + 51 driftKolorG = driftKolorG - 51 elseif driftFactor > 3 then driftKolorG = driftKolorG - 51 driftKolorR = driftKolorR - 51 elseif driftFactor > 1 then driftKolorR = driftKolorR - 51 end end if driftCpTimer > 0 then driftCpTimer = driftCpTimer - 1 else driftFactor = 0 end --Restriction against donuts one way if ((myRZ > 55 and myRZ < 65) or (myRZ > 175 and myRZ < 185) or (myRZ > 295 and myRZ < 305)) and math.abs(myRZ_poprzedni - myRZ) > 2 then if myRZ_poprzedni > myRZ then antyBonczek = antyBonczek + 1 else antyBonczek = antyBonczek - 1 end end -- dxDrawText( "antyBonczek: " ..antyBonczek, math.floor(40*screenPlayerWidth), math.floor(200*screenPlayerHeight), screenWidth, screenHeight, tocolor ( 0, 255, 0, 255 ), 1, "pricedown") myRZ_poprzedni = myRZ if math.abs(antyBonczek) > 14 then driftFactorAntyBonczek = 0 antyBonczekTimer = 36 * 60 antyBonczek = 0 driftFactor = 0 driftPointsTEMP = 0 end if antyBonczekTimer > 0 then antyBonczekTimer = antyBonczekTimer - 1 dxDrawText( "DRIFT x0 (" ..antyBonczekTimer.. ")", math.floor(5*screenPlayerWidth), math.floor(557*screenPlayerHeight), screenWidth, screenHeight, tocolor ( 255, 255, 0, 255 ), 1, "pricedown") end if antyBonczekTimer == 2 then antyBonczek = 0 driftFactorAntyBonczek = 1 end --points to view and remember local vehDriftHealth = getElementHealth(getPedOccupiedVehicle(gMe)) if vehDriftHealth and vehDriftHealth > 1 and playerIsNotSpawn == 1 then local thisRenderDriftPoints = (driftSpeed * angelDrift * driftFactor * driftFactorAntyBonczek)/850 driftPointsTEMP = driftPointsTEMP + thisRenderDriftPoints driftPoints = driftPoints + (thisRenderDriftPoints/333) allDriftPoints = allDriftPoints + thisRenderDriftPoints end