Top Mud Sites Forum

Top Mud Sites Forum (http://www.topmudsites.com/forums/index.php)
-   MUD Coding (http://www.topmudsites.com/forums/forumdisplay.php?f=9)
-   -   Chown Command (http://www.topmudsites.com/forums/showthread.php?t=444)

Verboden Faction 01-26-2003 11:43 PM

Running rom2.4, I have found the Change Ownership command on a few other muds, but I want to put it on mine, found some circle snippets, and having trouble converting it.  Anyone help?  -Those who don't know what the chown command does: it make an obj go from a player to an immortal no matter what.  I would type 'chown (obj) (player)' and that object would go from the player, whether it was equipped or not, and come to my inventory. If you have chown on your mud, just copy and paste the void do_chown section in your source file...

Verboden Faction 01-27-2003 12:33 AM

I got it to work. I had to rewrite the whole thing and make my own. but now i'm having a bit of an issue. It was kinda hard, but I got it. But here is my new problem, when you type 'chown (player)' but no object is put in, or the player doesn't have the object, the mud crashes. It's cause I don't have anything in the code for that instance. There is nothing for it to do if the object isn't found. What do I do to fix that?

Verboden Faction 01-27-2003 02:25 AM

...

Wenlin 01-27-2003 03:32 AM

Um, sir, I know nothing on the subject, but you're obviously awaiting a response...

Unfortunately, you're unlikely to get one in a few hours at the middle of the night. I hate to break it to you...

Terloch 01-27-2003 11:37 AM

Here's the syntax for our command which does probably the same thing as what you are trying to get to work...hope it helps...

DO_CMD ( do_seize )
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA * victim;
OBJ_DATA *obj;
OBJ_DATA *obj_next;
bool found;

argument = one_argument ( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char ( "{WSyntax:\n\r seize char <char> <object>{x\n\r", ch );
send_to_char ( " seize container <container> <object>{x\n\r", ch );
return;
}

if ( !str_prefix ( arg, "char" ) )
{
argument = one_argument ( argument, arg );
if ( arg[0] == '\0' )
{
do_function ( ch, &do_seize, "" );
return;
}

if ( ( victim = get_exact_player_room ( ch, arg ) ) == NULL )
{
send_to_char ( "They are not here.\n\r", ch );
return;
}

if ( IS_TRUSTED ( victim, LEVEL_ANCIENT ) )
{
send_to_char ( "Not on ancients.\n\r", ch );
return;
}

argument = one_argument ( argument, arg );
if ( arg[0] == '\0' )
{
do_function ( ch, &do_seize, "" );
return;
}

found = FALSE;
for ( obj = victim->carrying; obj != NULL; obj = obj_next )
{
obj_next = obj->next_content;

if ( is_name ( arg, obj->name ) )
{
found = TRUE;
obj_from_char ( obj );
obj_to_char ( obj, ch );
send_to_char ( "Ok.\n\r", ch );
ACT_OC ( "{WYou couldn't tell how it happened, but $p is now in $r's possesion.{x",
ch, obj, victim, TO_VICT );
}
}

if ( !found )
{
send_to_char ( "No such item found.", ch );
}
}

else if ( !str_prefix ( arg, "container" ) )
{
send_to_char ( "Not implemented.\n\r", ch );
}

else
{
do_function ( ch, &do_seize, "" );
}

return;
}

Terloch

markizs 01-28-2003 02:57 AM

hmm. as i am keen only with lp muds and dont see where your problem is :P in lpmud that would look somthing like:

init()
{
add_action("chown","chown");
}

int chown(string str)
{
string s1,s2;
if (str)
{
scanf(str,%s %s,s1,s2);
if (!s1 || !s2) return 0;
move_object(find_object(s1),find_player(s2));
return 1;
}
return 0;
}

//just wanted to post somthing :PPP
//shame that all talks there are about anything but lpmud :(

Ogma 01-28-2003 04:22 AM

Actually, you're going to want to use

if (str && str!="" && sscanf("%s %s",s1,s2)==2) ...

and you probably want to check if the two find_player calls actually worked.

And yes, LPMUDs are far outnumbered by the bland Diku/Merc/Rom/Smaug crowd.

markizs 01-28-2003 05:04 AM

heh. yes you proved me wrong. just havnt coded such stuff for few months and slightly forgot the syntax :)
but i rem doing somthing like that with find_object and find_player. using other stuff too, but i wernt sure if that wasnt mudlib functions, or maybe our modified amylaars stuff. oh well. my listing was still 10 times shorter than one above :)

jornel 01-28-2003 07:39 AM

Verboden Faction,

Perhaps it would help if you posted a copy of the code you wrote where we could look at it and help you find what's wrong or missing?

Verboden Faction 03-23-2003 07:12 PM

Actually, I figured it out. I run on rom24b6, here is what I used.

[code] void do_chown(CHAR_DATA *ch, char *argument)
{
CHAR_DATA *victim;
OBJ_DATA *obj;
char arg1[MIL];
char buf[MSL];
buf[0] = '\0';
bool found = FALSE;



argument = one_argument(argument,arg1);

if(IS_NULLSTR(arg1)){
send_to_char("chown <player> <item>\n\r", ch);
return;
}

if((victim = get_char_room(ch,arg1)) == NULL){
send_to_char("There is no such person.\n\r", ch);
return;
}

for(obj = victim->carrying; obj; obj = obj->next_content ){
if ( is_name( argument, obj->name )
&& can_see_obj( ch, obj ))
{
found = TRUE;
break;
}
}

if(!found){
send_to_char("They don't have that.\n\r", ch);
return;
}



obj_from_char( obj );
obj_to_char( obj, ch );
sprintf(buf, "You summon %s from %s.\n\r", obj->short_descr, victim->name);
send_to_char(buf, ch);
sprintf(buf,"You feel a light wind as %s floats into the hands of %s.\n\r",obj->short_descr,ch->name);
send_to_char(buf, victim);
return;
}
[/quote]


All times are GMT -4. The time now is 03:41 PM.

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright Top Mud Sites.com 2022