Joined: November 3rd, 2010, 10:48 am Posts: 1850 Location: Singapore
Title: Best Player
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.
Joined: February 24th, 2009, 1:31 pm Posts: 3815 Location: JEW LAND
under function main
Code:
call nameFunction()
under endglobals
Code:
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
_________________
Spoiler:
(02:24:09)
Code:
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:
(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:
(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:
(15:42:51) Lanaya: can i suck , . . .
Code:
(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:
GeorgeMots: xplain what happens in SP. Why cant you save? dast.-:i need play with 2 players
Code:
(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:
(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
Joined: November 3rd, 2010, 10:48 am Posts: 1850 Location: Singapore
Title: Best Player
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.
Joined: February 24th, 2009, 1:31 pm Posts: 3815 Location: JEW LAND
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:
trigger stringCommands=CreateTrigger()
function main
Code:
call initStringCommands()
EndGlobals
Code:
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.
_________________
Spoiler:
(02:24:09)
Code:
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:
(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:
(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:
(15:42:51) Lanaya: can i suck , . . .
Code:
(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:
GeorgeMots: xplain what happens in SP. Why cant you save? dast.-:i need play with 2 players
Code:
(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:
(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
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.
Joined: February 24th, 2009, 1:31 pm Posts: 3815 Location: JEW LAND
And is it working?
_________________
Spoiler:
(02:24:09)
Code:
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:
(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:
(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:
(15:42:51) Lanaya: can i suck , . . .
Code:
(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:
GeorgeMots: xplain what happens in SP. Why cant you save? dast.-:i need play with 2 players
Code:
(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:
(10:08:02) Bartimaeus: you do know run I youtube channel for my favorite music, right?
Joined: November 3rd, 2010, 10:48 am Posts: 1850 Location: Singapore
Title: Best Player
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
_________________ 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.
Users browsing this forum: No registered users and 25 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