• 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.

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
 
Level 12
Joined
Jul 2, 2004
Messages
471
[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:
Level 4
Joined
Aug 31, 2007
Messages
38
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.
Top