Jump to content


  • Posts

  • Joined

  • Last visited

1 Follower

About Investor

  • Birthday 14/04/1999


  • Location
    United Kingdom
  • Occupation
    Student & 3D modeller
  • Interests
    3D modelling, law, computer gaming, game development, level design, etc

Recent Profile Visitors

1,858 profile views

Investor's Achievements


Sucka (13/54)



  1. You're going to need to have the resource bone_attach installed and running on your server.
  2. The easy but inefficient way would be to use element data to sync the list of visible/hidden components. However it is preferable to use events: Have the server authoritatively control which components are visible and which aren't, by sending an event to all clients (or all clients within streaming proximity) regarding any changes in component visibility; and have the server also track these details to send the visiblities data to players connecting afterwards (or entering streaming range).
  3. giveWeapon is server-only. CEF can only trigger to client. You need to bridge the client to the server using a server-event. Taking money from the player should also happen on the server, but you probably shouldn't trust the client to tell the server the price, instead the server should look up the price for a given item independently, in a table stored on the server side. Additionally getPlayerMoney(getRootElement()) should be getPlayerMoney() with no parameters.
  4. The skill value is looked up in the SQL table weaponstats. Since you're already accounting for all the weapon skills possible, let's hypothetically say you want to add stamina stat to this. What you'd do is add a new column in the weaponstats SQL table called "stamina", and then edit this script's skills table by adding [22] = "stamina". The actual value for that stat will be in the SQL table. E.g. owner ak47 m4 ... stamina 23 1000 1000 ... 560 35 600 500 ... 600 So for player with charID 23, the poll[1]["stamina"] will be 560, for poll[1]["m4"] it will be 1000. For charID 35, these will be 600 and 500 respectively. When originally recommending that code, I didn't realise that all the skills were already added, which means you probably won't be adding or removing anything from it, but at least it's still a cleaner code design.
  5. You should show us the code which handles closing whatever it is that disappears forever. Perhaps it uses destroyElement where is should use guiSetVisible.
  6. local skills = { --[skillID] = columnName [77] = "ak47", [78] = "m4", [69] = "pistol", [70] = "silencedpistol", [71] = "deagle", [72] = "shotgun", [73] = "sawnoff", [74] = "spas", [76] = "mp5", [79] = "sniper", } local owner = charID dbQuery( function(qh) local poll = dbPoll(qh,0) local row = poll[1] if not row then return false end -- don't continue if poll[1] is empty (no rows found in weaponstats for this owner) for skillID, columnName in pairs(skills) do -- iterate the table defined above whose key-value pairs are [skill ID] = table column name setPedStat(player, skillID, row[columnName]) end end, {},connection,"SELECT * FROM weaponstats WHERE owner=? LIMIT 1", owner ) This is a little cleaner and more maintainable design. If you add more columns in your weaponstats db-table, all you have to do is update the skills table.
  7. dbQuery(function(qh) local poll = dbPoll(qh,0) for _,v in ipairs(poll) do local ak47 = v["ak47"] -- first of all, this is defined locally to this scope only so it doesn't exist outside the anonymous function(qh) end owner = 1 -- this definition seems very out of place. It should come before dbQuery as it's used in it's parameters end,{},connection,"SELECT * FROM weaponstats WHERE owner=?",owner) setPedStat(player, 77, ak47) -- this executes right after dbQuery but before the dbQuery's callback function, hence ak47 is not defined The solution could look something like this local owner = 1 dbQuery( function(qh) local poll = dbPoll(qh,0) for _,v in ipairs(poll) do -- if the poll result only has one row, it would be better to use local ak47 = poll[1]["ak47"] instead of this loop local ak47 = v["ak47"] setPedStat(player, 77, ak47) end end, {},connection,"SELECT * FROM weaponstats WHERE owner=?",owner)
  8. Presumably you have a line that goes something like this local itemsTableState = getElementType(unknown_variable) well, you need to add local clickedElementModel = getElementModel(unknown_variable) and then elseif itemsTableState == "object" then if clickedElementModel == 2332 then -- if the element model is a safe tabStartX = drawCategoryTab(tabStartX, tabStartY, "main", "safe", "Safe") end end But you haven't provided enough lines for me to know what is the name of the variable storing the clicked element, so I've named it unknown_variable here.
  9. Investor


    If you mean how many hours have passed since a player was last online, all you have to do is store a timestamp when he quits or logs out (via setAccountData perhaps) and compare that to the current timestamp to get the number of seconds passed, from which you can easily calculate the number of hours.
  10. doesn't seem to appear in the provided script, which could mean encoding problems. Anyway, while checking the code I also found it to contain a couple U+FEFF characters (ZERO WIDTH NO-BREAK SPACE). The bytes 0xFEFF are apparently also used by UTF-8 for BOM (Byte Order Mark) which could be part of encoding issues, perhaps. Best would be to simply filter out invisible and special characters which shouldn't be there.
  11. The difference is that only a player can issue a command, though an event's source could be any element type. This is why the wiki uses 'player' for command source variable, but you're free to use whatever name you want.
  12. Wrong section I think. Modelling would be more appropriate.
  13. dutyAllow[key] is a nil value (doesn't exist). You probably wanted dutyAllow[k]
  14. XML is only useful for configurations which you want to be able to change through a normal text editor, but even for that case, JSON is probably faster and easier. SQL is best for pretty much anything else.
  • Create New...