Please check out Justice League Unlimited MUX !

Member Discussions

terms



[Previous] [Next] [Post] [Reply] [Topics] [Summary] [Search]


1. Limited Objects Sat Dec 3, 2005 [12:00 PM]
ixyltryxl
kriegar100@yahoo.com
member since: Dec 26, 2000
Reply
Trying to put in a limit list command , i basically copied do_material_list and edited it changing it to do_limit_list. i've already added the field into oedit for world limit which was copied and edited from asize - it works fine. limit list i want it to show the limiteds in a table with world_limit amt, short_descr, who its carried by which last part, i still need to make a read to file code i guess? where the code then checks when the object is taken, looted, exchanged writes it to file, then the limit command reads from that file displaying carried by: mob, char, I just started this past week in trying to learn how to code myself, so this is probably a big mess but if anyone is willing to help solving these errors, I'd appreciate it greatly, Probably look like a fool but here is the errors:

oedit.cpp: In function `void do_limit_list(char_data*, char*)':
oedit.cpp:48: invalid conversion from `int' to `char*'
oedit.cpp:50: request for member `count' in `"Count=%5d, objvnum=%d"', which is
of non-aggregate type `char[22]'
oedit.cpp:58: warning: int format, pointer arg (arg 4)
oedit.cpp:73: invalid conversion from `int' to `const char*'
oedit.cpp:73: invalid conversion from `int' to `const char*'
oedit.cpp:76: syntax error before `}' token
oedit.cpp:82: break statement not within loop or switch
oedit.cpp: At global scope:
oedit.cpp:91: syntax error before `}' token


Here's the Code:


