Simple Change name Command?

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

User avatar
zamundax
Forum Fanatic
Posts: 342
Joined: October 8th, 2008, 4:21 pm

Simple Change name Command?

Post by zamundax »

How can I insert a simple change name Command
That requires no activation
And evry one can use it
Spoiler:
Image
Kidn
User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Re: Simple Change name Command?

Post by Risen »

Here's the one I wrote for my map, You'll need JNGP to compile it.
Spoiler:

Code: Select all

scope ChangeName initializer init
 
    globals
        private constant string        TRIGGER     = "-" // The activator E.G. "-name"
        private constant string        COMMAND     = "name" //The Cmd E.G. "-changename"
        private constant integer       LENGTH      = StringLength( TRIGGER ) + StringLength( COMMAND )
        private constant integer       MAX_LENGTH  = 16 // Maximum characters E.G. "-name 123456789123456"
 
        private          string  array pSaveListed
        private          integer       pSaveCount  = 0
    endglobals
 
    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
 
        return false
    endfunction
 
    private function conditions takes nothing returns boolean
        return SubString( GetEventPlayerChatString(), 0, LENGTH ) == TRIGGER + COMMAND
    endfunction
 
    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
Image
Wanna learn to hack maps? --> Guide
User avatar
zamundax
Forum Fanatic
Posts: 342
Joined: October 8th, 2008, 4:21 pm

Re: Simple Change name Command?

Post by zamundax »

Yeah but I am not going to insert it in my map
I want to insert it from JassCraft
Spoiler:
Image
Kidn
User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Re: Simple Change name Command?

Post by Risen »

There should be a built one in a few cheatpacks.
Image
Wanna learn to hack maps? --> Guide
User avatar
Ken
Spice Pirate
Posts: 862
Joined: January 29th, 2009, 5:35 pm
Title: LHC
Location: Canada

Re: Simple Change name Command?

Post by Ken »

This should work, probably. Works like "-name x" where x is the new name you want.

Code: Select all

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
Spoiler:
xkiska wrote:BARTIMEAUS is more understandable then u
Senethior459 wrote:Wow, Dream Theatre reminds me of Dragonforce, but with real skill.
Ozzapoo wrote:We laughed, we cried. Trashed.
FatherSpace: You don't find smart chicks hawt?
GeorgeMots: not anymore, im fed up with that kind of girls
FatherSpace: lol
FatherSpace: What happened?
GeorgeMots: most smart girls find out that i date/do/see other girls....
FatherSpace: ...
FatherSpace: So monogamy is your enemy?
Bartimaeus: Hmm, well, I hope my sister hasn't been kidnapped.
FatherSpace: What happened, Bart?
Bartimaeus: She walked out of the house saying that she was going over to some friends, and it's been like two hours, and my mom is trying to get a hold of her, which she's been unable to.
Bartimaeus: I can also hear three car alarms going off.
GeorgeMots: how old is she?
Bartimaeus: I haven't a clue. Probably 17.
UndeadxAssassin: wut
AbusivePie: You don't know how old your sister is?
Bartimaeus: Nope.
UndeadxAssassin: Epic fail
GeorgeMots: is she cute??
Bartimaeus: So, uh, how about you get into the Christmas spirit and put that avatar on before I do it myself and take away your bloody avatar-changin' rights?
UndeadxAssassin: If I thought of a random one...
UndeadxAssassin: Like....
UndeadxAssassin: I'll get back to you on that
User avatar
zamundax
Forum Fanatic
Posts: 342
Joined: October 8th, 2008, 4:21 pm

Re: Simple Change name Command?

Post by zamundax »

Try it.It doesn't work
Spoiler:
Image
Kidn
User avatar
Ken
Spice Pirate
Posts: 862
Joined: January 29th, 2009, 5:35 pm
Title: LHC
Location: Canada

Re: Simple Change name Command?

Post by Ken »

Ops, no endif.

Just add in an endif above the endfunction. :D
Spoiler:
xkiska wrote:BARTIMEAUS is more understandable then u
Senethior459 wrote:Wow, Dream Theatre reminds me of Dragonforce, but with real skill.
Ozzapoo wrote:We laughed, we cried. Trashed.
FatherSpace: You don't find smart chicks hawt?
GeorgeMots: not anymore, im fed up with that kind of girls
FatherSpace: lol
FatherSpace: What happened?
GeorgeMots: most smart girls find out that i date/do/see other girls....
FatherSpace: ...
FatherSpace: So monogamy is your enemy?
Bartimaeus: Hmm, well, I hope my sister hasn't been kidnapped.
FatherSpace: What happened, Bart?
Bartimaeus: She walked out of the house saying that she was going over to some friends, and it's been like two hours, and my mom is trying to get a hold of her, which she's been unable to.
Bartimaeus: I can also hear three car alarms going off.
GeorgeMots: how old is she?
Bartimaeus: I haven't a clue. Probably 17.
UndeadxAssassin: wut
AbusivePie: You don't know how old your sister is?
Bartimaeus: Nope.
UndeadxAssassin: Epic fail
GeorgeMots: is she cute??
Bartimaeus: So, uh, how about you get into the Christmas spirit and put that avatar on before I do it myself and take away your bloody avatar-changin' rights?
UndeadxAssassin: If I thought of a random one...
UndeadxAssassin: Like....
UndeadxAssassin: I'll get back to you on that
User avatar
ZaXTheAlien
Senior Member
Posts: 136
Joined: June 9th, 2007, 11:27 pm
Location: Indonesia

Re: Simple Change name Command?

Post by ZaXTheAlien »

with your code you loop it forever at ii=0

Code: Select all

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

fixed
Image