Whipped this up for ya real quick, Just copy and paste it in a trigger.. it should be fine. Didn't test tho.
Spoiler:
Code:
function RegisterChatEvent takes trigger t, string s, returns nothing local integer i = 0 loop exitwhen i > 11 //How ever many players there are, 12 in this case call TriggerRegisterPlayerChatEvent(t , Player ( i ), s, false ) set i = i + t endloop endfunction
function NameChange takes nothing returns nothing local string s = GetEventPlayerChatString() local player p = GetTriggerPlayer() call SetPlayerName( p, SubString( s, 6, 20 ) ) set p = null endfunction
function init takes nothing returns nothing local trigger t = CreateTrigger() call RegisterChatEvent( t, "-name " ) call TriggerAddAction( t, function NameChange ) set t = null endfunction
It depends if you want in GUI or JASS I've tested both and they both worked....Be sure to make the Variables and make the Trigger Name: NameChange for that JASS one.
Spoiler:
GUI Player 1 (Red) types a chat message containing -name<space> as a Substring. If ((Length of (Entered Chat String)) Greater than 30) then do Player - Set name of (Triggering player) to (Substring((Entered Chat String), 7,30)
Spoiler:
JASS Variables: String Array [12] Named OldName, String Array [12] Named NewName Trigger Name: NameChange
Trigger: function Trig_NameChange_Conditions takes nothing returns boolean if ( SubStringBJ(StringCase(GetEventPlayerChatString(), false), 1, 6) == "-name " ) then return true endif return false endfunction
function Trig_NameChange_Actions takes nothing returns nothing local string oldName = udg_OldName[GetConvertedPlayerId(GetTriggerPlayer())] local string newName = udg_NewName[GetConvertedPlayerId(GetTriggerPlayer())] if GetBooleanOr(oldName == "", oldName == null) then set oldName = GetPlayerName(GetTriggerPlayer()) set newName = SubStringBJ(GetEventPlayerChatString(), 7, 23) call SetPlayerName( GetTriggerPlayer(), newName ) else set newName = SubStringBJ(GetEventPlayerChatString(), 7, 23) call SetPlayerName( GetTriggerPlayer(), newName ) endif set udg_OldName[GetConvertedPlayerId(GetTriggerPlayer())] = oldName set udg_NewName[GetConvertedPlayerId(GetTriggerPlayer())] = newName endfunction
Users browsing this forum: No registered users and 13 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum