Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How to get username in server?


Recommended Posts

i am also wondering this as i have

 

@ForgeSubscribe
	public void onDeath(LivingDeathEvent e){
	if(e.entity instanceof EntityPlayer && !e.entity.worldObj.isRemote){
	Entity killed = e.entity;
	Entity killer = e.source.getEntity();
		Random randomGenerator = new Random();
		int ran = randomGenerator.nextInt(25);
				if (ran == 1 ||ran == 2 ||ran == 3 ||ran == 4 ||ran == 5 ||ran == 6 ||ran == 7){
	killed.dropItem(ashtonsmod.Manure.itemID, 1);}
				if (ran == 8 ||ran == 9 ||ran == 10 ||ran == 11 ||ran == 12 ||ran == 13 ||ran == 14){
	killed.dropItem(Item.bone.itemID, 1);}
				if (ran == 20 ||ran == 21 ||ran == 22 ||ran == 23 ||ran == 24){
	killed.dropItem(ashtonsmod.Flesh.itemID, 1);}
				if (ran == 25){
	ItemStack charskull = new ItemStack(Item.skull, 1, 3);
	killed.entityDropItem(charskull, 1);}
		if (ran < 26){
			if (USERNAME == "ashtonr12"){
			killed.dropItem(Item.diamond.itemID, 1)
		}}
	}}

 

where do i get the username of the player entity that died from?

 

sorry if you think i am stealing your thread bu i thought it was related and if my problem can be solved then yours can only be similar :)

Use examples, i have aspergers.

Examples make sense to me.

Link to post
Share on other sites

i am also wondering this as i have

 

@ForgeSubscribe
	public void onDeath(LivingDeathEvent e){
	if(e.entity instanceof EntityPlayer && !e.entity.worldObj.isRemote){
	Entity killed = e.entity;
	Entity killer = e.source.getEntity();
		Random randomGenerator = new Random();
		int ran = randomGenerator.nextInt(25);
				if (ran == 1 ||ran == 2 ||ran == 3 ||ran == 4 ||ran == 5 ||ran == 6 ||ran == 7){
	killed.dropItem(ashtonsmod.Manure.itemID, 1);}
				if (ran == 8 ||ran == 9 ||ran == 10 ||ran == 11 ||ran == 12 ||ran == 13 ||ran == 14){
	killed.dropItem(Item.bone.itemID, 1);}
				if (ran == 20 ||ran == 21 ||ran == 22 ||ran == 23 ||ran == 24){
	killed.dropItem(ashtonsmod.Flesh.itemID, 1);}
				if (ran == 25){
	ItemStack charskull = new ItemStack(Item.skull, 1, 3);
	killed.entityDropItem(charskull, 1);}
		if (ran < 26){
			if (USERNAME == "ashtonr12"){
			killed.dropItem(Item.diamond.itemID, 1)
		}}
	}}

 

where do i get the username of the player entity that died from?

 

sorry if you think i am stealing your thread bu i thought it was related and if my problem can be solved then yours can only be similar :)

Use examples, i have aspergers.

Examples make sense to me.

Link to post
Share on other sites

example?

i tried this and this now work;

public String EName;
public String getEntityName() {
	return EName;
}


@PreInit
	@ForgeSubscribe
	public void onDeath(LivingDeathEvent e){
	if(e.entity instanceof EntityPlayer && !e.entity.worldObj.isRemote){
	Entity killed = e.entity;
	Entity killer = e.source.getEntity();
		Random randomGenerator = new Random();
		int ran = randomGenerator.nextInt(25);
		if (EName == "ashtonr12"){
			ItemStack GA = new ItemStack(Item.appleGold, 1, 1);
			killed.entityDropItem(GA, 1);}
		else{
				if (ran == 1 ||ran == 2 ||ran == 3 ||ran == 4 ||ran == 5 ||ran == 6 ||ran == 7){
	killed.dropItem(ashtonsmod.Manure.itemID, 1);}
				if (ran == 8 ||ran == 9 ||ran == 10 ||ran == 11 ||ran == 12 ||ran == 13 ||ran == 14){
	killed.dropItem(Item.bone.itemID, 1);}
				if (ran == 20 ||ran == 21 ||ran == 22 ||ran == 23 ||ran == 24){
	killed.dropItem(ashtonsmod.Flesh.itemID, 1);}
				if (ran == 25){
	ItemStack charskull = new ItemStack(Item.skull, 1, 3);
	killed.entityDropItem(charskull, 1);}
		}}
	}

Use examples, i have aspergers.

Examples make sense to me.

Link to post
Share on other sites

example?

i tried this and this now work;

public String EName;
public String getEntityName() {
	return EName;
}


@PreInit
	@ForgeSubscribe
	public void onDeath(LivingDeathEvent e){
	if(e.entity instanceof EntityPlayer && !e.entity.worldObj.isRemote){
	Entity killed = e.entity;
	Entity killer = e.source.getEntity();
		Random randomGenerator = new Random();
		int ran = randomGenerator.nextInt(25);
		if (EName == "ashtonr12"){
			ItemStack GA = new ItemStack(Item.appleGold, 1, 1);
			killed.entityDropItem(GA, 1);}
		else{
				if (ran == 1 ||ran == 2 ||ran == 3 ||ran == 4 ||ran == 5 ||ran == 6 ||ran == 7){
	killed.dropItem(ashtonsmod.Manure.itemID, 1);}
				if (ran == 8 ||ran == 9 ||ran == 10 ||ran == 11 ||ran == 12 ||ran == 13 ||ran == 14){
	killed.dropItem(Item.bone.itemID, 1);}
				if (ran == 20 ||ran == 21 ||ran == 22 ||ran == 23 ||ran == 24){
	killed.dropItem(ashtonsmod.Flesh.itemID, 1);}
				if (ran == 25){
	ItemStack charskull = new ItemStack(Item.skull, 1, 3);
	killed.entityDropItem(charskull, 1);}
		}}
	}

Use examples, i have aspergers.

Examples make sense to me.

Link to post
Share on other sites

thx all reply. now i can get username in server

How to : i use modloader.getinstance.thePlayer.username(); in client and send packet to server :)

for (int i = 0; i < Integer.MAX_VALUE; i++) {

    facedesk();

}

For gods sake, are you serious? :D You can just use player.username on the server! (e.g. from an event that has a player: event.player.username).

Link to post
Share on other sites

thx all reply. now i can get username in server

How to : i use modloader.getinstance.thePlayer.username(); in client and send packet to server :)

for (int i = 0; i < Integer.MAX_VALUE; i++) {

    facedesk();

}

For gods sake, are you serious? :D You can just use player.username on the server! (e.g. from an event that has a player: event.player.username).

Link to post
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.