HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

doing something by player name

02-23-2006, 08:47 PM#1
Linera
How can i get the set a player variable when a player types in -invite <playername>?

What it is suppose to do is set a variable of both triggering player and player who's name was type in after -invite_
_ is a space
example code(not working right):

Trigger:
invite
Collapse Events
Player - Player 1 (Red) types a chat message containing -invite as A substring
Player - Player 2 (Blue) types a chat message containing -invite as A substring
Player - Player 3 (Teal) types a chat message containing -invite as A substring
Player - Player 4 (Purple) types a chat message containing -invite as A substring
Player - Player 5 (Yellow) types a chat message containing -invite as A substring
Player - Player 6 (Orange) types a chat message containing -invite as A substring
Player - Player 7 (Green) types a chat message containing -invite as A substring
Player - Player 8 (Pink) types a chat message containing -invite as A substring
Player - Player 9 (Gray) types a chat message containing -invite as A substring
Player - Player 10 (Light Blue) types a chat message containing -invite as A substring
Player - Player 11 (Dark Green) types a chat message containing -invite as A substring
Collapse Conditions
(Substring((Entered chat string), 1, 8)) Equal to -invite
Collapse Actions
Set triggerplayer2 = (Triggering player)
Set temp_string = (Substring((Entered chat string), 9, (Length of (Entered chat string))))
Collapse Player Group - Pick every player in (All players) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Name of (Picked player)) Equal to temp_string
Collapse Then - Actions
Set temp_player = (Picked player)
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
temp_string Not equal to <Empty String>
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
temp_string Not equal to (Name of (Triggering player))
Collapse Then - Actions
Set i = (Player number of temp_player)
Custom script: set udg_Invited = GetGroup(udg_i)
Set i = (Player number of (Triggering player))
Custom script: set udg_Triggerplayer = GetGroup(udg_i)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Invited Equal to 0
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Triggerplayer Equal to 0
Collapse Then - Actions
Custom script: set udg_EmptyParty = GetEmptyParty()
Player Group - Add triggerplayer2 to Party[EmptyParty]
Player Group - Add temp_player to Party[EmptyParty]
Game - Display to (All players) the text: (Name of temp_player)
Collapse Else - Actions
Game - Display to (Player group((Triggering player))) the text: error
Collapse Else - Actions
Game - Display to (Player group((Triggering player))) the text: ((Name of temp_player) + is in a party.)
Collapse Else - Actions
Game - Display to (All players) the text: you can't invite yo...
Collapse Else - Actions
Game - Display to (All players) the text: you must type in a ...
02-23-2006, 09:19 PM#2
Chuckle_Brother
Do a player pick, matching a string condition, comparing their name to the entered name.

The just grab their player index and you are laughing.
02-23-2006, 09:28 PM#3
Blade.dk
Never use Do Nothing calls btw, that is completely useless.
02-23-2006, 09:39 PM#4
Chuckle_Brother
Lol, doesn't it comment or something stupid like that whenever it becomes jass?
02-23-2006, 09:50 PM#5
Linera
i tried the pick all player then check to see if entered name matches name of picked player then set temp_player = picked player

it picks blue even if i type the name of another player like teal or orange.
02-23-2006, 10:08 PM#6
Whitehorn
Put in some checks at each variable assignment (like a game message printing the variable). Tnen you can check if your variables are all right.
02-23-2006, 10:32 PM#7
Linera
This is the new code and as before it only adds blue player to group and not the correct 2 players (triggering player and temp_player)
but in the text messages it says the correct name of temp_player

Trigger:
invite
Collapse Events
Player - Player 1 (Red) types a chat message containing -invite as A substring
Player - Player 2 (Blue) types a chat message containing -invite as A substring
Player - Player 3 (Teal) types a chat message containing -invite as A substring
Player - Player 4 (Purple) types a chat message containing -invite as A substring
Player - Player 5 (Yellow) types a chat message containing -invite as A substring
Player - Player 6 (Orange) types a chat message containing -invite as A substring
Player - Player 7 (Green) types a chat message containing -invite as A substring
Player - Player 8 (Pink) types a chat message containing -invite as A substring
Player - Player 9 (Gray) types a chat message containing -invite as A substring
Player - Player 10 (Light Blue) types a chat message containing -invite as A substring
Player - Player 11 (Dark Green) types a chat message containing -invite as A substring
Collapse Conditions
(Substring((Entered chat string), 1, 8)) Equal to -invite
Collapse Actions
Set triggerplayer2 = (Triggering player)
Set temp_string = (Substring((Entered chat string), 9, (Length of (Entered chat string))))
Collapse For each (Integer A) from 1 to 11, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Name of (Player((Integer A)))) Equal to temp_string
Collapse Then - Actions
Set temp_player = (Player((Integer A)))
Game - Display to (All players) the text: (Player check: + (Name of temp_player))
Collapse Else - Actions
Do nothing
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
temp_string Not equal to <Empty String>
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
temp_string Not equal to (Name of (Triggering player))
Collapse Then - Actions
Set i = (Player number of temp_player)
Custom script: set udg_Invited = GetGroup(udg_i)
Set i = (Player number of (Triggering player))
Custom script: set udg_Triggerplayer = GetGroup(udg_i)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Invited Equal to 0
Collapse Then - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Triggerplayer Equal to 0
Collapse Then - Actions
Custom script: set udg_EmptyParty = GetEmptyParty()
Player Group - Add temp_player to Party[EmptyParty]
Wait 1.00 game-time seconds
Player Group - Add triggerplayer2 to Party[EmptyParty]
Game - Display to (All players) the text: (Name of temp_player)
Collapse Else - Actions
Game - Display to (Player group((Triggering player))) the text: error
Collapse Else - Actions
Game - Display to (Player group((Triggering player))) the text: ((Name of temp_player) + is in a party.)
Collapse Else - Actions
Game - Display to (All players) the text: you can't invite yo...
Collapse Else - Actions
Game - Display to (All players) the text: you must type in a ...
02-25-2006, 12:42 AM#8
The_AwaKening
First thing I notice is that your substring numbers are wrong. Should be 1, 7.

Edit-- nevermind, shouldn't matter either way.
02-25-2006, 12:58 AM#9
Linera
it includes a space right after -invite