Jump to content

Lordy

Members
  • Posts

    290
  • Joined

  • Last visited

Everything posted by Lordy

  1. Indeed, lua is a case sensitive language. Look closely at line 10 and for example the previous line. I know I wrote carcount, but I'm sure if you actually LOOKED, you'd find the error at line 10. I'm not here to fix uppercase/lowercase stuff for your script, you have to do something yourself aswell.!
  2. Now you removed car[source][carcount] = {} You need to have BOTH
  3. Well look what conditions you're giving.. - Name is kinda ok, you wouldn't want anything below 1 character. - weightInput has to be more than 50 characters and less than 150 kg.. Why? Maybe you you meant also tonumber not string.len in that conditional. - for heightInput, do a outputChatBox(heightInput) to see what values are returned. And check if they fit in the conditions. If they fit, then something is wrong with elseif conditions, if not then something is wrong with the gui edits.
  4. That is.. most interesting. So you take some input from client, convert it into a txd with some funky stuff and fileWrite, change meta.xml and load it as a txd? That's REALLY awesome
  5. Lordy

    admin only

    @[DMC] It's not like you write something and if it doesn't work out from the box, you just dump it here. Please read the wiki article on debugging. If you had any idea what you were doing, you would have seen that at first the script wouldn't have loaded because syntax errors. Then you could have fixed the missing 'end'. Then it would have told you that there is something wrong on line two. You should have seen that you have no thePlayer variable declared anywhere. Could have fixed that yourself and saved a lot of time. Yours aswell as ours. The debugscript and error messages aren't just some random "it throws an eror! attmept to balha blah help me". All the error messages are very descriptive and helpful for debugging.
  6. Lordy

    timers

    Here is what happens if someone writes /mario - It looks for command handler /mario and which function should it call now - finds function displayPic - creates NavmanPlate image - moves it to back And nothing else happens. If you want it to hide after 28 seconds, you need to call the hiding function with a timer. For example function displayPic() if not navmanPlate then -- a little protection against creating multiple instances of the same image. Create a new image only if there is none created navmanPlate = guiCreateStaticImage(0, 0, 3.248333333333, 0.548333333333, 'files/funny.png', true, nil) -- create it else -- if one is already created, just set it visible guiSetVisible(navmanPlate,true) end guiMoveToBack(navmanPlate) -- move back setTimer(guiSetVisible,28000,1,navmanPlate,false) -- calls guiSetVisible(navmanPlate,false) in 28 seconds. end addCommandHandler("mario",displayPic)
  7. function myPosition(player,command) local file -- Just make the file variable local to the function scope. We don't have to assign anything to it though if fileExists("output.txt") then -- Check if the file exists file = fileOpen("output.txt") -- If it does, open it with read & write access else -- If it doesn't file = fileCreate("output.txt") -- create the file end fileSetPos(file,fileGetSize(file)) -- set the read/write position to the end of file. fileGetSize effectively returns the number of bytes from the start of file to the end local x,y,z = getElementPosition(player) -- get the position of the player fileWrite(file,("%s, %s, %s \n"):format(x,y,z)) -- now we write it into the file. Formatting strings is another way to add different strings up. Search for StringLibraryTutorial on lua wiki for more information. \n is a newline. It actually is string.format("%s, %s, %s \n",x,y,z), but it can be shortened to the form which I wrote before fileClose(file) -- Close the file. fileClose also automatically saves the file. end addCommandHandler("mypos",myPosition)
  8. in that case use outputConsole and copy from there (f8, select text, ctrl-c), no hassle with any files
  9. Why do you need it?
  10. Before car[source][carCount] = {} you need to have car[source] = {}
  11. First question: What doesn't work? What errors, where. Second question: What is the point of the while loop
  12. "doesn't work" as in? And why do you need to have the while loop there anyway?
  13. Is the concept really that hard to grasp? Now you don't declare the carCount[source] table anywhere. If you have something like tablea[b][c][d] = randomstuff then you need to make sure that - tablea is a table - tablea is a table - tablea[c] is a table That explains better?
  14. I don't see the taxiCalls table being initiated anywhere... Also, I don't see taxiCalls[newCallsInd] being initiated anywhere. You need to have taxiCalls[newCallsInd] = {} before taxiCalls[newCallsInd][1] = thePlayer
  15. Does this happen on the createVehicle or on the setElementData line? You obviously have to change the tables there aswell, as there is no table called car[carCount] anymore. You have to change them everywhere to car[source][carCount]
  16. 0.1 released. Can be found here EDIT: Can this be moved into Resources section?
  17. oh well yes, you need to initiate car[source][carCount] as a table aswell. The error message is very descriptive, it's not just some blah blah. Attempt to index a field "?" (a nil value) You should understand from that that it attempts to do something like randomtable[nil] = blah car[source][carCount].car = createVehicle() There is the [carCount].car the nil value, as car[source][carCount] isn't a table, because you haven't initiated it as a table.. A bit my fault too though, forgot to add car[source][carCount] = {} in my example. @varez That's just not needed, if he defines it local there, it's local to the file scope, shouldn't have anything to do with the attempt to index a field "?" thingie.
  18. When you initiate the table like taxiCalls = {{Element,X,Y,Z}} it's the same as doing taxiCalls = {{[1] = Element,[2] = X,[3] = Y,[4] = Z}} So there is no table key Element. That's why it's says attempt to index field ? Change while( taxiCalls[newCallInd ]["Element"] ~= nil )do to while( taxiCalls[newCallInd ][1] ~= nil )do Then you actually call the index [1] which returns the element.
  19. The problem is that you have one array, called car. Each time someone creates a car, the same array gets modified. What you should do, is have the array like car = {} -- in function car[source] = {} car[source][carCount].car = createVehicle() So each player would have a separate table for their cars. Don't forget to clean the car table after player leaves though.
  20. According to wiki onPlayerChat event has two parameters. And when cancelling the event So all you have to do is attach a function to "onPlayerChat" event and check, if the messageType is 1, cancel the event. I'm not going to show you the exact code, as it's better for you if you manage to script it yourself.
  21. Lordy

    Next question

    What makes you think that? If he couldn't find the 3D function from the wiki, why do you think he had been able to find the 2D function? Also, I didn't post just to be a smartass, but in case someone else actually does use search and then stumbles here in this thread, where he can read of both 3d and 2d distance calculation. Your post however (and I have to admit, this mine aswell) on the contrary are quite useless.
  22. umm I don't think I could make it like in your second snippet. There is no way of creating a shared variable over all resource iirc. I can't declare HELLO_WORLD in one resource and then use it in another. If one wants to use it, he has to declare it himself like HELLO_WORLD = exports.translator:getString("HELLO_WORLD") -- somewhere later outputChatBox(HELLO_WORLD) But I can think of no way to directly declare global variables for all resources without modifying the resources themselves. Might do something like this though <lang name="English"> <string id="HELLO_WORLD">Hello world!!!</string> </lang> --in translator -- strings are stored in a table -- strings[resourcename][stringid] = "STRING" function importStrings(resourcename) if not resourcename then resourceName = getResourceName(sourceResource) end return strings[resourcename] end -- in some other resource language = exports.translator:importStrings() outputChatBox(language.HELLO_WORLD) But I see no way past the exporting with a function part.
  23. Well I'm taking my time thinking about this one.. Also, I think I have to consider the things stated in Multilingual MTA threadhttps://forum.multitheftauto.com/v ... 02&t=28215 .. Is this resource really worth the hassle?
  24. Lordy

    Next question

    and if you don't care about the z-distance (when on ground, it usually doesn't matter), it's faster if you just use x and y and getDistanceBetweenPoints2D
  25. Rodeggo is a resource to help you translate your gamemode, you just define the strings for each language at definitions.xml and then use them inside your resources. The resource can be found here
×
×
  • Create New...