private function addSaveListed takes string s returns nothing set pSaveCount = pSaveCount + 1 set pSaveListed[pSaveCount] = StringCase( s, false ) endfunction
private function RegisterChatEvent takes trigger t, string s returns nothing local integer i = 0 loop exitwhen i > 11 call TriggerRegisterPlayerChatEvent( t, Player(i), s, false ) set i = i + 1 endloop endfunction
private function isSaveListed takes string s returns boolean local integer i = 0
set s = StringCase( s, false ) loop set i = i + 1 exitwhen i > pSaveCount
if s == pSaveListed[i] then return true endif endloop
private function actions takes nothing returns nothing local string e = GetEventPlayerChatString() local string s = SubString( e, LENGTH + 1, StringLength( e ) ) local integer l = StringLength( s ) local player p = GetTriggerPlayer()
if l > 0 and l < MAX_LENGTH then
if isSaveListed( s ) then call DisplayTextToPlayer( p, 0, 0, "You can't change your name to an Administrator." ) else call SetPlayerName( p, s ) endif endif set p = null endfunction
//=========================================================================== private function init takes nothing returns nothing local trigger t = CreateTrigger( ) call RegisterChatEvent( t, TRIGGER + COMMAND ) call TriggerAddCondition( t, Condition( function conditions ) ) call TriggerAddAction( t, function actions ) call addSaveListed( "The_Risen_One" ) set t = null endfunction
endscope
Re: Simple Change name Command?
Posted: May 11th, 2009, 1:26 pm
by zamundax
Yeah but I am not going to insert it in my map I want to insert it from JassCraft
Re: Simple Change name Command?
Posted: May 11th, 2009, 8:42 pm
by Risen
There should be a built one in a few cheatpacks.
Re: Simple Change name Command?
Posted: May 13th, 2009, 9:42 pm
by Ken
This should work, probably. Works like "-name x" where x is the new name you want.
globals Trigger trg_NameChange = CreateTrigger() // the rest of your globals endglobals
function NameChange_Actions takes nothing returns nothing local string s = GetEventPlayerChatString() local string s2 = SubString(s, 6, StringLength(s)+1) if SubString( s, 0, 6) == "-name " then call SetPlayerName( GetTriggerPlayer(), s2 ) endfunction
// the rest of your functions
function Main takes nothing returns nothing // function main locals local integer ii = 0 loop exitwhen ii > 11 call TriggerRegisterPlayerChatEvent( trg_NameChange, Player(ii), "-name ", false ) endloop call TriggerAddAction( trg_NameChange, function NameChange_Actions ) // the rest of function main
globals Trigger trg_NameChange = CreateTrigger() // the rest of your globals endglobals
function NameChange_Actions takes nothing returns nothing local string s = GetEventPlayerChatString() local string s2 = SubString(s, 6, StringLength(s)+1) if SubString( s, 0, 6) == "-name " then call SetPlayerName( GetTriggerPlayer(), s2 ) endif endfunction
// the rest of your functions
function Main takes nothing returns nothing // function main locals local integer ii = 0 loop exitwhen ii > 11 call TriggerRegisterPlayerChatEvent( trg_NameChange, Player(ii), "-name ", false ) set ii=ii+1 endloop call TriggerAddAction( trg_NameChange, function NameChange_Actions ) // the rest of function main