Jump to content

Addlibs

Members
  • Posts

    1,060
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by Addlibs

  1. He's not looking for RGB to Hex anymore — He wants to make colours smoothly change from one to another on team color (or at least that's what I understood. Read the full topic.
  2. if message:sub(1,1) == "/" then -- if message proceeds a forward slash (i.e. message is a command) local command = message:sub(2) local command = split(command, " ") local cmd = table.remove(command, 1) -- returns and removes the value on key 1 executeCommandHandler(cmd, thePlayer, unpack(command)) -- this won't work for commands like /login, /logout, /quit, /reconnect, /name etc return 0; --stop function here end executeCommandHandler […] NOTE: You can only execute commands created by Lua. You cannot execute MTA harcoded commands due to security reasons. — executeCommandHandler
  3. Are you sure it's named 'sql' and it is running for sure? The error message clearly states it isn't running.
  4. One memory address is a bit-sized. Therefore, after you exhaust all 64 bits, it resets and starts overlapping the old ones that are no longer needed, I think? This would be an explanation as to why ≈70 (64 ≈ 70±6) is the number where it starts overlapping. I think this is hardware-related, as on the http://www.lua.org/cgi-bin/demo site, it starts repeating near ≈106. (Yep, had to extend the for i loop as it didn't catch any conflicts with the original code) It might also be possible that previous tables change their memory address at one point to free up space for others. Therefore a new table might be assigned an address that was once used but isn't in use anymore. http://www.cplusplus.com/forum/beginner/134971/ — even though it's not directly about Lua, I think we can safely assume Lua acts the same way because of the OS.
  5. Dude, the only time you try to use 'source' is in getPlayerName and getPlayerNametagColor. Is that a coincidence that the WARNING message occurs only on those lines? (The ERROR message occurs because getPlayerNametagColor fails)
  6. You can write like about 3 lines of code and you'll have delta time onClientRender. Anyway, onClientPreRender isn't a bad solution either, so it's ultimately your choice which one you'll use.
  7. I'd do it onClientRender with math or interpolation (getEasingValue or interpolateBetween).
  8. That is not a colour but a sequence of different colours.
  9. source is not defined. You're probably not using an event to call the function 'Local'
  10. Addlibs

    [HELP] Trigger

    You can't cancel a custom event (unless you write code to support that). Also, I don't think it's possible to cancel a remote event (i.e. from client to server or vice versa)
  11. change 'fire' to 'hitElement' in all three getElementData
  12. if x2 and y2 and z2 then if getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) > 10 then outputChatBox("Are not fire.", 255, 0, 0) count = 0 cooldown = setTimer(resetCooldown, 5000, 1, false) else count = count + 1 if (count==20) then count = 0 cooldown = setTimer(resetCooldown, 30000, 1, false) triggerServerEvent("cancelrandomfires", localPlayer) end end end
  13. It's a hexadecimal memory address reference
  14. You're hitting an element that is not a player but neither a fire (hence x2, y2 and z2 are false, a boolean value). You should check if x2 and y2 and z2 then before proceeding to getDistanceBetweenPoints3D.
  15. To use this as a standard function, you'd most likely need to use coroutines. I know for sure that it is possible but I don't know how to do that myself. Because requests through callRemote aren't instant, a callback function is called when the result it ready (a bit like dbQuery). Thus, your custom getPlayerMoney() would trigger the query but the actual result will come at a later stage. A coroutine would allow you to pause the execution of the function until the result is ready, but I do not know how to do it technically. I'd stick to the internal money system, and extend it with functions like setMoneyFromDatabaseForAllPlayers (or preferably a shorter function name) which would request money for every online account and set it when the results arrive.
  16. stopResource(getResourceFromName("earth"))
  17. callRemote("[Link]", callbackFunction, "databaseExec", "UPDATE `mvp_core_members` SET `somecolumn`='somedata'")
  18. else if (isset($input[0]) && isset($input[1]) && $input[0] == "databaseExec") { // this is the first line of the addition Oh whoops - auto-corrector mistake, it should be 'elseif' not 'else if'
  19. Depends if you want to secure the whole code from external IPs or just the update database queries. I'd put it around the whole code, that is, just after <?php and ending just before ?>, just for safety.
  20. It might be unguessable, but I think it is somehow possible for a ‘Man in the Middle’ to sniff out traffic and see where your server may be connecting to, and get the URL. I have no idea how easy it might be to do and if it's even possible without control over the network of either remote machine. Regardless, it's always safer to verify the IP which is connecting. (Check the edit on my previous post)
  21. You'd probably want to add ... mta::doReturn(false, 2); // Account not found } } // previous code ends here elseif (isset($input[0]) && isset($input[1]) && $input[0] == "databaseExec") { // this is the first line of the addition mta::doReturn(mysqli_query($conn, $input[1])); } In this case, you'll be able to specify your own SQL statement, such as UPDATE `mvp_core_members` SET `somecolumn`='somedata' . This code would be called in the following way: callRemote("[Link]", callbackFunction, "databaseExec", yourSQLstatement) However, I'm not very sure about the security of this. If someone found out the PHP link, they'd be able to run any query on your database schema without logging in (since the PHP does that for you) EDIT: If you use if ($_SERVER['REMOTE_ADDR'] == "IP of the server on which MTA is running") { // code} then only your server will be able to execute the PHP.
  22. Yeah, OR use this query: $sql = "SELECT * FROM `".$table."` WHERE `".$accountColumn."`='".$input[1]."' LIMIT 1"; // instead of $sql = "SELECT * FROM `".$table."` WHERE `".$accountColumn."`='".strtolower($input[1])."' LIMIT 1";
  23. // Edit: $sql = "SELECT * FROM `".$table."` WHERE `".$accountColumn."`='".strtolower($input[1])."' LIMIT 1"; […] mta::doReturn(true, 0, $row); // Password correct This will send all of the row data as the 3rd parameters of the callback function, as a Lua table (you don't have to convert from JSON). Example: callRemote("[Link]", function(success, extra, data) if success == true then -- if passwords match (the 3rd parameter “data” isn't sent over otherwise) outputDebugString(data['email'])) --this will output the data under column 'email' in that database table end end, "verifyPasswords", username, password)
  24. Change the SQL query to select all columns (SELECT *) and then in the logon successful mta::doReturn add more arguments in the format $row['columnName'] add another argument, $row. They will be sent over as additional parameters to the callback function in Lua. Also, nota bene that column 'name' (which you're using) stores a case-sensitive username, and my PHP transforms the input into lowercase. Either use 'members_seo_name' or remove strtolower() // don't remove what's between the brackets from the query in the WHEN part of the statement.
×
×
  • Create New...