-
Posts
4,121 -
Joined
-
Last visited
-
Days Won
2
Everything posted by Kenix
-
local screenWidth, screenHeight = guiGetScreenSize() local timer, state function repairVehicle() local theVehicle = getPedOccupiedVehicle( localPlayer ) if theVehicle then dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) else dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) end end bindKey( '2','down', function( ) if not state then if getPlayerMoney() >= 2500 then takePlayerMoney(2500) else dxDrawText("Nie posiadasz $2500 na naprawe!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) end if isTimer(timer) then return end local theVehicle = getPedOccupiedVehicle( localPlayer ) if theVehicle then fixVehicle( theVehicle ) end addEventHandler( 'onClientRender',root,repairVehicle ) state = true timer = setTimer( function() dxDrawText("Odczekaj 5 sekund!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) removeEventHandler( 'onClientRender',root,repairVehicle ) state = false end, 5000,1 ) end end )
-
addEventHandler("preparePlaybackForStart", g_Root, function(info) for i,v in pairs( info ) do outputChatBox( 'index'..tostring( i )..'value'..tostring( v ) ) end --... Try it. And we find out whether it contains anything or not.
-
Can you debug full, function recordKeys? return values in functions,variables,...
-
Try addEvent("startRecording", true) addEvent("setControlState", true) g_Root = getRootElement() g_Me = getLocalPlayer() keysTimer = nil ACCURACY = 200 --200ms POS_UPDATE = 2500 --2500ms lastKeysChecked = {} keysState = {} posTickUpd = nil keyNames = { "special_control_up", "special_control_down", "special_control_right", "special_control_left", "vehicle_look_right", "vehicle_look_left", "handbrake", "sub_mission", "horn", "brake_reverse", "accelerate", "steer_back", "steer_forward", "vehicle_right", "vehicle_left", "vehicle_secondary_fire", "vehicle_fire" } -- 17 local pRecordingInfo = { startPosX, startPosY, startPosZ, startRotX, startRotY, startRotZ, pVeh = nil, vehModel = nil, pKey = {}, pKeyState = {}, vehHealth = {}, posUpdX = {}, posUpdY = {}, posUpdZ = {}, posUpdRotX = {}, posUpdRotY = {}, posUpdRotZ = {}, posUpdVelX = {}, posUpdVelY = {}, posUpdVelZ = {} } function recordKeys() local veh = getPedOccupiedVehicle(g_Me) if veh then -- Got the hunter if getElementModel(veh) == 425 then if isTimer(keysTimer) then killTimer(keysTimer) end posTickUpd = nil lastKeysChecked = {} outputDebugString("[Recording finished]") return end -- Record the keys for i, k in ipairs(keyNames) do local state = getControlState(k) if state then if not lastKeysChecked[k] then table.insert(pRecordingInfo.pKey, k) table.insert(pRecordingInfo.pKeyState, state) lastKeysChecked[k] = true outputDebugString("getControlState key: " ..k.. " state: true") keysState = nil else table.insert(pRecordingInfo.pKey, "continue") table.insert(pRecordingInfo.pKeyState, "continue") outputDebugString("getControlState key: " ..k.. " state: continue") end else if not state then if lastKeysChecked[k] then table.insert(pRecordingInfo.pKey, k) table.insert(pRecordingInfo.pKeyState, false) outputDebugString("getControlState key: " ..k.. " state: false") lastKeysChecked[k] = false else keysState = true end end end end if getPressedKeys() == 17 then table.insert(pRecordingInfo.pKey, "nothing") table.insert(pRecordingInfo.pKeyState, "nothing") outputDebugString("getControlState key: nothing state: nothing") end -- Position update if not posTickUpd then posTickUpd = getTickCount() end if getTickCount() - posTickUpd > POS_UPDATE then local tmpX, tmpY, tmpZ = getElementPosition(veh) table.insert(pRecordingInfo.posUpdX, tmpX) table.insert(pRecordingInfo.posUpdY, tmpY) table.insert(pRecordingInfo.posUpdZ, tmpZ) tmpX, tmpY, tmpZ = getElementRotation(veh) table.insert(pRecordingInfo.posUpdRotX, tmpX) table.insert(pRecordingInfo.posUpdRotY, tmpY) table.insert(pRecordingInfo.posUpdRotZ, tmpZ) tmpX, tmpY, tmpZ = getElementVelocity(veh) table.insert(pRecordingInfo.posUpdVelX, tmpX) table.insert(pRecordingInfo.posUpdVelY, tmpY) table.insert(pRecordingInfo.posUpdVelZ, tmpZ) table.insert(pRecordingInfo.vehHealth, getElementHealth(veh)) posTickUpd = getTickCount() outputDebugString("[Pos update]") end else --resetRecordInfo() outputDebugString("[Error while recording, aborting..]", 0, 255, 0, 0) end end function resetRecordInfo() if isTimer(keysTimer) then killTimer(keysTimer) end pRecordingInfo = { startPosX, startPosY, startPosZ, startRotX, startRotY, startRotZ, pVeh = nil, vehModel = nil, pKey = {}, pKeyState = {}, posUpdX = {}, posUpdY = {}, posUpdZ = {}, posUpdRotX = {}, posUpdRotY = {}, posUpdRotZ = {}, posUpdVelX = {}, posUpdVelY = {}, posUpdVelZ = {}, vehHealth = {} } posTickUpd = nil lastKeysChecked = {} end function getPressedKeys() local count = 0 for i = 1, #keysState do if keysState then count = count + 1 end end return count end addEventHandler("startRecording", g_Root, function() --resetRecordInfo() pRecordingInfo.pVeh = getPedOccupiedVehicle(g_Me) pRecordingInfo.startPosX, pRecordingInfo.startPosY, pRecordingInfo.startPosZ = getElementPosition(pRecordingInfo.pVeh) pRecordingInfo.startRotX, pRecordingInfo.startRotY, pRecordingInfo.startRotZ = getElementRotation(pRecordingInfo.pVeh) pRecordingInfo.vehModel = getElementModel(pRecordingInfo.pVeh) keysTimer = setTimer(recordKeys, ACCURACY, 0) outputDebugString("[Recording started]") end ) addEventHandler("setControlState", g_Root, function(ped, key, state) if key == "continue" or state == "continue" or key == "nothing" or state == "nothing" then else setPedControlState(ped, key, state) end end ) addEventHandler("onClientPlayerWasted", g_Root, function() resetRecordInfo() outputDebugString("[Recording stopped]") end ) addCommandHandler("asd", function() triggerServerEvent("preparePlaybackForStart", g_Root, pRecordingInfo) end ) addCommandHandler("data", function() local cc = 1 local second = 2500 setTimer( function() outputChatBox("Second " ..second.. " X: " ..pRecordingInfo.posUpdX[cc].. "Y: " ..pRecordingInfo.posUpdY[cc].. "Z: " ..pRecordingInfo.posUpdZ[cc]) second = second + 2500 cc = cc + 1 end , 2500, 0) end ) Rules: Events Variables functions event handlers The order is important. Otherwise it will not work.
-
So getElementPosition not return nil value right? You can show full code please
-
You check returned value getElementPosition? Maybe variable veh is not element and function getElementPosition return nil.
-
What return variable tmpX? Show full code please.
-
You insert to table? table = { } table.posUpdX = { } table.posUpdX[1] = 123 print( table.posUpdX[1] ) -- 123 Updated. Example
-
You can write, what not work? /debugscript 3?
-
local pRecordingInfo = { startPosX, startPosY, startPosZ, startRotX, startRotY, startRotZ, pVeh = nil, vehModel = nil, pKey = {}, pKeyState = {}, vehHealth = {}, posUpdX = {}, posUpdY = {}, posUpdZ = {}, posUpdRotX = {}, posUpdRotY = {}, posUpdRotZ = {}, posUpdVelX = {}, posUpdVelY = {}, posUpdVelZ = {} } -- Put all the info on each table, etc triggerServerEvent("sendPressedKeys", g_Root, pRecordingInfo) -- Server side table = nil addEvent("sendPressedKeys", true) addEventHandler("sendPressedKeys", g_Root, function(info) table = info end ) outputChatBox(table.startPosX) -- Works good outputChatBox(table.posUpdX[1]) -- Gives me a nil value Fixed. addEvent("sendPressedKeys", true) addEventHandler("sendPressedKeys", g_Root, funcion(info) -- You use funcion, but need use function. table = info end ) So in your code syntax error , if you understand.
-
[lua][/lua] highlighting
Kenix replied to Static-X's topic in Site/Forum/Discord/Mantis/Wiki related
http://pastebin.com/8M7h8HNs Fresh -
_getPlayerName = getPlayerName function getPlayerName ( plr,removeHex ) if isElement( plr ) then if removeHex then local name = _getPlayerName( plr ) return name:gsub ( '#%x%x%x%x%x%x', '' ) or name end return _getPlayerName( plr ) end return false end What you mean i not understand ... Remove hex only? string getPlayerName ( player plr,[ bool removeHex ] )
-
Классная песня
-
_getPlayerName = getPlayerName function getPlayerName( el ) if isElement( el ) then local name = _getPlayerName( el ) if name then return name:gsub ( '#%x%x%x%x%x%x', '' ) or name end return false end return false end ?
-
You lol? I do not need for you to write all the code you have to write yourself. This impudence I just help. All functions: Client side https://wiki.multitheftauto.com/wiki/Cli ... _Functions Server side https://wiki.multitheftauto.com/wiki/Ser ... _Functions Find the right is not difficult.
-
Server addCommandHandler( 'fire', function( thePlayer,cmd ) toggleControl( thePlayer,'fire',not isControlEnabled( thePlayer,'fire' ) ) end )
-
local screenWidth, screenHeight = guiGetScreenSize( ) local timer,state function repairVehicle() local theVehicle = getPedOccupiedVehicle( localPlayer ) if theVehicle then dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements else dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements end end bindKey( 'F2','down', function( ) if not state then if getPlayerMoney( ) >= 2500 then takePlayerMoney( 2500 ) if isTimer( timer ) then return end local theVehicle = getPedOccupiedVehicle( localPlayer ) if theVehicle then fixVehicle( theVehicle ) end addEventHandler( 'onClientRender',root,repairVehicle ) state = true timer = setTimer( function( ) removeEventHandler( 'onClientRender',root,repairVehicle ) state = false end, 5000,1 ) end end end )
-
Ты не знаешь что пишешь! https://wiki.multitheftauto.com/index.ph ... troduction
-
You lol? I tested now it working .. Maybe you not have money?
-
scripter_new,What you need create? All players can't fire if you use /unfire ? or what
-
local screenWidth, screenHeight = guiGetScreenSize( ) local timer function repairVehicle() local theVehicle = getPedOccupiedVehicle( localPlayer ) if theVehicle then dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements else dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements end end bindKey( 'F2','down', function( ) if getPlayerMoney( ) >= 2500 then takePlayerMoney( 2500 ) if isTimer( timer ) then return end local theVehicle = getPedOccupiedVehicle( localPlayer ) if theVehicle then fixVehicle( theVehicle ) end addEventHandler('onClientRender',root,repairVehicle) timer = setTimer( function( ) removeEventHandler('onClientRender',root,repairVehicle) end, 3000,1 ) end end ) ... function repairVehicle() local theVehicle = getPedOccupiedVehicle(localPlayer) if(theVehicle) then fixVehicle(theVehicle) dxDrawText("Pojazd zostal naprawiony! (Koszt: $2500)", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements else dxDrawText("Musisz znajdowac sie w pojezdzie!", screenWidth*0.5, screenHeight*0.1, screenWidth*0.5, screenHeight*0.5, tocolor(255,0,0,210), 1.0, "bankgothic", "center", "center", false, false, false) -- you can't use variables in dx drawing because it don't return elements end end Good job fix car in render!
-
scripter_new,2 argument addCommandHandler is function ( not element ).