Storing Player Numbers In MYSQL Without Two Numbers Being The Same
#1

Let's say a player joined a family and I want to give that player a number. I'm leading the faction so I go to the player and I want to /givenumber to the player. I want to store the number into their MYSQL Profile. So I make a new column in SQL called "Number" and I go to the player and do /givenumber Name_One 100. So another guy comes along and he wants another number. I want to do /givenumber but excluding numbers that exist in that SQL column. Number 100 already exists for another player. I want it so I can't do /givenumber Name_2 100 to the second guy who wants a number, but instead, it sends me a message saying that that number exists. Any help?
Reply
#2

pawn Код:
format(string,sizeof(string),"SELECT * FROM `table where the info stored` WHERE `number`='%d'",number);
samp_mysql_query(string);
samp_mysql_store_result();
whie(samp_mysql_fetch_row(query))
  print("Number already exists.");
else print("Number doesn't exist.");
Reply
#3

Wow. I could've thought of that but I kept making it sound more complicated than it is. Thanks man. I really appreciate it.

Edit:

Well actually, that code is only for one number. Suppose the interval of numbers is let's say 1-100. Instead of rewriting the code 100 times, how can I fit it all into a few lines?

Edit(2):

Nevermind. I got it. I set the strval(tmp) to %d. Thank you so much.
Reply
#4

Problem.

It doesn't let me use an 'else' statement if it doesn't contain an 'if' statement.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)