How to stop a command from being used over?

RealSlimShady
Hello again, I'm wondering if there's a way to stop a command from being used over and over. I have this command where If you type "choose" a random aspect will be assigned to the Player object's attribute and you gain abilities based on that aspect.
I want to make it where if you already used the command once before you can't use it again to gain new abilities and an aspect over and over. Is that possible?

Espera
Absolutely. If you're using the editor, begin teh command's script with a 'First time' script (in the 'Scripts' section of the scripts list). Make the command do what is supposed to do in the first section, and in the 'otherwise' section, put an error message like 'You can't choose again'.

HegemonKhan
and if you want to specify after a certain number of times, all you need is to use a 'count' variable~attribute, an example:

<game name="blah">
// blah code lines
<attr name="choose_count" type="int">0</attr>
</game>

<command name="choose_command">
<pattern>choose</pattern>
<script>
choose_function
</script>
</command>

<function name="choose_function"><![CDATA[
if (game.choose_count = 5) {
msg ("sorry, you've reached the max you can do this thing")
} else {
// blah scripts for doing whatever you want to do
game.choose_count = game.choose_count + 1
}
</function>


you can also take a look at this code too:

viewtopic.php?f=5&t=4094&hilit=rock%2C+paper%2C+scissors

if you want to see how to allow the person playing the game, to select the max number of times for doing a scripting of~for something.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums