Jump to content
  • 0

@maintown commands (@warp phtownall 199,184 )


Question

Posted

Hello Everyone. Can someone make me a custom commands that has a function to warp in a specific location. 

@maintown = ( @warp phtownall 199,184 )

@mall = ( @warp turbo_room 100, 100 )

@event = ( @warp quiz_02 100,100 )

@donate = ( @warp turbo_room 200,200 )

 

 

I know there's @go commands. But is it possible to make a commands like that? 

 

Thank you in advance. Ciao.  /no1

7 answers to this question

Recommended Posts

Posted

Try this you can do the same thing for others just change the " maintown

-	script	maintown	-1,{
OnInit:
	bindatcmd "maintown",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
	atcommand "@warp phtownall 199 184";
	end;
}
  • Like 1
  • 1
Posted
4 minutes ago, maken06 said:

Is it possible to add restrictions so that it is only used for a level 45 gm? @Radian

Change this part

bindatcmd "maintown",strnpcinfo(3)+"::OnAtcommand";

Into this

bindatcmd "maintown",strnpcinfo(3)+"::OnAtcommand",45,99;

So a level 45 and 99 GM can only access this command.

  • Love 1
  • 0
Posted
On 21/1/2015 at 3:50 PM, Radian said:

Try this you can do the same thing for others just change the " maintown


-	script	maintown	-1,{
OnInit:
	bindatcmd "maintown",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
	atcommand "@warp phtownall 199 184";
	end;
}

Is it possible to add restrictions so that it is only used for a level 45 gm? @Radian

Posted (edited)

Hello guy,

 

i have try it and it works fine. You have to do 4 steps.

 

First of all: [step 1]

Add your custom Map in the src/common/mapindex.h file. After:

#define MAP_ECLAGE_IN "ecl_in01"

add this:

#define MAP_MAINTOWN "phtownall"

Now. Step 2.

Open your src/map/atcommands.c file. Search for:

/*==========================================
 * @tonpc
 *------------------------------------------*/
ACMD_FUNC(tonpc)
{
	char npcname[NAME_LENGTH+1];
	struct npc_data *nd;

	nullpo_retr(-1, sd);

	memset(npcname, 0, sizeof(npcname));

	if (!message || !*message || sscanf(message, "%23[^\n]", npcname) < 1) {
		clif_displaymessage(fd, msg_txt(sd,1129)); // Please enter a NPC name (usage: @tonpc <NPC_name>).
		return -1;
	}

	if ((nd = npc_name2id(npcname)) != NULL) {
		if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
			clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
		else
			return -1;
	} else {
		clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
		return -1;
	}

	return 0;
}

And after it add this:

/*==========================================
 * @maintown
 *------------------------------------------*/
ACMD_FUNC(maintown)
{
if (pc_setpos(sd, mapindex_name2id(MAP_MAINTOWN), 119, 184, CLR_TELEPORT) == 0){
	clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
} else {
	return -1;
}
return 0;
}

After you finish that go to Step 3. Search for

ACMD_DEF(tonpc),

And after it add this one:

ACMD_DEF(maintown),

Last but not least: Step 4.

Recompile your server and test it. It works fine for me ;) You can use it for all 4 commands. I hope you like it and I hope you have a lot of fun with it. http://pastebin.com/D144ZaQ9

 

Best regards,

Garkor

Edited by Garkor
Posted

use bindatcmd

-	script	warp#11	-1,{
	
	
OnInit:
bindatcmd "maintown ", strnpcinfo(3) +"::OnMaintown";
bindatcmd "mall", strnpcinfo(3) +"::OnMall";
bindatcmd "event", strnpcinfo(3) +"::OnEvent";
bindatcmd "donate", strnpcinfo(3) +"::OnDonate";
end;
		
	
	
OnMaintown:	
warp "phtownall",199,184;
end;


OnMall:	
warp "turbo_room",100,100;
end;


OnEvent:	
warp "quiz_02",100,100;
end;


OnDonate:	
warp "turbo_room",200,200;
end;
}	
Posted

use bindatcmd

-	script	warp#11	-1,{
	
	
OnInit:
bindatcmd "maintown ", strnpcinfo(3) +"::OnMaintown";
bindatcmd "mall", strnpcinfo(3) +"::OnMall";
bindatcmd "event", strnpcinfo(3) +"::OnEvent";
bindatcmd "donate", strnpcinfo(3) +"::OnDonate";
end;
		
	
	
OnMaintown:	
warp "phtownall",199,184;
end;


OnMall:	
warp "turbo_room",100,100;
end;


OnEvent:	
warp "quiz_02",100,100;
end;


OnDonate:	
warp "turbo_room",200,200;
end;
}	

Each atcommand is only allowed one binding. If you rebind, it will override the original binding.

and

 

-	script	maintown	-1,{
OnInit:
	bindatcmd "maintown",strnpcinfo(3)+"::OnAtcommand";
	end;
OnAtcommand:
	atcommand "@warp phtownall 199 184";
	end;
}
Why use atcommand "@war... when you can use the warp script command?

i.e.

warp "phtownhall",199,184;
So.. Maybe something like this (untested):

 

-	script	atcmdwarp#Maintown	-1,{

	OnInit:
		bindatcmd strnpcinfo(3)+"::On"+strnpcinfo(3);
		end;
	
	OnMaintown:
		warp "phtownall",199,184;
		end;
	
	OnMall:
		warp "turbo_room",100,100;
		end;
	
	OnEvent:
		warp "quiz_02",100,100;
		end;
	
	OnDonate:
		warp "turbo_room",200,200;
		end;
}
-	duplicate(Maintown)	atcmdwarp#Mall	-1
-	duplicate(Maintown)	atcmdwarp#Event	-1
-	duplicate(Maintown)	atcmdwarp#Donate	-1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...