06.07.2012, 10:21
(
Последний раз редактировалось iggy1; 06.07.2012 в 10:55.
)
I recently read this thread https://sampforum.blast.hk/showthread.php?tid=356637.
And i thought it might be useful to have a database with all valid objectids in it. You can also add your own ids to the database easily if you have created your own objects.
I created it from the valid_model array from the pastebin link in that thread. So credits go to whoever made that. It was posted by guest. http://pastebin.com/xgMrfNNK
Here's the database
Valid object database (should go in scriptfiles folder): https://dl.dropbox.com/u/76608104/valid_objects.db
So you can do normal sqlite queries with the database.
Eg,
EDIT: I posted the created database because it takes a while to generate. I think it took about 30 seconds on my PC.
This was how it was created.
Wasn't sure whether to post here or snippets, i thought here would be better because its a DB not code.
And i thought it might be useful to have a database with all valid objectids in it. You can also add your own ids to the database easily if you have created your own objects.
I created it from the valid_model array from the pastebin link in that thread. So credits go to whoever made that. It was posted by guest. http://pastebin.com/xgMrfNNK
Here's the database
Valid object database (should go in scriptfiles folder): https://dl.dropbox.com/u/76608104/valid_objects.db
So you can do normal sqlite queries with the database.
Eg,
pawn Код:
db_IsValidObject(objectid)
{
new
szBuffer[64],
DBResult: dbrResult,
DB: db_ValidObjects = db_open("valid_objects.db");
format(szBuffer, sizeof(szBuffer), "SELECT null FROM objects WHERE objectid=%d", objectid);
dbrResult = db_query(db_ValidObjects, szBuffer);
if(db_num_rows(dbrResult))
{
db_free_result(dbrResult);
db_close(db_ValidObjects);
return 1;
}
db_free_result(dbrResult);
db_close(db_ValidObjects);
return 0;
}
This was how it was created.
pawn Код:
new
szBuffer[64],
DB: db_ValidObjects = db_open("valid_objects.db");
db_query(db_ValidObjects, "CREATE TABLE IF NOT EXISTS objects (objectid INTEGER)");
for(new i=0; i < sizeof(valid_model); ++i)
{
format(szBuffer, sizeof(szBuffer), "INSERT INTO objects VALUES (%d)", valid_model[i]);
db_query(db_ValidObjects, szBuffer);
}
db_close(db_ValidObjects);