Dynamic job script - actors and saving?
#5

Quote:
Originally Posted by TheBigFive
Посмотреть сообщение
Alright, any clue how I am supposed to deal with the job ids?
Not sure why you would use MAX_PLAYER_NAME as your size. It doesn't quite tell you what it is. You should define MAX_JOBS or something along those lines instead.

As for your question, the database ID is only used in queries. Session ID and Database ID is something to be kept apart because of the fact that you use an array to access the enum and arrays start counting at 0, unlike your A_I field. I personally prefer keeping the 0-start instead of adding 1 to every index.

To achieve that, I keep an extra boolean enumerator usually called 'bool: xxExists'. Fill in the 'xx' yourself or remove it. This variable is not saved.

Loading:
PHP код:
for(new 0cache_get_row_count(); MAX_JOBS && ji++) {
    
jobData[i][Exists] = true;
    
// Load other data

Filling in the gaps when creating a new job:
PHP код:
for(new i  0MAX_JOBSi++) if(!jobData[i][Exists]) {
    
jobData[i][Exists] = true;
    
// Save other data

The loop will loop through all indexes of jobData and check which ID is not created yet. It will then create the new job using that ID. All you have to do to remove a job is set 'Exists' to false and of course remove the row from the database.

There are countless ways of achieving the same thing, but I do it like this. I'm open to hear from others on how to do it differently.
Reply


Messages In This Thread
Dynamic job script - actors and saving? - by TheBigFive - 05.08.2016, 20:10
Re: Dynamic job script - actors and saving? - by TheBigFive - 05.08.2016, 23:20
Re: Dynamic job script - actors and saving? - by AndySedeyn - 05.08.2016, 23:26
Re: Dynamic job script - actors and saving? - by TheBigFive - 05.08.2016, 23:56
Re: Dynamic job script - actors and saving? - by AndySedeyn - 06.08.2016, 00:41
Re: Dynamic job script - actors and saving? - by TheBigFive - 06.08.2016, 11:43
Re: Dynamic job script - actors and saving? - by TheBigFive - 06.08.2016, 15:57
Re: Dynamic job script - actors and saving? - by TheBigFive - 12.08.2016, 16:18

Forum Jump:


Users browsing this thread: 3 Guest(s)