Jaysds1 Posted July 26, 2011 Author Posted July 26, 2011 The error is still shown... My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted July 26, 2011 Posted July 26, 2011 Tried the last script I posted? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted July 26, 2011 Author Posted July 26, 2011 Thanks Castillo, it works now And JR10 thanks for trying to help me. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Jaysds1 Posted July 26, 2011 Author Posted July 26, 2011 I have this same problem... When the text shown, I want it to disappear until they enter another zone... Client-side only: local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution function createText ( ) local playerX, playerY, playerZ = getElementPosition( getLocalPlayer() ) -- Get player's coordinates. local playerZoneName = getZoneName( playerX, playerY, playerZ ) -- Get name of the player's zone. dxDrawText( playerZoneName, 0.95, screenHeight-37, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) -- Draw Zone Name text shadow. dxDrawText( playerZoneName, 0.95, screenHeight-40, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) -- Draw Zone Name text. end function HandleTheRendering() showPlayerHudComponent("area_name", false) addEventHandler("onClientRender",rootElement, createText) -- keep the text visible with onClientRender. setTimer(removeEventHandler,1500,0,"onClientRender",rootElement,createText) end addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted July 26, 2011 Posted July 26, 2011 Try: local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution function createText ( ) local playerX, playerY, playerZ = getElementPosition( getLocalPlayer() ) -- Get player's coordinates. local playerZoneName = getZoneName( playerX, playerY, playerZ ) -- Get name of the player's zone. dxDrawText( playerZoneName, 0.95, screenHeight-37, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) -- Draw Zone Name text shadow. dxDrawText( playerZoneName, 0.95, screenHeight-40, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) -- Draw Zone Name text. end function HandleTheRendering() showPlayerHudComponent("area_name", false) addEventHandler("onClientRender",rootElement, createText) -- keep the text visible with onClientRender. setTimer(function() removeEventHandler("onClientRender",rootElement,createText) end,1500,0) end addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted July 26, 2011 Author Posted July 26, 2011 thanks... My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted July 27, 2011 Posted July 27, 2011 No problem. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted July 28, 2011 Author Posted July 28, 2011 How do you make the camera change based on a timer? function fadeCamera(source, true, 5) setCameraMatrix(source, 1636.267578125,-2286.37890625,72.458694458008, 1682.93359375,-2286.330078125,13.508057594299) setTimer(function() fadeCamera(source, true, 5) setCameraMatrix(source, 1786.759765625,1450.986328125,92.410263061523, 1688.240234375,1448.77734375,10.767894744873)end, 9000,0) setTimer(function() fadeCamera(source, true, 5) setCameraMatrix(source, -1685.783203125,-580.9912109375,272.26177978516, -1570.81640625,-455.7080078125,14)end, 9000,0) end Thanks for helping My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted July 28, 2011 Posted July 28, 2011 You should make a table, a timer to change the matrix to a random value from the table. Example: local Table = { {0, 0, 0, 1, 1, 1}, {1, 1, 1, 2, 2, 2} } local timer = {} function Show(player) local x, y, z, lx, ly, lz = unpack(Table[math.random(#Table)]) -- get a random value from the Table and unpack it to get the coords fadeCamera(player, false, 1, 0, 0, 0) setTimer(setCameraMatrix, 1000, 1, player, x, y, z, lx, ly, lz) setTimer(fadeCamera, 1000, 1, player, true) setTimer(Show, 8000, 1, player) end Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted July 29, 2011 Author Posted July 29, 2011 thanks, I never would have thought of that... My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted July 29, 2011 Posted July 29, 2011 No problem. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted July 29, 2011 Author Posted July 29, 2011 JR10, It doesn't work... i added my coordinates and restarted it but the camera is blank/black.: local Table = { {1636.267578125,-2286.37890625,72.458694458008, 1682.93359375,-2286.330078125,13.508057594299}, {1786.759765625,1450.986328125,92.410263061523, 1688.240234375,1448.77734375,10.767894744873}, {-1685.783203125,-580.9912109375,272.26177978516, -1570.81640625,-455.7080078125,14}} local timer = {} function Show() local x, y, z, lx, ly, lz = unpack(Table[math.random(#Table)]) -- get a random value from the Table and unpack it to get the coords fadeCamera(source, true, 5) setTimer(setCameraMatrix, 100, 1, source, x, y, z, lx, ly, lz) setTimer(fadeCamera, 100, 1, source, true) setTimer(Show, 8000, 1, source) end My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted July 29, 2011 Posted July 29, 2011 Because you changed it wrong, i made you Show function to use it. local Table = { {1636.267578125,-2286.37890625,72.458694458008, 1682.93359375,-2286.330078125,13.508057594299}, {1786.759765625,1450.986328125,92.410263061523, 1688.240234375,1448.77734375,10.767894744873}, {-1685.783203125,-580.9912109375,272.26177978516, -1570.81640625,-455.7080078125,14}} local timer = {} function Show(player) local x, y, z, lx, ly, lz = unpack(Table[math.random(#Table)]) -- get a random value from the Table and unpack it to get the coords fadeCamera(player, true, 5) setTimer(setCameraMatrix, 100, 1, player, x, y, z, lx, ly, lz) setTimer(fadeCamera, 100, 1, player, true) setTimer(Show, 8000, 1, player) end addEventHandler("onPlayerJoin", root, function() Show(source) end) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted July 29, 2011 Author Posted July 29, 2011 ohhh, I 4got about the onPlayerJoin, Thanks again... My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted July 29, 2011 Posted July 29, 2011 No problem. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Jaysds1 Posted August 10, 2011 Author Posted August 10, 2011 Hi again, I want to know if this code respawns all vehicles addCommandHandler("rav", function() outputChatBox("RESPAWNING ALL UNOCCUPIED VEHICLES IN 30Secs") local vehicles = getElementsByType ( "vehicle" ) -- Return all the vehicles in a table for k, vehicle in ipairs ( vehicles ) do -- For every vehicle do the following... if (getVehicleOccupants(vehicle) == false) then resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time setTimer(function() respawnVehicle(vehicle) end,30000,0) end end end) Thanks for checking it... My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted August 10, 2011 Posted August 10, 2011 (edited) addCommandHandler("rav", function() outputChatBox("RESPAWNING ALL UNOCCUPIED VEHICLES IN 30Secs") setTimer(function () local vehicles = getElementsByType ( "vehicle" ) -- Return all the vehicles in a table for k, vehicle in ipairs ( vehicles ) do -- For every vehicle do the following... if isEmpty( vehicle ) then local seats = getVehicleMaxPassengers(vehicle) resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time respawnVehicle ( vehicle ) end end end, 30000, 1) end) function isEmpty( vehicle ) local passengers = getVehicleMaxPassengers( vehicle ) if type( passengers ) == 'number' then for seat = 0, passengers do if getVehicleOccupant( vehicle, seat ) then return false end end end return true end Edited August 10, 2011 by Guest San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted August 10, 2011 Author Posted August 10, 2011 thanks again Castillo, I wish I could be like u... My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted August 10, 2011 Posted August 10, 2011 Wait, copy the code again, I fixed some bugs. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Jaysds1 Posted August 10, 2011 Author Posted August 10, 2011 ok, thanks, I see the bug now... My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Jaysds1 Posted August 11, 2011 Author Posted August 11, 2011 Hello again, I have this problem with a script I'm working on... When the player enters the vehicle and turns left or right, the left or right blinker/light is suppose to blink, Here's my script: addEventHandler("onVehicleEnter", getRootElement(), function(player) local vehicle = getPedOccupiedVehicle(player) if getControlState(player, vehicle_left) then setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) else setVehicleOverrideLights(vehicle,0) end if getControlState(player, vehicle_right) then setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) else setVehicleOverrideLights(vehicle,0) end end) and thanks for help... My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Castillo Posted August 11, 2011 Posted August 11, 2011 Maybe you should put a string, not a variable (vehicle_left, vehicle_right)...? addEventHandler("onVehicleEnter", getRootElement(), function(player) local vehicle = getPedOccupiedVehicle(player) if getControlState(player, "vehicle_left") then setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) else setVehicleOverrideLights(vehicle,0) end if getControlState(player, "vehicle_right") then setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) else setVehicleOverrideLights(vehicle,0) end end) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
SDK Posted August 11, 2011 Posted August 11, 2011 You need a timer for that, you can't just put them behind each other. Learn Lua - Learn to script - GUI scripting Scripter tools - Find/fix errors yourself(!) Don't pm me for scripting help, keep it for the Scripting subforum!
Jaysds1 Posted August 11, 2011 Author Posted August 11, 2011 This is the error that is shown when a person enters a vehicle: [2011-08-11 12:27:45] WARNING: JEngine\server.lua:22: Bad 'ped' pointer @ 'getPedOccupiedVehicle'(1)[2011-08-11 12:27:45] WARNING: JEngine\server.lua:23: Bad 'player' pointer @ 'getControlState'(1) [2011-08-11 12:27:45] WARNING: JEngine\server.lua:37: Bad argument @ 'setVehicleOverrideLights' [2011-08-11 12:27:45] WARNING: JEngine\server.lua:38: Bad argument @ 'setVehicleLightState' [2011-08-11 12:27:45] WARNING: JEngine\server.lua:39: Bad argument @ 'setVehicleLightState' [2011-08-11 12:27:45] WARNING: JEngine\server.lua:43: Bad 'ped' pointer @ 'getPedOccupiedVehicle'(1) [2011-08-11 12:27:45] WARNING: JEngine\server.lua:44: Bad 'player' pointer @ 'getControlState'(1) [2011-08-11 12:27:45] WARNING: JEngine\server.lua:58: Bad argument @ 'setVehicleOverrideLights' [2011-08-11 12:27:45] WARNING: JEngine\server.lua:59: Bad argument @ 'setVehicleLightState' [2011-08-11 12:27:45] WARNING: JEngine\server.lua:60: Bad argument @ 'setVehicleLightState' i changed the script a little, here: addEventHandler("onVehicleEnter", getRootElement(), function(player) turnLeft(player, "vehicle_left") turnRight(player, "vehicle_right") end) function turnLeft(player, key) local vehicle = getPedOccupiedVehicle(player) if (getControlState(player, key)) then setVehicleLightState(vehicle, 1,1) setVehicleLightState(vehicle, 3,1) setTimer(function() setVehicleOverrideLights(vehicle, 1) end,1000,0) setTimer(function() setVehicleOverrideLights(vehicle, 2) end,1000,0) setTimer(function() setVehicleOverrideLights(vehicle, 1) end,1000,0) setTimer(function() setVehicleOverrideLights(vehicle, 2) end,1000,0) setTimer(function() setVehicleOverrideLights(vehicle, 1) end,1000,0) setTimer(function() setVehicleOverrideLights(vehicle, 2) end,1000,0) setTimer(function() setVehicleOverrideLights(vehicle, 1) end,1000,0) setTimer(function() setVehicleOverrideLights(vehicle, 2) end,1000,0) setTimer(function() setVehicleOverrideLights(vehicle, 1) end,1000,0) setTimer(function() setVehicleOverrideLights(vehicle, 2) end,1000,0) else setVehicleOverrideLights(vehicle,0) setVehicleLightState(vehicle,1,0) setVehicleLightState(vehicle,3,0) end end function turnRight(player, key) local vehicle = getPedOccupiedVehicle(player) if (getControlState(player, key)) then setVehicleLightState(vehicle, 0,1) setVehicleLightState(vehicle, 2,1) setTimer(function() setVehicleOverrideLights(vehicle, 1) end,5000,0) setTimer(function() setVehicleOverrideLights(vehicle, 2) end,5000,0) setTimer(function() setVehicleOverrideLights(vehicle, 1) end,5000,0) setTimer(function() setVehicleOverrideLights(vehicle, 2) end,5000,0) setTimer(function() setVehicleOverrideLights(vehicle, 1) end,5000,0) setTimer(function() setVehicleOverrideLights(vehicle, 2) end,5000,0) setTimer(function() setVehicleOverrideLights(vehicle, 1) end,5000,0) setTimer(function() setVehicleOverrideLights(vehicle, 2) end,5000,0) setTimer(function() setVehicleOverrideLights(vehicle, 1) end,5000,0) setTimer(function() setVehicleOverrideLights(vehicle, 2) end,5000,0) else setVehicleOverrideLights(vehicle,0) setVehicleLightState(vehicle,0,0) setVehicleLightState(vehicle,2,0) end end I sort of copied what wiki showed. My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
JR10 Posted August 12, 2011 Posted August 12, 2011 Try: addEventHandler("onVehicleEnter", getRootElement(), function(player) local vehicle = source if getControlState(player, "vehicle_left") then setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) else setVehicleOverrideLights(vehicle,0) end if getControlState(player, "vehicle_right") then setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) setVehicleOverrideLights(vehicle, 1) setVehicleOverrideLights(vehicle, 2) else setVehicleOverrideLights(vehicle,0) end end) Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now