i am making a trigger where you can save things as points in the game using the first two letters of your name but it does not work.What i got so far is:
enter region
Events
Unit - A unit enters a region
Conditions
(Unit-type of (Triggering unit)) Equal to Blood Mage
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Or - Any (Conditions) are true
Conditions
(Owner of (Triggering unit)) Equal to Player 1 (Red)
Then - Actions
Set Name[1] = (Substring((Name of (Triggering player)), 1, 1))
Set Name[2] = (Substring((Name of (Triggering player)), 2, 2))
Set Changetocode[1] = Intigers[(Integer(Name[1]))]
Set Changetocode[2] = Intigers[(Integer(Name[2]))]
Game - Display to (Player group((Triggering player))) the text: (Changetocode[1] + Changetocode[2])
Else - Actions
Game - Display to (Player group((Triggering player))) the text: ERROR!!!!
initialization
Events
Map initialization
Conditions
Actions
Set Intigers[(Integer(a))] = 47hg6
Set Intigers[(Integer(b))] = ns72hj
Set Intigers[(Integer(c))] = 982h7
Set Intigers[(Integer(d))] = je7h2
Set Intigers[(Integer(e))] = 832js7
Set Intigers[(Integer(f))] = 92hs7
Set Intigers[(Integer(g))] = 82ha7
Set Intigers[(Integer(h))] = na78h
Set Intigers[(Integer(i))] = 82a7a
Set Intigers[(Integer(j))] = js8h2a
Set Intigers[(Integer(k))] = 87edhs
Set Intigers[(Integer(l))] = 83h7s
Set Intigers[(Integer(m))] = q9aj3
Set Intigers[(Integer(n))] = ks832
Set Intigers[(Integer(o))] = kd8hs
Set Intigers[(Integer(p))] = 9ns72
Set Intigers[(Integer(q))] = 9en73
Set Intigers[(Integer(r))] = o9sh2
Set Intigers[(Integer(s))] = 0amns
Set Intigers[(Integer(t))] = 9w3mh
Set Intigers[(Integer(u))] = 9dsn1
Set Intigers[(Integer(v))] = jsx82h
Set Intigers[(Integer(w))] = 9w2n7
Set Intigers[(Integer(x))] = js8hj3
Set Intigers[(Integer(y))] = u8shy
Set Intigers[(Integer(z))] = 8h63w
when i try it i just end up getting 2 of the last code part 8h63w even though there are no z in my name.
PM me the map. I have an idea, yet im not sure im right. So the best way to find out would by trying it out in the map.
Edit :
Integer(a) just comes out as 0, and so do all the other letters, which is why z, the last one, is the only one that works. There is a solution for this in JASS, by using the following function:
Ok For somereason it has a problem converting the String to an Intiger than back to a string. (or atleast thats what my recreated one had a problem with)
i got it working by makeing a longer trigger.
make your triggers with numbers. For example. if a players name is apple
Than A = 1
and P = 16
Than make it look for 1 and 16 and display those. It should work or you can go with the Jass above
Initialization
Events
Map initialization
Conditions
Actions
Set Code[1] = a
Set Code[2] = b
Set Code[3] = c
Set Code[4] = d
Set Code[5] = e
Set Code[6] = f
Set Code[7] = g
Set Code[8] = h
Set Code[9] = i
Set Code[10] = j
Set Code[11] = k
Set Code[12] = l
Set Code[13] = m
Set Code[14] = n
Set Code[15] = o
Set Code[16] = p
Set Code[17] = q
Set Code[18] = r
Set Code[19] = s
Set Code[20] = t
Set Code[21] = u
Set Code[22] = v
Set Code[23] = w
Set Code[24] = x
Set Code[25] = y
Set Code[26] = z
Set Code[27] = A
Set Code[28] = B
Set Code[29] = C
Set Code[30] = D
Set Code[31] = E
Set Code[32] = F
Set Code[33] = G
Set Code[34] = H
Set Code[35] = I
Set Code[36] = J
Set Code[37] = K
Set Code[38] = L
Set Code[39] = M
Set Code[40] = N
Set Code[41] = O
Set Code[42] = P
Set Code[43] = Q
Set Code[44] = R
Set Code[45] = S
Set Code[46] = T
Set Code[47] = U
Set Code[48] = V
Set Code[49] = W
Set Code[50] = X
Set Code[51] = Y
Set Code[52] = Z
Code
Events
Player - Player 1 (Red) types a chat message containing -code as An exact match
Conditions
Actions
Set PlayerName[1] = (Substring((Name of (Triggering player)), 1, 1))
Set PlayerName[2] = (Substring((Name of (Triggering player)), 2, 2))
For each (Integer A) from 1 to 52, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Code[(Integer A)] Equal to PlayerName[1]
Then - Actions
Game - Display to (Player group((Triggering player))) the text: Code[(Integer A)]
Else - Actions
For each (Integer B) from 1 to 52, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Code[(Integer B)] Equal to PlayerName[2]
Then - Actions
Game - Display to (Player group((Triggering player))) the text: Code[(Integer B)]
Else - Actions
i have got that so far it works to get the letters but that is all i can get so far ill try some more stuff