-
Posts
740 -
Joined
-
Days Won
16
Everything posted by Tails
-
Sure. Just post the code here, I'll take another look.
-
You're defining the rootNode globally in open() then you'r nilling it in close(), so it will recreate the file everytime. Just change it to local and remove rootNote = nil in close(). Edit: Or just leave it global and remove the line in close(), OR better, return the rootNode in open() and use it to close it: close(rootNode)
-
Everything is explained here: https://wiki.multitheftauto.com/wiki/Meta.xml
-
Yeah, you can export both functions with the same name as long as the functions are present on both the server and client. I did the same thing on one of my scripts before. Nothing wrong with your example.
-
addCommandHandler("k", function(_,...) if #arg < 3 then outputChatBox("Not enough arguments supplied") else local q,a1,a2 = unpack(split(table.concat(arg," ",2),",")) outputChatBox("Question: "..q) outputChatBox("Answer 1: "..a1) outputChatBox("Answer 2: "..a2) end end ,false,false) Usage: /k Is this a question?, Yes it is, No it's not
-
Why not use ... to get the args and play around with them? Here: addCommandHandler("k", function(_,...) if #arg < 3 then outputChatBox("Not enough arguments supplied") else local q = table.concat(arg," ", 1, #arg-2) local a1 = arg[#arg-1] local a2 = arg[#arg] outputChatBox("Question: "..q) outputChatBox("Answer 1: "..a1) outputChatBox("Answer 2: "..a2) end end ,false,false) It does exactly what you're asking. Example: /k Is this a question? yes no
-
A few years ago I was able to this on the EIR branch: The limitations were pretty much the only thing that was holding us back for a long time. We had to wait for MTA 1.4, and we were told that the EIR branch would be merged with the main on a relatively short term. This never happened unfortunately as the development of EIR had stopped and we lost interest in our project as well. While we don't have plans to finish it anymore, I've still been hoping for the developers to continue working on EIR again to atleast increase the limitations in MTA. Technical note: I would use the limit adjuster through MTA's own Lua functions unless there'll be a better way. I don't like players to have to restart the game in order to see the increased limitations or anything. I'd just like to see increased object limits and the ability to add new objects without replacing existing ones. That's my dream for MTA.
-
You can move the colshape before you check the object though: local col = createColCircle(2306.687, -1658.936, 14.386) local object = createObject(737, 2306.687, -1658.936, 14.386) addCommandHandler("c", function() local x,y,z = getElementPosition(col) setElementPosition(col,x,y,z+1) setElementPosition(col,x,y,z) print(isElementWithinColShape(object, col)) end ) I don't really know why it doesn't work normally, MTA is weird.
-
From the wiki: Note: This function can not set more than <maxplayers> as defined in mtaserver.conf. Using https://wiki.multitheftauto.com/wiki/SetServerConfigSetting might work.
-
" < max+1 " lol Use <=
-
local curMaxPlayers = getMaxPlayers() local newMaxPlayers = curMaxPlayers * 2 setMaxPlayers( newMaxPlayers ) Remove the math.ceil when multiplying.
-
New patch released (ver. 1.1.2) (Nov. 26, 2016) This version fixes some bugs that unfortunately came with the last patch Fixed the screen playing videos through youtube.com intead of youtube.tv when being added through the youtube.com browser Fixed time changing when changing settings Some other minor issues fixed Download the latest version here! If you find any more bugs, please report them to us so we can fix them as soon as possible.
-
The text will be shown for 3 seconds (3000 ms). Check the timer function. As for the borders, just play around with the draw functions. All I did was make a copy of the dxDrawText line and add +1 the x,y, width and height. Make another copy on top of it and do -1, then another copy and just do -1 on the y and another one and do +1 on the y. Check this post of mine from 2015: Hope this helps.
-
Replace this in the onChannelSwitch func: playerRadioChannel = getRadioChannelName(station):upper() Put this above the other dxDrawText: dxDrawText ( playerRadioChannel, screenWidth + 1, screenHeight - 155 + 1, screenWidth - 66 + 1, screenHeight + 1, tocolor ( 0, 0, 0, 255 ), 1.5, "bankgothic", "right" )
-
You must use onClientRender to draw the text on the screen, check this out: local screenWidth, screenHeight = guiGetScreenSize () function onChannelSwitch(station) playerRadioChannel = getRadioChannelName(station) if isTimer(switchTimer) then resetTimer(switchTimer) else switchTimer = setTimer(function() playerRadioChannel = nil end,3000,1) end end addEventHandler("onClientPlayerRadioSwitch", getLocalPlayer(), stationDraw) function stationDraw() if playerRadioChannel then dxDrawText ( playerRadioChannel, screenWidth, screenHeight - 155, screenWidth - 66, screenHeight, tocolor ( 135, 96, 45, 255 ), 1.5, "bankgothic", "right" ) end end addEventHandler("onClientRender", root, stationDraw) The render will try to draw the text so long the playerRadioChannel var is a station name. The onChannelSwitch function takes care of that variable plus a timer to remove it. I think it's easy to understand.
-
Oops, some of it was wrong haha -- I changed district[i] to district[i][1], since you're storing the -- colshapes in an array. remove the the {} brackets where you store -- the colshape, then you can do district[i]. Also again, a player check. -- Everything's working now. addEvent("onDistrictChange", true) function districtChangeEvent(hitElement) if hitElement == localPlayer then for i=1,#district do if district[i][1] == source then triggerEvent("onDistrictChange", hitElement, districts[i][5]) end end end end addEventHandler("onClientColShapeHit", root, districtChangeEvent)
-
Change to resourceRoot, player as argument, and renamed test to test2. Might be that test is reserved as a function name. I know you can't use "test" in a commandHandler. triggerEvent("onDistrictChange", resourceRoot, hitElement, districts[i][5]) function test2(player, districtName) outputChatBox(getPlayerName(player).." entered "..districtName) end addEventHandler("onDistrictChange", resourceRoot, test2)
-
Yes, you got the right idea. You just need to pass the district name to the event and preferably the player, either as root or as an argument. triggerEvent("onDistrictChange", source, districts[i][5]) function test(districtName) outputChatBox(getPlayerName(source).." entered "..districtName) end addEventHandler("onDistrictChange", root, test) Also make sure to export it as well <export function="onDistrictChange" type="client"/> Note that this is all client-side, the event is only triggered by the localPlayer and the test func is only being outputted to the localPlayer. You can make it trigger a server event in the test func though. Or you could create an event on the server.
-
function getPlayerDistrict(player) for i=1,#district do if isElementWithinColshape(player,district[i][1]) then return districts[i][5] end end end then <export function="getPlayerDistrict" type="client"/> use it in a different script: local district = exports.resourceName:getPlayerDistrict(localPlayer)
-
function outputDistrictName(hitElem) if hitElem == localPlayer then for i=1,#district do if district[i][1] == source then outputChatBox("Welcome to "..districts[i][5]) end end end end addEventHandler("onClientColShapeHit", resourceRoot, outputDistrictName) Tested and works now.
-
" table expected,got nil " menuNames is nil, meaning it's undefined. Do you have a table by that name somewhere?
-
What about this function outputDistrictName() for i=1,#district do if district[i] == source then outputChatBox("Welcome to "..districts[i][2]) end end end addEventHandler("onClientColShapeHit", root, outputDistrictName)
-
Could be achieved with shaders. Check this out: https://community.multitheftauto.com/index.php?p=resources&s=details&id=7615