Jump to content
  • 0

AtCommand That Calls Variable


Dragonis1701

Question


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  96
  • Reputation:   7
  • Joined:  05/25/12
  • Last Seen:  

Hey, just curious if there was a way to add an @command that would call a variable linked to the player that uses it. For example, I have a variable set whenever somebody gains an achievement and the variable is the achievement points they gain, which can later be used at a pointshop. What I'm curious is, can I somehow make a command that will tell that player what their variable is set to? So they can check how many achievement points they have whenever they want.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  133
  • Reputation:   189
  • Joined:  05/20/12
  • Last Seen:  

You can add a command handler like this:

ACMD_FUNC(mypoints)
{
	int points = pc_readaccountreg(sd, add_str("your-script-variable-here"));
	char buffer[32];

	sprintf(buffer, "You have %d points.", points);

	clif_displaymessage(fd, buffer);

	return 0;
}
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  96
  • Reputation:   7
  • Joined:  05/25/12
  • Last Seen:  

Thank you, that worked! I did have to change the buffer to 512 for it to not give me errors, though.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  16
  • Topics Per Day:  0.00
  • Content Count:  666
  • Reputation:   673
  • Joined:  11/12/12
  • Last Seen:  

I'd recommend a script command instead for what you need.

-	script	atcmd_mypoints	-1,{
	end;
OnInit:
	bindatcmd "mypoints", strnpcinfo(3) + "::OnAtcommand", 0, 99;
	end;
OnAtcommand:
	dispbottom "You have " + variable_here + " points.", 0x00ff00;
	end;
}

They are easier to manage and doesn't require a server recompile.

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...