/**************************************************************************/
void do_limit_list( char_data *ch, char *argument) // ixyltryxl dec '05
{
name_linkedlist_type* limits_list=0, *plist;
OBJ_INDEX_DATA *pObjIndex;
int vnum, count, value;
BUFFER *output;
char buf [MIL];

if(IS_NULLSTR(argument)){
logf("do_limit_list(): Sorting Limited Items");
for (vnum=0; vnumcount=0;
for ( pObjIndex = obj_index_hash[vnum];
pObjIndex != NULL;
pObjIndex = pObjIndex->next )
{
count++;
addlist(&limits_list,pObjIndex->world_limit, 0, false, false); <-- Line 48
if(count>20000){
bugf("Count=%5d, objvnum=%d". count, pObjIndex->vnum); <-- line 50
}
}
}
logf("do_limit_list(): Displaying world limits to buffer");
output = new_buf();
count=0;`
for(plist=limits_list;plist; plist=plist->next){
sprintf(buf, "%3d> %d\n", ++count, plist->name); <-- line 58
add_buf( output, buf );
}
logf("do_limit_list(): Sending buffer to player");
ch->printlnf( "%d limited%s total.",
count,
count==1 ? "" : "s" );
ch->sendpage(buf_string(output));
free_buf(output);
}else{
count=0;
output = new_buf();
for(vnum=0; vnum<70000; vnum++){
pObjIndex =get_obj_index(vnum);
if(pObjIndex){
if(is_name(value, pObjIndex->world_limit)){ <-- line 73
sprintf(buf, "%3d> [%5d] %s `Sworld limit='%d'`x\n",
++count, pObjIndex->vnum,
pObjIndex->short_descr, pObjIndex->world_limit}; <-- line 76
add_buf( output, buf );
}
}
if(count>400){
ch->println( "You can only list up to 400 items at once, be more specific." );
break; <-- line 82
}
}
ch->printlnf( "Displaying %d limited%s total.",
count,
count==1 ? "" : "s" );
ch->sendpage(buf_string(output));
free_buf(output);
}
} <-- line 91

/**************************************************************************/


2. RE: Limited Objects Sat Dec 3, 2005 [3:16 PM]
c_rassus
Email not supplied
member since: Oct 26, 2004
In Reply To
Reply
While perhaps some more information (like the codebase you're running) would be helpful, it looks like you're trying to use integers and strings interchangably, which you can't do.

For example:

sprintf(buf, "%3d> %d\n", ++count, plist->name); <-- line 58

%d calls an integer, but plist->name looks to me like it should be a string. So you'd need to use %s instead.

oedit.cpp:82: break statement not within loop or switch

You probably want a return instead of a break, since, as it says, you're not in a loop or switch. If you just want to get out of the function, then put in "return;" instead of "break;".


3. RE: Limited Objects Sat Dec 3, 2005 [4:59 PM]
Qidexan
Email not supplied
member since: Feb 29, 2000
In Reply To
Reply
48, 73, 76: pObjIndex->world_limit appears to be an integer instead of a string.

50: period used instead of a comma

58: second %d should be %s

82: you need to move the if statement and contents from line 80 into the for statement brackets.

91: not sure...fix the other issues, if there is still a problem, you may have too many or two few closing brackets


4. RE: Limited Objects Sat Dec 3, 2005 [5:46 PM]
ixyltryxl
kriegar100@yahoo.com
member since: Dec 26, 2000
In Reply To
Reply
Thanks for your input guys, I managed to get everything working for the skeleton part of this a few hours back.
Everything works smoothly on it so far. the source code is DOT 1.69r This is what appears when you type limit

limit
3 limited objects total.
1> 0
2> 1
3> 3

'0' being all other objects in the game with 0 int for world_limit world_limit defaults to 0, so will have to change that later in the source to -1 for infinite and to exclude any item with -1 from pulling up on the list. If there is 10 items in the game with world_limit 1 it still only lists it on 2> where it states 1. I want to make it so when you type limit the list pulls up like this.

3 limited objects total.
[LIMIT][VNUM ][ NAME ][ WHERE ]
[ 1][60000][Sword of Ages ][Ixyltryxl, Vlosk ]
[ 1][60001][Crown of Ages ][Ixyltryxl ]
[ 3][60002][Imperisk Pearl ][Vlosk, Shadow Owl]

Here's the Code currently, which compiled, error free and works without any errors/crashing.
/**************************************************************************/
void do_limit_list( char_data *ch, char *argument) // ixyltryxl dec '05
{
name_linkedlist_type* limits_list=0, *plist;
OBJ_INDEX_DATA *pObjIndex, *pObj;
int vnum, count, value;
BUFFER *output;
char buf [MIL];


if(IS_NULLSTR(argument)){
logf('do_limit_list(): Sorting Limited Items');
for (vnum=0; vnum count=0;
for ( pObjIndex = obj_index_hash[vnum];
pObjIndex != NULL;
pObjIndex = pObjIndex->next )
{
count++;
addlist( &limits_list, FORMATF('%d',pObjIndex->world_limit), 0, false, false );
if(count>20000){
bugf('Count=%5d, objvnum=%d', count, pObjIndex->vnum);
}
}
}
logf('do_limit_list(): Displaying world limits to buffer');
output = new_buf();
count=0;
for(plist=limits_list;plist; plist=plist->next){
sprintf(buf,'%3d> %s\n', ++count, plist->name);
add_buf( output, buf );
}
logf('do_limit_list(): Sending buffer to player');
ch->printlnf( '%d limited object%s total.',
count,
count==1 ? '' : 's' );
ch->sendpage(buf_string(output));
free_buf(output);
}else{
count=0;
output = new_buf();
for(vnum=0; vnum<70000; vnum++){
pObjIndex =get_obj_index(vnum);
if(pObjIndex){
if(value == pObjIndex->world_limit){
sprintf(buf, '%3d> [%5d] %s `Sworld limit='%d'`x\n',
++count, pObjIndex->vnum,
pObjIndex->short_descr, pObjIndex->world_limit);
add_buf( output, buf );
}
}
if(count>400){
ch->println( 'You can only list up to 400 items at once, be more specific.' );
break;
}
}
ch->printlnf( 'Displaying %d world limit%s total.',
count,
count==1 ? '' : 's' );
ch->sendpage(buf_string(output));
free_buf(output);
}
}
/**************************************************************************/


After all this, I still need to make code that when a mobile repops, and it does its checks on loading objects it checks if objects that it successfully rolls are limited, if so it checks a file that will be written into the system directory, if that limited object already exists in game. If its at world_max for that limited then it will not load, if it isn't it will. At which point it then writes to the limit file in the system directory, of that limited being loaded into the game. If a player, loots, takes, steals, gives, destroys, or an immortal, clones, loads, purges limited objects then the file will be updated approriately either adding to the list or removing it. Other commands to work in conjunction would be a destroy command for immortals to purge all limiteds from the game as well as clear the limit file in the system directory. And a script to run weekly to check on log ins of players if timeframe surpasses allowed time, then the script will purge limiteds off the players who have not logged in - in the set amount of time frame. This is to stop hoarding limiteds. Probably way over my head, I started attempting C++ this past weekend. If see anything else in this current code that could use some work, i'm sure it looks like a hack-job, i'd appreciate the help, or any pointers on how to go about getting what i listed above done more efficiently in setting this up.

Ixyltryxl






[Previous] [Next] [Post] [Reply] [Topics] [Summary] [Search]