Storing Player Numbers In MYSQL Without Two Numbers Being The Same - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Storing Player Numbers In MYSQL Without Two Numbers Being The Same (
/showthread.php?tid=84114)
Storing Player Numbers In MYSQL Without Two Numbers Being The Same -
Kenny990 - 28.06.2009
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?
Re: Storing Player Numbers In MYSQL Without Two Numbers Being The Same -
MenaceX^ - 28.06.2009
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.");
Re: Storing Player Numbers In MYSQL Without Two Numbers Being The Same -
Kenny990 - 29.06.2009
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.
Re: Storing Player Numbers In MYSQL Without Two Numbers Being The Same -
Kenny990 - 29.06.2009
Problem.
It doesn't let me use an 'else' statement if it doesn't contain an 'if' statement.