Jump to content

check if ID is used or not


scaryface87

Recommended Posts

Posted

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

Posted

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

Posted

This should work.

  
local numberCounter = 0 
function numberup() 
numberCounter = numberCounter + 1 
outputChatBox(numberCounter) 
end 
addCommandHandler("number",numberup) 
  

Posted

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

Posted

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.

Posted
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.

Posted

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

Posted

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 
  

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...