Jump to content
  • 0

Custom #command


QwertyD

Question


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  12/23/19
  • Last Seen:  

Hey guys, 

 

I was trying to make a custom @command named @reward that gives zeny to a player as an event reward, but if player has spaces on their name eg: M y C h A r N a m e, then the custom command fails. I know # commands work on this by adding " " before and after the character name but how do I make my own custom #command?

Example:

#reward "N a M e" 10000

To give 10000 zeny reward to that player.

 

Thanks!

Edited by QwertyD
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  34
  • Topics Per Day:  0.01
  • Content Count:  215
  • Reputation:   45
  • Joined:  05/03/13
  • Last Seen:  

Hello,

# commands make the player using the command as if they did it themself using @.

So you may change your @reward command to NOT take in parameter a player, but gives to the player using it the reward, so:

@reward 10000 - would give you 10000 zeny
#reward "N a M e" 10000 - would give N a M e 10000 zeny

And you don't give the @reward command right to the basic players and it should do the job.

---

Another way is to split the parameters you get, and change how you give them, like:

@reward N a M e#10000

And you split on # on know on [0] it's the name and on [1] it's the number (but be carefull what you're doing there).

---

Or like vip command, you put the name at the end, just watch in the src how it's done:

ACMD_FUNC(vip) {
	struct map_session_data *pl_sd = NULL;
	char * modif_p;
	int32 vipdifftime = 0;
	time_t now=time(NULL);

	nullpo_retr(-1, sd);

	memset(atcmd_output, '\0', sizeof(atcmd_output));

	if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
		clif_displaymessage(fd, msg_txt(sd,700));	//Usage: @vip <timef> <character name>
		return -1;
	}

	atcmd_output[sizeof(atcmd_output)-1] = '\0';

	modif_p = atcmd_output;
	vipdifftime = (int32)solve_time(modif_p);
	if (vipdifftime == 0) {
		clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
		clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
		return -1;
	}

	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
		return -1;
	}

And adapt the first parameter to work without having to solve_time (just an integer).

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  12/23/19
  • Last Seen:  

7 hours ago, Kreustoo said:

Hello,

# commands make the player using the command as if they did it themself using @.

So you may change your @reward command to NOT take in parameter a player, but gives to the player using it the reward, so:

@reward 10000 - would give you 10000 zeny
#reward "N a M e" 10000 - would give N a M e 10000 zeny

And you don't give the @reward command right to the basic players and it should do the job.

---

Another way is to split the parameters you get, and change how you give them, like:

@reward N a M e#10000

And you split on # on know on [0] it's the name and on [1] it's the number (but be carefull what you're doing there).

---

Or like vip command, you put the name at the end, just watch in the src how it's done:


ACMD_FUNC(vip) {
	struct map_session_data *pl_sd = NULL;
	char * modif_p;
	int32 vipdifftime = 0;
	time_t now=time(NULL);

	nullpo_retr(-1, sd);

	memset(atcmd_output, '\0', sizeof(atcmd_output));

	if (!message || !*message || sscanf(message, "%255s %23[^\n]",atcmd_output,atcmd_player_name) < 2) {
		clif_displaymessage(fd, msg_txt(sd,700));	//Usage: @vip <timef> <character name>
		return -1;
	}

	atcmd_output[sizeof(atcmd_output)-1] = '\0';

	modif_p = atcmd_output;
	vipdifftime = (int32)solve_time(modif_p);
	if (vipdifftime == 0) {
		clif_displaymessage(fd, msg_txt(sd,701)); // Invalid time for vip command.
		clif_displaymessage(fd, msg_txt(sd,702)); // Time parameter format is +/-<value> to alter. y/a = Year, m = Month, d/j = Day, h = Hour, n/mn = Minute, s = Second.
		return -1;
	}

	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
		return -1;
	}

And adapt the first parameter to work without having to solve_time (just an integer).

Thank you

Link to comment
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
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.

×
×
  • Create New...