Add/remove classes from items (database)
I am hoping someone can help me figure out an easy way to either add or remove a class from the bitmask 'classes' in the items table. Is there another way of getting Navicat to look and edit classes based on the bitmask?
For example, how could you add 'warrior', =1, to every item, but exclude the one it's already on? I'm trying to avoid making items all/all here, even though that would be much easier. Thank you! |
Add: where 'slots' & 1 = 0 set 'slots' = 'slots' | 1
Remove: where 'slots' & 1 = 1 set 'slots' = 'slots' ^ 1 Someone with more sql experience may want to translate that. My sql from memory is horrible. EDIT: fixed Add error |
Select * from items where classes & 1
Inside navicat will find all items that can be used by warriors even the multi class items Google bitwise operators to find how to use them in sql it should help a lot |
Awesome! Thanks guys.
|
Code:
UPDATE items SET classes = 1 where classes > 1; |
Quote:
|
Yeah - just for anyone's reference in the future, the correct code is:
--- Add: where 'slots' & 1 = 0 set 'slots' = 'slots' | 1 Remove: where 'slots' & 1 = 1 set 'slots' = 'slots' ^ 1 --- This will add/remove warrior. Classes beyond warrior, or races beyond human, would go by the item table number (2,4,8...). Very useful code for those who want to expand class/race restrictions, but don't want to make items all/all. |
You are right my apologies DO NOT use what I posted.
|
Correct, you need to use bitmasks in sql.
Step #1. Back up, back up, back up. Step #2. Science! Somewhat recently I went through and removed gnomes and halflings pal/sk/rng respectively. Here's the thread with some explanation and sql example for people in the future that might want to see a select/update example. http://www.project1999.com/forums/sh...494#post785494 I hope it helps. |
I use this.
Code:
SELECT * FROM items WHERE classes & [class bitmask]; Code:
SELECT * FROM items WHERE classes & 32768; Code:
Operator Meaning |
All times are GMT -4. The time now is 09:13 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.