Hi. For starters, i'd like to point out I am new to the forums here, so do not be harsh with any actions I make that are accidental here.
Anyways, I am trying to create a unit for a specific player (so, say, this trigger will take the name of a player and compare it to a string, and if it returns true, allow the player to be able to do custom commands).
Then, I want the player to be able to access a special unit exclusive to that player.
So for a visual...
(RNX is allowed to use commands, because RNX = String!)
RNX: /Spawn Zergling
(A Zergling spawns under RNX's control!)
However... I have no idea how to set this up in triggers... this is my first trigger, and may be my last.
Hey there, duno what u rlly want to as i didnt rlly understand all u wanna do but hope this helps u,make an action in the trigger with create unit (here are some mroe options which u can costumize, for eg facing and number) for the specific player (1 for eg). Now if u want to spawn that unit only for an unique player, u need to use player handles. If player handle is this then do that. Atm cant tell u specific names cause im not at home and dont remember exact names. This is a guide to player handles : http://www.sc2mapster.com/forums/development/triggers/26109-101-guide-to-player-handles/#p17
Also im curious aswell if this can be done "this trigger will take the name of a player and compare it to a string" as I dont think its possible. =
Ah well see I'm a programmer, and the way I see it, a players name is a string of text. So, it should be able to be ran through an if statement. And, Ill try that when I get home today, thanks! Will update later :)
there is no, and there will never be a function that translate text to string. all you can do with text is showing it to the player or manipulating it and then show it to the player. player handle is indeed the way to go in sc2 (not like wc3), player handles are unique for the player. also you cant change the name of a player.
So, essentially, all I need to do is acquire the player I.D, run a check on each player and see if the I.D matches, and if it does, allow that player to use these custom commands?
So, I'm not sure you understand how the SC2 Editor works completely. If you just want it so that any player can type commands, you dont need to check if their name is a string. If you only want some players, you can make a condition of (owner of player(triggering player) == # of player you want to check). Then you just make an event that says (player enters chat string "/command you want" matching exactly). Then put in the actions, create zergling for (triggering player). Or if you have multiple commands to add, you can put them all in the events, and use if statements to determine which one they typed in. Hope this helps!
If you need help with the editor, check out the tutorial link in my signature, it has tutorials for almost everything.
Here is a very basic trigger setup that will would allow you to restrict commands to specific players.
If you are a programmer it should be pretty straight forward if you just read through slowly, but a few things to note. The OR statement is only necessary if you want multiple people to have access to the commands. As far as I'm aware you can't actually use slash commands, so what most people do is just create an event handler for chat messages with their own key (example only triggers when the message contains a hyphen). The player handle is a string and the player name is a text value as people were saying previously. You cannot use a text value in a comparison statement, but you can use it when you are actually displaying text to the user. Also if you were unaware, player variables themselves are integers.
Keep in mind that restricting commands by player handle means you would need to update the map anytime you wanted to allow more users to have access to certain commands. If you want to have players unlock access to commands over time just by playing, you'll need to look into bank files.
Outstanding answer, I understand it completely. Im the type where a visual will work over words or text.
In English: Thank you for taking your time to answer! Not only do I benefit, but others in the future will benefit from this too.
Oh, and haha, it's a mod, not a map. My objective is to make a special unit spawn for only I, the developer, not out of selfishness, but purely for testing.
Thanks guys, problem solved. :D
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hi. For starters, i'd like to point out I am new to the forums here, so do not be harsh with any actions I make that are accidental here.
Anyways, I am trying to create a unit for a specific player (so, say, this trigger will take the name of a player and compare it to a string, and if it returns true, allow the player to be able to do custom commands).
Then, I want the player to be able to access a special unit exclusive to that player.
So for a visual...
(RNX is allowed to use commands, because RNX = String!)
RNX: /Spawn Zergling
(A Zergling spawns under RNX's control!)
However... I have no idea how to set this up in triggers... this is my first trigger, and may be my last.
Hey there, duno what u rlly want to as i didnt rlly understand all u wanna do but hope this helps u,make an action in the trigger with create unit (here are some mroe options which u can costumize, for eg facing and number) for the specific player (1 for eg). Now if u want to spawn that unit only for an unique player, u need to use player handles. If player handle is this then do that. Atm cant tell u specific names cause im not at home and dont remember exact names. This is a guide to player handles : http://www.sc2mapster.com/forums/development/triggers/26109-101-guide-to-player-handles/#p17
Also im curious aswell if this can be done "this trigger will take the name of a player and compare it to a string" as I dont think its possible. =
@HuniFTW: Go
Ah well see I'm a programmer, and the way I see it, a players name is a string of text. So, it should be able to be ran through an if statement. And, Ill try that when I get home today, thanks! Will update later :)
@bvanseghi: Go
Im a programmer too and ik what u mean cause i thought the same but after a quick try I didn't find how to do it so i used this uniques sc2 ID.
there is no, and there will never be a function that translate text to string. all you can do with text is showing it to the player or manipulating it and then show it to the player. player handle is indeed the way to go in sc2 (not like wc3), player handles are unique for the player. also you cant change the name of a player.
So, essentially, all I need to do is acquire the player I.D, run a check on each player and see if the I.D matches, and if it does, allow that player to use these custom commands?
Correct. The Player Handle is the unique ID to any and all b.net accounts.
@ArcaneDurandel: Go
Alright... So I did some playing around in the triggers, but can't seem to find what I am looking for.
So, I'm not sure you understand how the SC2 Editor works completely. If you just want it so that any player can type commands, you dont need to check if their name is a string. If you only want some players, you can make a condition of (owner of player(triggering player) == # of player you want to check). Then you just make an event that says (player enters chat string "/command you want" matching exactly). Then put in the actions, create zergling for (triggering player). Or if you have multiple commands to add, you can put them all in the events, and use if statements to determine which one they typed in. Hope this helps!
If you need help with the editor, check out the tutorial link in my signature, it has tutorials for almost everything.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
Here is a very basic trigger setup that will would allow you to restrict commands to specific players.
If you are a programmer it should be pretty straight forward if you just read through slowly, but a few things to note. The OR statement is only necessary if you want multiple people to have access to the commands. As far as I'm aware you can't actually use slash commands, so what most people do is just create an event handler for chat messages with their own key (example only triggers when the message contains a hyphen). The player handle is a string and the player name is a text value as people were saying previously. You cannot use a text value in a comparison statement, but you can use it when you are actually displaying text to the user. Also if you were unaware, player variables themselves are integers.
Keep in mind that restricting commands by player handle means you would need to update the map anytime you wanted to allow more users to have access to certain commands. If you want to have players unlock access to commands over time just by playing, you'll need to look into bank files.
@ZMilla93: Go
Outstanding answer, I understand it completely. Im the type where a visual will work over words or text.
In English: Thank you for taking your time to answer! Not only do I benefit, but others in the future will benefit from this too.
Oh, and haha, it's a mod, not a map. My objective is to make a special unit spawn for only I, the developer, not out of selfishness, but purely for testing.
Thanks guys, problem solved. :D