Howdy pardner!

These here forums are read-only. Click here to go to the new forums, where you can actually post and stuff!

Sorry for the inconvenience

-Andrew

Hi I was wondering how to put the players name on the end of the message for example: carol_9924 zapped [player] <---- That's how im wondering? Is it $name or p.name idk. Thx.

Tylerhartman2000 Tue Feb 10 at 1:14:24 (2015)

Hmm I Dont Know Try Googling It!

I think it's $name... not sure!

Need more details!

Command for what? What language? Etc.

like /slap. [Player1] has been slapped by [player2] /slap [player1]. I'm wondering what do I put in [player1]. I'm not sure if its $name or p.name to make [player 1] the name of the player you wanted to slap. $name or p.name is the player1.

123DontMessWitMe Special Sun Feb 22 at 6:55:32 (2015)

I am gonna assume the software you use is opensorce, and you are modding it for yourself. I am also gonna assume that when you type in chat "$name" is replaced by either your name or the person who is viewing it's name. Either way, if you are modding the codebase it's p.name assuming p is a player class.

Assuming you are using MCForge, hopefully these three lines from cmdSlap will help explain how this works.

Each cmd is 'Used' in this way.

The 'Player p' argument is always the player executing the command, while the 'string message' can perform different ways depending on the command (e.g. on /goto the 'message' is used with Level.Find rather than Player.find). This 'message' is what you type in the command line (e.g. /slap Peteys93 - Peteys93 becomes 'message'). For your purposes, you want the message to be a second player.

In the code below, the 'message' argument is used with a Player object and assigns the player that is found (by player.find(message) to whatever you decide to name it (here, the name chosen is 'who,' which is the name most MCForge commands use for this). You can then change 'Player' variables on 'who' (e.g who.name = the username of the second player).

Again, assuming you are on MCForge, $name functions as a name variable chatting within the server, and will show each player their name when it is typed, this isn't what you are looking for.

Sorry if that was hard to follow - 3AM

tl;dr In the code below, p = the player executing the command, while who = the player the command is used on. p.name = the username of p and who.name = the username of who.

public override void Use(Player p, string message)

//Assign the value of the player found with the 'message' to 'who'

Player who = Player.Find(message);

//Send message to the server that player2 (who) was slapped sky high by player1 (p)

who.level.ChatLevel(who.color + who.name + Server.DefaultColor + " was slapped sky high by " + p.color + p.name);

Thx dontmess and petey,! It really helped!

This post has been hidden by the ClassiCube moderation team.
🛑 This thread has been set to read-only due to inactivity. 🛑