[Trigger] Sub Strings

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
Ive been having trouble with substrings, I looked at the tutorial on how substrings work, but I cannot figure out how to set two players through one substring. What i need to do is to swap incomes. I dont even know how to start it. Basically Player(12) brown. Makes the income. And After a certain time, he has to type who he gives the income amount that hes making to. Can anyone help me please.?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I am guessing the income is a variable, or a given number? (e.g.: the amount of farms he has).
If you are only having problems with the substrings, it should something like:

  • Switch
  • Events
    • Player - Player 12 (Brown) types a chat message containing -give as A substring
  • Conditions
  • Actions
    • Set Income_Variable[(Integer((Substring((Entered chat string), 7, (Length of (Entered chat string))))))] = Income_Variable[12]
What does it do?
When brown types -give X, it gives player X his income (by variable).
e.g.: when brown types "-give 3", teal will get his income.

If you want to add it to the amount of income teal makes (instead of setting it to brown's income), just use "Income_Variable[12] + Income_Variable[(Integer((Substring((Entered chat string), 7, (Length of (Entered chat string))))))]"

I hope you understand and this is what you meant ;)
 
Level 9
Joined
Jun 7, 2008
Messages
440
Do i have to set players into variables before i do this? As well, If i wanted to give teal my income but i only wanted to give him a fraction of it, would setting that fraction as an integer be easier? or Just trying through substrings?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
You do not need to set player variables.
Erm... can you give me an example?

Basically, you need to set the income of every player to an integer variable, that is all you need to do for my trigger.
If you want to give a fraction of it, just change the second part of the "set variable".
If you want to give half of Brown's income to teal, use "Set Income_Variable[the thing in my trigger] = Income_Variable[12] / 2"
(Income_Variable[12] is obviously brown's income, since it's player 12...).
 
Level 2
Joined
Jul 4, 2009
Messages
10
IMO it's better have a temporary integer to extract the amount, then subtract the amount from giving player's pool and add the amount to receiver's pool. And you need to include receiver playerID in -give string too, though this will involve using other string functions since playerID's length is unpredictable(1 or 2 digis/characters)
 
Status
Not open for further replies.
Top