Sorata_Kanda

Members
  • Content Count

    69
  • Joined

  • Last visited

Community Reputation

6 Neutral

About Sorata_Kanda

  • Rank
    Snitch

Recent Profile Visitors

185 profile views
  1. Sorata_Kanda

    How to check if argument is empty?

    if argument then end represents if argument ~= nil then end If you'd like to check if it's nil: if not argument then -- Do something end -- or if argument == nil then -- Do something end EDIT: It doesn't matter which of the two methods you choose. As far as I know, the common code style uses if not element then -- Do something end -- etc.
  2. Sorata_Kanda

    Creating global/native functions

    But how were all the functions ported to all LuaVMs? They must have been defined in the source code. So I suspect that you could manage to provide your own functions natively by creating modules.
  3. Sorata_Kanda

    Advertisments PROBLEM !

    Because this looks like the query you sent to your MySQL database doesn't return your values. Did you look up in the debug log files of /debugdb? Send some lines where it occurs.
  4. Sorata_Kanda

    Advertisments PROBLEM !

    Did you make sure the MySQL connection exists?
  5. Sorata_Kanda

    Creating global/native functions

    Hey everyone, I've been wondering if there's a way to create functions that are natively available without using functions exports. I did a little research and found modules which might be suiting in this case. However, I downloaded the SDK and opened it in Visual Studio, and it sort of looks like outdated? So does there a method of creating native functions in Lua exist? If so, how do you do it? Thanks in advance!
  6. Sorata_Kanda

    Advertisments PROBLEM !

    Either way you don't have a connection to your MySQL database or the table/entry does not exist. Use /debugdb and check the MySQL logs for detailed error messages.
  7. Sorata_Kanda

    Override existing functions

    Hey everyone, I'm wondering if you're able to override existing functions. I can image that doing on OOP side, but I don't know if it's possible to do so on a normal function. For example: function _setElementData( player, key, value ) -- Wrapper return setElementData( player, key, value, false ) end Element.setData = _setElementData -- OOP -- But why to do it on setElementData? Just simply setElementData = _setElementData? Thanks in advance!
  8. Sorata_Kanda

    OOP vs element data

    So I sort of managed it like this -- Server races = {} addEventHandler('onResourceStart', resourceRoot, function() -- Query all races from DB for _, race in ipairs(queryResult) do local raceObject = Race.new(race) races[raceObject:getElement()] = raceObject end addEventHandler('onPlayerJoin', resourceRoot, function() triggerClientEvent(source, 'raceUpdateClientTable', this, races) end) end) -- Client races = {} addEvent('raceUpdateClientTable', true) addEventHandler('raceUpdateClientTable', resourceRoot, function(raceTbl) for _, race in pairs(raceTbl) do attachRaceClasses(race) -- See @IIYAMA's example end races = raceTbl end) Any suggestions for improvements?
  9. Sorata_Kanda

    OOP vs element data

    So as I thought, I won't be coming around with storing those objects in a table. I probably have to fill those reference tables at resource start + with event or something. (Aside: Imagine having those objects "stored" in MySQL. I sort of try to avoid double queries for those Race elements as I think it's not necessary)
  10. Sorata_Kanda

    OOP vs element data

    The rendering happens only when you're near the Race elements. So that shouldn't be a problem? But I still need to have a reference to the object when looping through Race elements. And as far as I found out, they don't update either.
  11. Sorata_Kanda

    OOP vs element data

    @IIYAMA But in order to work with onClientRenders so I can display info with 3D Text labels, I need to store each information in elementData, right?
  12. Sorata_Kanda

    OOP vs element data

    Wow, I wish I'd come up with such a simple solution easily. Thank you very much
  13. Sorata_Kanda

    OOP vs element data

    Because you mentioned using elementdata non-synced: Would it still make sense to create an element called 'Race'? I did that because I'd like to get later on all races by: for i, race in ipairs(getElementsByType('race')) do -- do stuff here end Or is there another elegent solution?
  14. Sorata_Kanda

    OOP vs element data

    Ah, okay. Thank you. Asking for a small piece of advice: Would you stick with oop in this case or rather use setelementdata to store title and stuff?
  15. Sorata_Kanda

    OOP vs element data

    Well, how do I do it?