how to make offline /makeadmin
#1

I was wondering how do you demote someone offline, I'm using MySQL r41-2 and I need to know how can you check if someone exists on the database? are there any tutorials regarding this ?
Reply
#2

You command should run a query on your database

Код:
INSERT INTO accounts( `adminlevel`) VALUES(`%d`) WHERE `pname` = `%e`, newAdminLevel, NameOfPlayer
Make a command to run that query on your database fitting in the right things and it should work.
Reply
#3

Quote:
Originally Posted by Akeem
Посмотреть сообщение
You command should run a query on your database

Код:
INSERT INTO accounts( `adminlevel`) VALUES(`%d`) WHERE `pname` = `%e`, newAdminLevel, NameOfPlayer
Make a command to run that query on your database fitting in the right things and it should work.
Yeah thanks, but what about detecting the player on the database?, like, "This user is not registered in our database", what are the right checks ?
Reply
#4

Quote:
Originally Posted by severance
Посмотреть сообщение
Yeah thanks, but what about detecting the player on the database?, like, "This user is not registered in our database", what are the right checks ?
Check out a MySQL tutorial almost every tutorial has a check...
You do this query [/PHP]SELECT * FROM `users` WHERE `username` = '%s'[/PHP]and check if a row is returned or not.
Reply
#5

Quote:
Originally Posted by Akeem
Посмотреть сообщение
You command should run a query on your database

Код:
INSERT INTO accounts( `adminlevel`) VALUES(`%d`) WHERE `pname` = `%e`, newAdminLevel, NameOfPlayer
Make a command to run that query on your database fitting in the right things and it should work.
If you decide to help atleast make sure the information you give its correct. Its not INSERT INTO, it suppose to be UPDATE

Код:
UPDATE acounts SET adminlevel = %i WHERE name = '%s'
OP: If you run the query using mysql_tquery, and call a callback you can use https://sampwiki.blast.hk/wiki/MySQL/R40..._affected_rows to check if the update was made or not. (if wasnt made means the player doesnt exist)

Edit: coool method works aswell
Reply
#6

Use the affected rows method.
Reply
#7

Quote:
Originally Posted by Banditul18
Посмотреть сообщение
If you decide to help atleast make sure the information you give its correct. Its not INSERT INTO, it suppose to be UPDATE

Код:
UPDATE acounts SET adminlevel = %i WHERE name = '%s'
OP: If you run the query using mysql_tquery, and call a callback you can use https://sampwiki.blast.hk/wiki/MySQL/R40..._affected_rows to check if the update was made or not. (if wasnt made means the player doesnt exist)

Edit: coool method works aswell
Ideally, you should be working with unique ID's when altering ANYTHING to do with accounts to avoid data duplication, or editing the data of the wrong account.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)