[Jass] Setname

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

Apple
Forum Staff
Posts: 1470
Joined: November 3rd, 2010, 10:48 am
Title: Best Player
Location: Singapore

[Jass] Setname

Post by Apple »

Can anyone help me on making a -name function, as short as possible.
Request a map? Follow the rulesHERE
Request templateHERE
Please, do not PM me.
On the side note, I'm still playing vampirism speed on malaysia room, occasionally in Garena. Bcuz too lazy to find out where else I can play them.
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: how to make a simple -name function?

Post by haxorico »

under function main

Code: Select all

call nameFunction()


under endglobals

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
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
Apple
Forum Staff
Posts: 1470
Joined: November 3rd, 2010, 10:48 am
Title: Best Player
Location: Singapore

Re: how to make a simple -name function?

Post by Apple »

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
Spoiler:
trigger NameFunction=null

End Globals
Spoiler:
function Trig_Name_Conditions takes nothing returns boolean
if(SubStringBJ(StringCase(GetEventPlayerChatString(),false),1,6)=="-name ")then
return true
endif
return false
endfunction
function Trig_Name_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,26)
call SetPlayerName(GetTriggerPlayer(),newName)
else
set newName=SubStringBJ(GetEventPlayerChatString(),7,26)
call SetPlayerName(GetTriggerPlayer(),newName)
endif
set udg_oldName[GetConvertedPlayerId(GetTriggerPlayer())]=oldName
set udg_newName[GetConvertedPlayerId(GetTriggerPlayer())]=newName
endfunction
function YourName takes nothing returns nothing
set NameFunction=CreateTrigger()
call TriggerRegisterPlayerChatEvent(NameFunction,Player(0),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(1),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(2),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(3),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(4),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(5),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(6),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(7),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(8),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(9),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(10),"",false)
call TriggerRegisterPlayerChatEvent(NameFunction,Player(11),"",false)
call TriggerAddCondition(NameFunction,Condition(function Trig_Name_Conditions))
call TriggerAddAction(NameFunction,function Trig_Name_Actions)
endfunction
function CustomName takes nothing returns nothing
call YourName()
endfunction

I feel this is too lengthy, can you shorten it and make it in jass?
Request a map? Follow the rulesHERE
Request templateHERE
Please, do not PM me.
On the side note, I'm still playing vampirism speed on malaysia room, occasionally in Garena. Bcuz too lazy to find out where else I can play them.
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: how to make a simple -name function?

Post by haxorico »

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

Code: Select all

trigger stringCommands=CreateTrigger()


function main

Code: Select all

call initStringCommands()


EndGlobals

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


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.
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
Apple
Forum Staff
Posts: 1470
Joined: November 3rd, 2010, 10:48 am
Title: Best Player
Location: Singapore

Re: how to make a simple -name function?

Post by Apple »

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
Request a map? Follow the rulesHERE
Request templateHERE
Please, do not PM me.
On the side note, I'm still playing vampirism speed on malaysia room, occasionally in Garena. Bcuz too lazy to find out where else I can play them.
User avatar
haxorico
Super Moderator
Posts: 3190
Joined: February 24th, 2009, 1:31 pm
Location: JEW LAND

Re: how to make a simple -name function?

Post by haxorico »

And is it working?
Image
Spoiler:
(02:24:09)

Code: Select all

ChatBot: FatherSpace logs into the Chat.
(02:24:28) Lanaya: Gtfo ken.
(02:24:33) ChatBot: FatherSpace logs out of the Chat.
(02:24:40) Lanaya: Thought so. bitch.
(02:24:44) ChatBot: FatherSpace logs into the Chat.
(02:24:48) FatherSpace: Can I come back yet?
(02:24:51) Lanaya: What'd i say earlier.
(02:24:51) Lanaya: No.
(02:24:58) FatherSpace: Let's try this...
(02:25:01) ChatBot: Lanaya has been logged out (Kicked).

Code: Select all


(14:33:51) 2Pac: Do you know what'S so funny?
(14:34:01) Lanaya: No, please show me.
(14:34:07) 2Pac: This.
(14:34:09) ChatBot: Lanaya has been logged out (Kicked).
(14:34:10) 2Pac:


Code: Select all

(14:35:59) haxorico: No one will belive me if I say "I got this song from 2pac on MSN" lolz ^^
(14:36:02) Lanaya: lolz.
(14:36:16) 2Pac: I AIN'T DEAD FFS.
(14:36:26) 2Pac: I'm a living legend, y'now.
(14:37:17) haxorico: why is 2Pac a legend?
(14:37:28) Lanaya: He's the worse rapper evar.

Code: Select all

(15:42:51) Lanaya: can i suck , . . .

Code: Select all

(13:55:21) ChatBot: 2Pac rolls 1d100 and gets 1.
(13:55:21) ChatBot: haxorico rolls 1d2 and gets 2.
(13:55:27) haxorico: owned?

Code: Select all

GeorgeMots: xplain what happens in SP. Why cant you save?
dast.-:i need play with 2 players

Code: Select all

(21:53:08) (673237): plzplzplz, im sorry about before.
(21:53:26) FatherSpace: I'm sorry you were born.
(21:53:31) ChatBot: (673237) has been logged out (Kicked).


Code: Select all

(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
Apple
Forum Staff
Posts: 1470
Joined: November 3rd, 2010, 10:48 am
Title: Best Player
Location: Singapore

Re: how to make a simple -name function?

Post by Apple »

haxorico wrote:And is it working?

not yet tested.
I'll test it later.

Edit:: Tested both of ours name function, worked.
I'll use yours since it's shorter :D
Request a map? Follow the rulesHERE
Request templateHERE
Please, do not PM me.
On the side note, I'm still playing vampirism speed on malaysia room, occasionally in Garena. Bcuz too lazy to find out where else I can play them.