Jump to content

churchill

Members
  • Posts

    129
  • Joined

  • Last visited

Everything posted by churchill

  1. they'd have to be pretty large colshapes, wouldn't they? but I guess you're right.
  2. Why not do what I suggested in the meantime, if it's possible, fade the camera, move the player and his vehicle to the nearest garage, spawn a recovery vehicle alongside it, and fade the camera back in to make it look like someone came and brought you and your vehicle to the nearest garage?
  3. http://www.lua.org/download.html ? What exactly are you trying to do? If you just want to script LUA for MTADM, then you don't need to download anything other than the MTADM Server. LUA scripts can be written in notepad, textpad, notepad+ (recommended) or any other text editor?
  4. https://community.multitheftauto.com/index.php?p= ... ils&id=203 This is mainly a replacement for the buggy getAccountData/setAccountData, but can also be used for storing data against other objects as well. Data can be stored in SQL or XML, which is configurable by the admin user using a console command (/datamanager XML or /datamanager SQL, while logged in as admin.) This might be useful to anyone who wants to do simple data storage along the lines of getAccountData/setAccountData without the fear of losing data when the server shuts down, but can't be bothered creating their own SQL Lite or XML system. When in XML storage mode, there are no checks to ensure your object and keys are named in a valid way for XML, so just don't do it! I know I should add some validation on the data being entered to ensure it doesn't happen, but for now just read up on XML element naming rules to find out what the rules are, or leave it in SQL mode if you have any bug reports or suggestions, feel free to post in here or comment on the resource in the resource library. Available exported functions (also available in HTTP): getData(objectid, key) returns false if an object/key can't be found, or a string value if it can. setData(objectid, key, value) returns false if the value couldn't be added/updated, or true if successful. removeData(objectid,key) returns false if the key could not be removed, or true if successful. I created the following code in another resource called "DMTester" to run the XML and SQL tests, it might be useful to look at if you plan to use this resource. There's also an example in the readme.txt file that comes with the resource. resourcename = getResourceName(getThisResource()) -- ensures that our data doesn't overwrite some other resources data tablename = "Players" uniqueplayerid = "1" -- ordinarily would be a player's account name, so that it's unique to that player -- this ensures that what we're storing is going to be unique to our resource, storing player data for player 1. uniquename = resourcename .. "_" .. tablename .. "_" .. uniqueplayerid keyfield = "money" -- we're going to store the bank balance for player 1. -- reduces the call line size a little function DMcall(functionName, name, key, value) return call(getResourceFromName("datamanager"), functionName, name, key, value) end function doTests() -- Check for data for first time outputChatBox("first test - check for data ('" .. uniquename .. "','" .. keyfield .. "')") result = DMcall("getData", uniquename, keyfield) outputChatBox("data exists = " .. tostring(result)) -- Write Data first time outputChatBox("second test - write data ('" .. uniquename .. "','" .. keyfield .. "','0')") result = DMcall("setData", uniquename, keyfield, "0") outputChatBox("test result = " .. tostring(result)) -- Check data value has been inserted outputChatBox("third test - check for data ('" .. uniquename .. "','" .. keyfield .. "')") result = DMcall("getData", uniquename, keyfield) outputChatBox("data exists = " .. tostring(result)) --Update value outputChatBox("fourth test - write data ('" .. uniquename .. "','" .. keyfield .. "','500')") result = DMcall("setData", uniquename, keyfield,"500") outputChatBox("test result = " .. tostring(result)) --Check data value has updated outputChatBox("fifth test - check for data ('" .. uniquename .. "','" .. keyfield .. "')") result = DMcall("getData", uniquename, keyfield) outputChatBox("data exists = " .. tostring(result)) --remove data value outputChatBox("sixth test - remove data ('" .. uniquename .. "','" .. keyfield .. "')") result = DMcall("removeData", uniquename, keyfield) outputChatBox("test result = " .. tostring(result)) --Check data value has gone outputChatBox("seventh test - check for data ('" .. uniquename .. "','" .. keyfield .. "')") result = DMcall("getData", uniquename, keyfield) outputChatBox("data exists = " .. tostring(result)) end addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()),doTests)
  5. I know DP3 has functionality to return the child nodes of a given node, but I need a DP2 solution to checking whether a node has children or not. e.g. would xmlFindSubNode(node, "",0) return the first node that it came across regardless of what it was called? Otherwise it means me re-working some code so that all the nodes are named something like "data" and then have the key as an attribute instead of the tag name, e.g instead of: <data> <someKey>value</someKey> </data> it would have to become: <lotsOfData> <data key="someKey">value</data> </lotsOfData> Which would make the script slower in other places, as I could no longer find the right node value simply using: node = xmlFindSubNode(someXMLfile, "someKey", 0) if (node ~= false) then nodevalue = xmlNodeGetValue(node) end I would have to do this instead, which will be a lot slower when using lots of data: node = findNode(someXMLfile, "someKey") if (node ~= false) then nodevalue = xmlNodeGetValue(node) end function findNode(parentnode, key) i = 0 node = xmlFindSubNode(parentnode, "data", i) while (node ~= false) do nodeKey = xmlNodeGetAttribute(node, "key") if (nodeKey == key) then return node end i = i + 1 node = xmlFindSubNode (parentnode, "data", i) end return false end
  6. but that would be useless, mta already bans by ip and both those information are changeable. but u already know that, hmm. Well it wouldn't be a permenent ban like serial banning is, but it would hopefully provide enough of a deterrant to cheaters etc if they have to go to the trouble of getting a new IP and account before they can continue to cause problems on the server, so it's better than nothing.
  7. lol. I fixed it!! I typed the Wrong lol! good stuff. So now you know how to create script files and add them to your meta file, next step is fixing those script errrors. Assuming you've created an admin user for youself as part of setting up your server, the following will come in very handy: login username password -- to login as your admin user debugscript 3 -- turns on error messages and tells you where the problems are cleardebug -- clears the debug output ready for running your script again. the map file that people are advocating is great when you want to spawn your vehicles in a fixed location when the server starts, but if you want your vehicle to spawn next to a player when they type a command or push a gui button, you'll still need to script it, so you're on the right track.
  8. ..you have a resource which writes to an xml file, and two clients trigger the xml writing function at the same time? is MTA intelligent enough to queue them up and do both changes in a row, or does one get "deadlocked" and return a false result back for the XmlNodeSetValue call? and if so, do you put it in a while loop so that it keeps attempting to write the value until it returns true?
  9. those damn serial problems are probably causing havoc on many servers and scripts right now
  10. Didn't you just read the scripting introduction? This reply might seem a bit long, but it's worth you reading it, as hopefully it'll explain things a bit clearer so that you can understand why you're doing what you're doing, rather than me just give you a one sentence answer that doesn't really make it clear what you're actually doing. When you're writing scripts, you can call them whatever you want, and put them in any folder you want, whether it's the root of your resource or a subfolder. So say, I've got a new resource I'm creating called "myleetrpg", and I've created a folder under the resources folder, and created a meta.xml file in that folder, I'd have something like this: resources/myleetrpg/ -- the resource folder resources/myleetrpg/meta.xml -- the meta file associated with this resource, making sure the info details are correct inside this meta file. now I want to create my first script - let's call it "myfirstscript.lua". Note that it can be whatever you want to call it, but it makes sense to call it something that you can later identify it. So, if you're working on some code for your gamemode that handles vehicle spawning, you might call it "vehiclespawning.lua". Now, as to where you need to put it, you can either put it in the root, alongside the "meta.xml" file (remember in the introductory tutorial it says to do this with your first test script it asks you to create?) or you could put them into a subfolder. Generally you would create a subfolder if you want to separate your clientside scripts from your server side scripts, so that you have: resources/myleetrpg/ -- the resource folder resources/myleetrpg/meta.xml -- the meta file associated with this resource, making sure the info details are correct inside this meta file. resources/myleetrpg/client/CodeThatHandlesSomethingOnTheClientSuchAsGUIBuildingForAVehicleSelectorWindow.lua resource/myleetrpg/server/vehiclespawning.lua -- this handles the server side code that will be run when the vehicle selector window has been used by a player. or if you wanted to you could dump everything in one place like this: resources/myleetrpg/ resources/myleetrpg/meta.xml resources/myleetrpg/CodeThatHandlesSomethingOnTheClientSuchAsGUIBuildingForAVehicleSelectorWindow.lua resources/myleetrpg/vehiclespawning.lua but doing it this way makes it harder to find what you're looking for when you have lots of scripts in there Another way of separating things is to put a _c at the end of your script, such a "vehiclespawning_c.lua" to indicate it's a client side script, or "c_vehiclespawning.lua" if you want to group all your clientside scripts together when viewing the folder. Finally, if you have lots of scripts associated with particular functionality, you might even do something like this: resources/myleetrpg/ resources/myleetrpg/meta.xml resources/myleetrpg/vehiclespawning/vehiclespawning_c.lua resources/myleetrpg/vehiclespawning/vehiclespawning.lua meaning I've put all my vehicle spawning scripts into one place. again, if I had lots of scripts associated with a function, I'd probably add another sub folder to further group things together: resources/myleetrpg/ resources/myleetrpg/meta.xml resources/myleetrpg/vehiclespawning/client/vehiclespawning_c.lua resources/myleetrpg/vehiclespawning/server/vehiclespawning.lua summary: you can name your scripts anything you want, and put them anywhere you want, but it makes sense to keep things that are related together in some way! And now for the important bit: Whatever you call your files and whatever folder structure you choose to keep them in, your meta.xml must contain a reference to the scripts. In your meta.xml file for your resource, you would have something like this, depending on where you've put it and what you're calling it:
  11. this page has all you need to know about spawning vehicles: http://development.mtasa.com/index.php? ... ateVehicle and a list of vehicle ids are here: http://development.mtasa.com/index.php? ... ehicle_IDs But the next question is, how many vehicles are you planning to spawn, and are planning to spawn them in fixed locations, randomly or where the player is when he requests a vehicle?
  12. Here's an updated list of heavily anticipated RP(G) servers on MTA, in various states of completion SAES (http://www.saesrpg.net/) - Judging by the features listed on their forum as "already thought of, and in v2", this one is looking highly likely to be the the top dog. Argonath (http://www.argonathrpg.eu/) - judging by the feature set of the SA-MP version, if they can recreate this one in MTA it could be one of the better ones. Venturas Nights (viewtopic.php?f=87&t=23291) - Nothing known about this one at the moment, other than it's been in progress for 6 months, so hopefully there'll be something worth shouting about eventually. Simbad De Zeeman - (http://38.103.164.118/~simbadde/gamemode.html) - Hopefully SDZ has plans to build on this server and add further features because some of the work on there is pretty good. Another another one that sounded promising (viewtopic.php?p=281678#p281678), described by Moenski, but other than a few features listed, nothing really known about it. and what happened to the MTA-RPG site that I read in one old forum post? It appears one or two of the MTA QA Team were in that project, but I think they are now part of SAES? Dropped from the list: * Godfather (viewtopic.php?f=87&t=22852) seemed to die just as quickly as it was announced, and the URL in the thread now links to a rather suspicious website these days.
  13. one step at a time, eh? he's only just getting into scripting
  14. and when you've done all this, you'll probably want to refactor your code a little into functions that do a specific thing and reduces duplicate code, e.g. in the example above, you might change it to something like: function iDontKnowWhatKindOfFunctionNameYouWantSoLolIllMakeAVeryShortFunctionNameCuzYouDeserveItDoYouSee() giveWeaponsToPlayer(source, getPlayerTeam(source)) end function giveWeaponsToPlayer(thePlayer, theTeam) if (theTeam == teamCops) then giveWeapon ( thePlayer, 31, 10000 ) giveWeapon ( thePlayer, 24, 10000 ) giveWeapon ( thePlayer, 25, 10000 ) giveWeapon ( thePlayer, 29, 10000 ) giveWeapon ( thePlayer, 17, 10000 ) giveWeapon ( thePlayer, 42, 10000 ) -- add more if statements here to handle the various teams end end addEventHandler("onPlayerWasted",getRootElement(),iDontKnowWhatKindOfFunctionNameYouWantSoLolIllMakeAVeryShortFunctionNameCuzYouDeserveItDoYouSee) which would mean in your original function "assignCopTeam", you could also do this: function assignCopTeam ( player, commandName ) setPlayerTeam ( player, teamCops ) giveWeaponsToPlayer(player, teamCops) setPlayerSkin ( player, 280 ) setElementPosition( player, 1552.4109, -1675.0485, 16.1953 ) outputChatBox( "You are now logged in as a Los Santos Police Department officer", source, 0, 255, 0 ) setPlayerNametagColor ( player, 101, 101, 215 ) end Much neater, isn't it? Hopefully you get the idea of why re-factoring your code is a good thing
  15. he would have already done that as part of the instructions under "Identifying your resource".. he's referring to this article: http://development.mtasa.com/index.php? ... ple_script
  16. What that means is the MTA Server.exe file that is in the root of your MTADM folder, wherever you installed it to. IDK what that means neither. Was I suppose to make another file as Meta or something? If U can explain all of this 2 me that will be great. Thanks!! It's missing a word. It should read "Therefore we'll create the file in the SAME folder as meta.xml." The file they want you to create will be called "script.lua", copying and pasting the code that followed.
  17. Lol, thank you. Thats sad. I could place a Gui over the clock, but i want to set the Gui's Alpha ^^. So it wouldnt look good if there is a clock in the background.-. separate gui elements can have different alpha settings can't they? if so, just make the rest of the gui with alpha transparency, but in that top right hand corner, make it solid. if it's done in the right way, it could still look pretty neat...maybe?
  18. How come? I prefer MySQL because the SQLite implementation is too basic for my likings and XML just sucks for dynamic data management. +1
  19. Um, can I just say that this isn't my script? it's [uVA]Barts! I've not actually attempted to run this script yet, so I wasn't aware that there were even any errors in it A working Fuel management resource is on my to-do list - that handles just the fuel management aspect of it and nothing more, but whether that involves taking an existing resource and reworking it (with permission of course) or just writing my own, I've not decided yet. I'm keen to do it in such a way that it let's the money and player data management get handled by a separate resource that you can define in the config of the fuel management resource. This is all in my head at the moment - whether what I'm talking about is actually a feasible solution is another matter. Needs more thought before I begin work on it, but I'm also working on some other little bits and bobs that hang together right now, so it might take a while before I do anything that I can release for public use.
  20. first bug reported: triggering the report made it appear on ALL connected clients, not just for the person who pressed the button. Silly n00b mistake This has now been fixed as of v1.0.1, which is now available in the resource library.
  21. should be: function assignNewTeam ( source, commandName ) setPlayerTeam ( source, teamCops) -- the team "Cops" doesn't exist according to your code, teamCops does, however. end addCommandHandler ( "command", assignNewTeam ) -- if "command" is what you type in the console, in order to activate the function, shouldn't the word be more be something more descriptive such as "assignToCops" ?
  22. onClientClick is supposed to return an element that was clicked on. the element can supposedly be any physical entity (such as Player, Vehicle, Object, Pickup, Marker, Blip, Radar Area), and yet if I click on a pickup, I get false. Clicking on myself gives me "player", so it must be working? Whereas if I use createObject instead of createPickup, I can click on the object and it returns "object", which is correct, but the downside is that it seemed to render the object equivalent smaller than the pickup equivalent! in my test I was using the dollar sign (1274)
  23. Having been researching in the wiki and in the forum, I've noticed a couple of threads that indicate problems with SQL Lite, namely the ExecuteSQLQuery bug, mentioned here: viewtopic.php?f=95&t=23018 That's a pretty big obstacle in the way of doing some things, as some of the ideas I've got would probably require (well, not so much require, more best practice) multiple tables, and using inner joins to link IDs in one table to a primary key in another table. for example, not that I'm actually doing this in my idea, I'm just using the structure as an example: Table 1: PickupLocations PickupID INTEGER PRIMARY KEY X INTEGER Y INTEGER Z INTEGER PickupTypeID INTEGER Table 2: PickupTypes TypeID INTEGER PRIMARY KEY TypeDescription TEXT so that you can do a query like: "SELECT X, Y, Z, PT.TypeDescription FROM PickupLocations PL INNER JOIN ON PL.PickupTypeID = PT.TypeID" Without ExecuteSQLQuery, doing an inner join like this would be pretty much impossible, wouldn't it? So, I now seem to have 3 options, and would like advice, as usual! 1) Avoid best practice, and have the descrption in the Pickup Locations table, thus reducing the need for inner joins, and be able to use executeSQLSelect instead, but potentially causing more problems with inconsistent naming, etc. 2) is XML flexible enough to do something like that? how difficult would it be to return a result like the one in the sql query, if the data is stored in two different xml files? or do I avoid the idea of "best practice", and do what I suggested above, but stored in XML instead of SQL? 3) Is one of these modules the answer? http://development.mtasa.com/index.php? ... /MTA-MySQL or http://development.mtasa.com/index.php? ... ules/MySQL ? I'm still convinced that SQL is preferred when talking about the potential for a fair bit of data manipulation, whereas XML is best for reading more static content, but would love to know if there are any figures that prove one way or another whether SQL or XML is best suited for a particular use.
  24. https://community.multitheftauto.com/index.php?p=resources&s=details&id=199 My first attempted resource/script - something basic, but might be useful to others. I've noticed that most weather scripts seem to be a bit basic in that they just randomly change the weather at a fixed time. Sometimes they go one step further and change it at a random time. What this resource does is attempt to mimic weather patterns by setting today's weather but also pre-defining potential weather for 2 days ahead, for both the day and night weather. When the weather updates each day it's based on these pre-defined "predictions". As with real weather, it's not 100% accurate - sometimes the weather prediction can be wrong for the days ahead when we actually get to tomorrow or the next day It is also a little random in that it won't change at a set time every day/night. Day time changes come into effect between 7am and midday. Night time weather comes into effect after 8pm, but before midnight. Included in the resource is weather report window, activated by hitting F5, but that key is defineable in an optional.xml config file, if you unzip the file into a folder. Additionally, the resource has export functions so that you can send weather descriptions (or IDs) for the days ahead to other resources. I can think of one or two examples where you might want to do that, but I'm not going to give away ideas Note: it only uses one timer at any time, but is set 3 times over the course of a 24 minute day, for the midnight update, daytime update, and evening update. Second note: I noticed while testing this that the client time seems to slowly go out of sync compared to the server time. because of this, I've added a setTime(getTime()) at the point of each update, in order to keep the server/client times in sync a bit better. Comments welcome, either here or in the resource comments. Please report bugs, or suggestions for improvements! Screenshots The Today Tab changes slightly depending on the time of day you view it. It displays overnight weather alongside the day and evening weather if you're viewing in the early hours of the morning, or just the night weather if you're viewing it after about 7pm onwwards: The Tomorrow and Day After tabs just show day and night time weather - so they both generally look like this:
  25. Ace didn't give any page link? Mr Hankey did, which was most useful, but from what I can see, that page has no mention of including the helpmanager resource in your meta.xml file? maybe I missed something, but I've not seen it documented on the pages I was looking at. When I was getting errors my immediate thought was that I probably needed to add a reference to it somewhere, as I mentioned in my first post regarding the error - I just needed someone to confirm it
×
×
  • Create New...