• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

changing players names

Status
Not open for further replies.
Level 5
Joined
Mar 21, 2007
Messages
155
hi i am killing myself with this one thing that i can't seem to get right. changing players names (i.e a player types a chat message like -set name *name here*) but i can't figure out how substrings work, and i can't find an unprotected warcraft 3 map that has this feature. plz help!! i have been trying for the past hour!! ty
 
[TRIGGER=GUI Trigger]
Player - Player 1 (Red) types a chat message containing -set name as A substring
Player - Player 2 (Blue) types a chat message containing -set name as A substring
Player - Player 3 (Teal) types a chat message containing -set name as A substring

Set s = (Substring((Entered chat string), 11, (Length of (Entered chat string))))
Player - Set name of (Triggering player) to s
Game - Display to (All players) the text: (Name of (Triggering player))
[/TRIGGER]

[JASS=JASS Script]
function Trig_Melee_Initialization_Copy_Actions takes nothing returns nothing
local string s = SubString(GetEventPlayerChatString(),11-1,StringLength(GetEventPlayerChatString()))
call SetPlayerName( GetTriggerPlayer(), s )
call DisplayTextToForce( GetPlayersAll(), GetPlayerName(GetTriggerPlayer()) )
endfunction

//===========================================================================
function InitTrig_Melee_Initialization_Copy takes nothing returns nothing
set gg_trg_Melee_Initialization_Copy = CreateTrigger( )
call TriggerRegisterPlayerChatEvent( gg_trg_Melee_Initialization_Copy, Player(0), "-set name ", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Melee_Initialization_Copy, Player(1), "-set name ", false )
call TriggerRegisterPlayerChatEvent( gg_trg_Melee_Initialization_Copy, Player(2), "-set name ", false )
call TriggerAddAction( gg_trg_Melee_Initialization_Copy, function Trig_Melee_Initialization_Copy_Actions )
endfunction
[/code]
 
Last edited:
I made a unprotected map of with this trigger going to upload it soon on this site, It's called Askaria... you can steal anything from my maps if you want. Unless it is protected like Sturlungar Final v.
 
Status
Not open for further replies.
Back
Top