scaryface87 Posted November 2, 2015 Share Posted November 2, 2015 Hello , I would like to know how to assign an ID starting from 1 to unlimitedd. For example if person got ID 1 then the next one requesting an id will receive ID 2. I would like to do this with setElementData Thank you in advance Link to comment
Gothem Posted November 2, 2015 Share Posted November 2, 2015 https://community.multitheftauto.com/index.php?p= ... ils&id=953 https://community.multitheftauto.com/index.php?p= ... ls&id=2322 there you have two resources that make what you want. Link to comment
scaryface87 Posted November 3, 2015 Author Share Posted November 3, 2015 Hello , this isnt rlly helping me out as im not understunding it properly. So i wanna try to make aanother thing for : function numberup() number = +1 -- this is wrong i know outputChatBox("".. number .."") end addCommandHandler("number",numberup) What it should do : after doing /nextnumber it should do +1 from the previous number so if player 1 uses /number then it says 1 then player 2 will use /number , then it"ll say 2 Link to comment
ozulus Posted November 3, 2015 Share Posted November 3, 2015 This should work. local numberCounter = 0 function numberup() numberCounter = numberCounter + 1 outputChatBox(numberCounter) end addCommandHandler("number",numberup) Link to comment
scaryface87 Posted November 3, 2015 Author Share Posted November 3, 2015 Hello , One more question is it possible to save the last number? So if i restart the script for example the number will go up depending the last number thats given out? Edit : Fixed it with elementdata but if i restart the server its gone Or am i wrong and it"ll keeps the eleentdata even after restarting the server. Greetings Link to comment
ozulus Posted November 4, 2015 Share Posted November 4, 2015 Well, you must use SQL or XML to save the number count. Sql is better than xml but its your choice. I think XML won't create any lag because data is too short. Link to comment
scaryface87 Posted November 4, 2015 Author Share Posted November 4, 2015 Thank you very much! I got it all working with SQL now. If im right SQL wont create any laggs?(or atleast not big ones) Link to comment
SpecT Posted November 4, 2015 Share Posted November 4, 2015 Thank you very much! I got it all working with SQL now. If im right SQL wont create any laggs?(or atleast not big ones) Yes, unless its size get bigger. Link to comment
scaryface87 Posted November 5, 2015 Author Share Posted November 5, 2015 Hello , I've found a little problem. The script is functionaling perfectly except the part that the database is getting created? Everything is working fine but if i check registery.db i cant see the table there. Any idea why? function createTable() executeSQLQuery("CREATE TABLE IF NOT EXISTS lastID (lastID NUMERIC)") end addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),createTable) Fixed with restarting server Link to comment
scaryface87 Posted November 5, 2015 Author Share Posted November 5, 2015 Hello , I would like to know if its posssible to check multiple collumns. What i mean with it is the 2 lines below this should be one and sshould only delete a table if it maatches the the model & name(playername) in the SQL database executeSQLQuery("DELETE FROM `InteriorObjectsTEST` WHERE `model`=?",model) -- i defined model already executeSQLQuery("DELETE FROM `InteriorObjectsTEST` WHERE `name`=?",playerName) --- -- basicly this but then in one line and shouldnt delete everything Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now