[Jass] Setname
Moderator: Cheaters
-
- Forum Staff
- Posts: 1471
- Joined: November 3rd, 2010, 10:48 am
- Title: Not cool
- Location: Singapore
-
- Super Moderator
- Posts: 3197
- Joined: February 24th, 2009, 1:31 pm
- Location: JEW LAND
- Been thanked: 1 time
Re: how to make a simple -name function?
under function main
under endglobals
Code: Select all
call nameFunction()
Code: Select all
function actionFunc takes nothing returns nothing
//your function is here...
endfunction
function nameFunction takes nothing returns nothing
local integer looper=0
loop
exitwhen looper>11
if GetPlayerName(Player(looper))=="Enter Name Here"then
call actionFunc()
endif
set looper=looper+1
endloop
endfunction
-
- Forum Staff
- Posts: 1471
- Joined: November 3rd, 2010, 10:48 am
- Title: Not cool
- Location: Singapore
Re: how to make a simple -name function?
Hey haxorico, I knew it would be you helping this kind of request. Thanks a lot yeah.
Edit2:: Oh I forgot about the conditions. For any name that anyone uses, if they type in "-name fjie" then their name in the game change to fjie, of course the fjie can be any other names they "-name" to.
Edit3::
Globals
End Globals
I feel this is too lengthy, can you shorten it and make it in jass?
Edit2:: Oh I forgot about the conditions. For any name that anyone uses, if they type in "-name fjie" then their name in the game change to fjie, of course the fjie can be any other names they "-name" to.
Edit3::
Globals
Spoiler:
Spoiler:
-
- Super Moderator
- Posts: 3197
- Joined: February 24th, 2009, 1:31 pm
- Location: JEW LAND
- Been thanked: 1 time
Re: how to make a simple -name function?
1) I don't think it will work, mainly cause nothing is executing the YourName function, (It is being called at CustomName but that function isn't called or executed also)
globals
function main
EndGlobals
This should work, I can't test it at the moment or check for syntax errors, it was made on the spot and I don't have tools at the moment. Check for syntax errors before you use and if there are, post and Ill fix.
globals
Code: Select all
trigger stringCommands=CreateTrigger()
Code: Select all
call initStringCommands()
Code: Select all
function commands takes nothing returns nothing
local string command=StringCase(GetEventPlayerChatString(),false)
if SubString(command,0,6)=="-name "then
call SetPlayerName(GetTriggerPlayer(),SubString(command,6,StringLength(commanmd))
endif
set command=""
endfunction
function initStringCommands takes nothing returns nothing
local integer index=0
loop
exitwhen index>11
call TriggerRegisterPlayerChatEvent(stringCommands,Player(index),"",false)
set index=index+1
endloop
call TriggerAddAction(stringCommands,function commands)
endfunction
-
- Forum Staff
- Posts: 1471
- Joined: November 3rd, 2010, 10:48 am
- Title: Not cool
- Location: Singapore
Re: how to make a simple -name function?
Okay I fixed it
Code: Select all
globals
trigger stringCommands=CreateTrigger()
endglobals
function commands takes nothing returns nothing
local string command=StringCase(GetEventPlayerChatString(),false)
if SubString(command,0,6)=="-name "then
call SetPlayerName(GetTriggerPlayer(),SubString(command,6,StringLength(command)))
endif
set command=""
endfunction
function initStringCommands takes nothing returns nothing
local integer index=0
loop
exitwhen index>11
call TriggerRegisterPlayerChatEvent(stringCommands,Player(index),"",false)
set index=index+1
endloop
call TriggerAddAction(stringCommands,function commands)
endfunction
function main takes nothing returns nothing
call initStringCommands()
endfunction
-
- Super Moderator
- Posts: 3197
- Joined: February 24th, 2009, 1:31 pm
- Location: JEW LAND
- Been thanked: 1 time
-
- Forum Staff
- Posts: 1471
- Joined: November 3rd, 2010, 10:48 am
- Title: Not cool
- Location: Singapore
Re: how to make a simple -name function?
not yet tested.haxorico wrote:And is it working?
I'll test it later.
Edit:: Tested both of ours name function, worked.
I'll use yours since it's shorter
