-
Posts
6,063 -
Joined
-
Last visited
-
Days Won
209
Everything posted by IIYAMA
-
No. local teamBlue = createTeam ( "Team Blue", 0, 0, 255 ) local teamRed = createTeam ( "Team Red", 255, 0, 0 ) local teams = {teamBlue,teamRed} local randomteam = teams[math.random(#teams)]
-
repairTimer = setTimer(function() repairTimer = false end,repairDelayTime,1) Although tickcount would be more suitable for this code.
-
You forgot to define if it is relative or absolute. element guiCreateStaticImage ( float x, float y, float width, float height, string path, bool relative, [element parent = nil] )
-
dxDraw functions don't create elements. Ones they are executed they will show a DX effect, which is only shown for 1 frame. If you want images in your gui, use: https://wiki.multitheftauto.com/wiki/Gu ... taticImage
-
afk, your limit is your HDD. And when you write too much characters per frame, you might crash(unless you enable fileFlush, which is for logging). The max string length is limited by your ram.
-
are you kidding me? That code just creates a custom event. You are the one that has to test and add everything. If you forget to add everything, it will be impossible to help you.
-
afaik, weapon sounds aren't the same as the tank sound or am I incorrect? Try to find the correct sounds using: /debugscript 3 /start runcode /crun setDevelopmentMode ( true) /showsound 1 Shoot the tank cannon.
-
that laggs, will use too much bandwidth and it is incorrect. This example should enable the event "onPlayerTeamChange". local lastPlayerTeam = {} setTimer(function () local players = getElementsByType("player") for i=1,#players do local player = players[i] local playerTeam = getPlayerTeam(player) or false -- make sure it always returns false, if it returns nil. if playerTeam then local lastTeam = lastPlayerTeam[player] or false -- make sure it always returns false, if it returns nil. if playerTeam ~= lastTeam then triggerEvent("onPlayerTeamChange",player,isElement(lastTeam) and lastTeam or false,playerTeam) lastPlayerTeam[player] = playerTeam end else local lastTeam = lastPlayerTeam[player] if lastTeam then triggerEvent("onPlayerTeamChange",player,isElement(lastTeam) and lastTeam or false,nil) lastPlayerTeam[player] = nil end end end end,1000,0) addEventHandler("onPlayerQuit",root, function () if lastPlayerTeam[source] then lastPlayerTeam[source] = nil end end) Which you can use here: addEventHandler ( "onPlayerTeamChange", root, function ( oldTeam,newTeam ) local team = getTeamFromName ( "Criminal" ) if oldTeam == team then setElementVisibleTo( criminalBlip, source, nil ) elseif newTeam == team then setElementVisibleTo( criminalBlip, source, true ) end end) And this is maybe handy too. addEventHandler("onPlayerJoin",root, function () setElementVisibleTo(criminalBlip, source, false) end) Nothing is tested, I will leave that to you.
-
It means that the account data hasn't been set yet. It is nil. Replace line 7 t/m 8 with: local points = tonumber(getAccountData (account, "DMpoints")) or 0 local money = tonumber(getAccountData (account, "DMmoney")) or 0 Which will replace the accountdata with 0, when it hasn't been set/hasn't been set correct.
-
Because dxDraw functions are rendering behind the gui. Unless the argument postGUI is set to true(which is by default false): postGUI: A bool representing whether the text should be drawn on top of or behind any ingame GUI (rendered by CEGUI).
-
Is the server OK, when players start download resources? What about the RAM, SWAP and CPU usage?
-
the createBrowser function returns a dynamic texture, which you can render with a 3D render function near the object. Using: dxDrawMaterialLine3D
-
Try to render with lower resolution, if your pc can't handle it. This should be optional for the user experience.
-
I personal see it like this: (others have different opinions about it) A: can be anything in the table. B: can also be anything in the table. The only way to sort a table is by comparing data with each other. So what are A and B? [color=#0000FF]toptimes[/color] = { [color=#FF0000][b]{[/b][/color]32423,"nickname"[color=#FF0000][b]},[/b][/color] [color=#FF0000][b]{[/b][/color]12313,"nickname"[color=#FF0000][b]},[/b][/color] }; A and B are the data which are inside of the sorted table. Which are in this case tables too. The table.sort function will be comparing and sort those data behind the scene. And the function(with the A and B) will be used in this process.
-
Smooth animations can be done with onClientRender. Untested, but this might give you an idea how this can be working. local animationEnd = 0 local startRotation local isRenderingAnimation = false local changeRotateSmoothFunction changeRotateSmoothFunction = function () local timeNow = getTickCount() local factor = 1-((animationEnd - timeNow)/300) -- calculate the factor based on future time. if factor < 1 then rot1 = (startRotation + (5*factor))%360 else rot1 = startRotation+5 -- set at the end to the correct rotation removeEventHandler("onClientRender",root,changeRotateSmoothFunction) -- remove the event handler. isRenderingAnimation = false -- set the variable to false, so you can render an animation again. end end function onPanelRegisterButtonClicked( btn, state ) if btn ~= "left" or state ~= "up" then return end if not isRenderingAnimation then animationEnd = getTickCount()+300 -- timeNow + 300 ms = futureTime startRotation = rot1 -- save the start of the animation. addEventHandler("onClientRender",root,changeRotateSmoothFunction) -- add an render event handler. isRenderingAnimation = true -- use a variable to check if you are rendering end end addEventHandler("onClientGUIClick", lu, onPanelRegisterButtonClicked, false)
-
You have to index twice instead of one time. Because you have tables inside a table. local messages = { -- < table 1 {"TEXT1",255,0,0}, -- table inside table 1 {"TEXT2",0,0,255}, -- table inside table 1 {"TEXT3",0,255,0} -- table inside table 1 } local i = 0 function sendNextAutomatedMessage ( ) i = i + 1 if ( i > #messages ) then i = 1 end local content = messages[i] outputChatBox( content[1], root ,content[2],content[3],content[4]) setTimer ( sendNextAutomatedMessage, 150000, 1 ) end setTimer ( sendNextAutomatedMessage, 200, 1 )
-
try something like this: local mapRoot = resourceRoot -- temporary adding to resourceRoot addEventHandler("onResourceStart",resourceRoot, function () local resourceOfMap = export.mapmanager:getRunningGamemodeMap ( ) if resourceOfMap then mapRoot = getResourceRootElement(resourceOfMap) end end) addEventHandler( "onGamemodeMapStart", root, function (startedMap) mapRoot = getResourceRootElement(startedMap) end) function ramp ( thePlayer, commandName ) if ( thePlayer ) then local ramp = createObject ( 1634, 0, 0, 0, 0, 0, 0 ) if ramp then attachElements ( ramp, getPedOccupiedVehicle(thePlayer), 0, 1, 0, 0, 0, 180 ) setObjectScale ( ramp, 0.7) outputChatBox ( "Ramp Added", thePlayer ) if isElement(mapRoot) then local setToParent = setElementParent(ramp, mapRoot) if setToParent then -- debug -- outputDebugString("Set ramp parent successfully!") end end end end end addCommandHandler ( "ramp", ramp )
-
You can cancel the bullet explosion like this: addEventHandler("onClientExplosion",root, function (x,y,z,explosionType) if source == localPlayer and explosionType == 10 then local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle and getElementMode(vehicle) == 432 then cancelEvent() end end end) But how you want to check if it hits an object is up to you.
-
and yes, you can sort by characters/words: outputChatBox(tostring("a" < "b")) -- true outputChatBox(tostring("b" < "a")) -- false
-
local tablex = { [1] = {"900","WonderfulNick52"}, [2] = {"100","WonderfulNick52"}, [3] = {"1","WonderfulNick52"}, [4] = {"69","WonderfulNick52"} } table.sort(tablex, function(a,b) return a[1] < b[1] end) for i=1,#tablex do outputChatBox(tablex[i][1]) end That is because you are using strings, not numbers. 1 100 69 900 So sort it like this: table.sort(tablex, function(a,b) return tonumber(a[1]) < tonumber(b[1]) end)
-
That is: "???" = "aim_weapon" You can find those names on: https://wiki.multitheftauto.com/wiki/Control_names
-
local circleRotation = 21 addEventHandler("onClientRender",root, function () dxDrawImage(689, 280, 116, 115, "circlebar.png", circleRotation) end) bindKey("backspace","down", -- see next line > function (key,keyState) -- key = "backspace", keyState = "down"(if "both" it can be "down" or "up") circleRotation = (circleRotation+90)%360 -- % <<< 456%360 = 96 (removes a value till the rest value remains, which is lower than that ) end) Ik kan het ook op zijn Nederlands/Belgisch uitleggen, mocht je er niks van snappen.
-
local myTable = {} -- Create an empty table. local amountOfItems = #myTable -- # < Will return the highest position in this table. -- When the table is empty it will be 0. -- When there is 1 item in it, it will be most likely 1, but not always when the array/table isn't clean. What is the array? local positionOfLastItem = amountOfItems -- This is most likely the position of the last item in the table. local dataThatIsInside = {345,57567,5777} -- x,y,z This is what you are going to save. local nextItemPosition = positionOfLastItem +1 -- Get the next position in the table, where you want to store your item. myTable[nextItemPosition] = dataThatIsInside -- Saving in the Table. The table will look like this at the end: (in the lua memory) myTable = { {345,57567,5777} } There are also table.insert and table.remove. But those have more functionality. You should first understand the array before you start using those.
-
It belongs to deathreason/weapon 50, which is the same as getting rammed by a car. See deathReasons. Use the event onClientPlayerHeliKilled like GTX said.
-
This function returns somtimes NaN https://wiki.multitheftauto.com/wiki/Ge ... ldPosition in combination with https://wiki.multitheftauto.com/wiki/GetPedTargetEnd There is not much I can do about it Afaik. Also I get sometimes NaN values when I am playing around with vectors of my serverside bullet collision system. (checking the distance between 2 lines in 3D)