• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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