!m4a1 the m4a1 apears for you please help
Forum
CS2D Scripts Lua Scripts/Questions/Help!m4a1 the m4a1 apears for you please help
Admin has written
Need Help in how to script smthing like:
!m4a1 the m4a1 apears for you please help
!m4a1 the m4a1 apears for you please help
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
if sample==nil then sample={} end sample.say={} addhook("say","sample.say.say") function sample.say.say(id,msg) 	-- Give M4A1 	if (msg=="!m4a1") then 	parse("equip "..id.." "..32) 	return 1 	end end
this is only give you that weapon
Admin has written
Need Help in how to script smthing like:
!m4a1 the m4a1 apears for you please help
!m4a1 the m4a1 apears for you please help
Look at the lua archive next time.
http://www.unrealsoftware.de/files_show.php?file=1374
This doesn't work, I press button 1 but the other menu doesn't appear (Or maybe it appears but it closes inmediatly)
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
addhook("menu","flacko.rpg.menu") function flacko.rpg.menu(id,title,button) 	if(title=="MAIN MENU") then 		if(button==1) then 			flacko.rpg.weaponsl1(id) 		end 	end end
Other hard thing for me with coding itself is that i don`t know what i must do first inorder to do something to it.
For example, if i want to make a menu...I don`t know do i have to make the menu-base, menu buttons or what i need to make first...
*EDIT*And the hooks, is it just about logic to know which hook to use or is there other way i dont get?'
*EDIT2* And, does lua support "java-functions" like "&&" and "|"?
So, does anyone have ideas how can i improve myself, and how have you learned to visualize and know what to do first and so.
Jonzku777 has written
I think i know all the "Basics" in lua, but the biggest problem for me is to visualize what i am doing.
same here
LinuxGuy has written
same here
Jonzku777 has written
I think i know all the "Basics" in lua, but the biggest problem for me is to visualize what i am doing.
same here
That`s why it`s lot easier to use visual basic...but everyone starts to whine if you do
| = or
if txt==hey and txt2=guys
I think its like that :p
1
parse("sethealth "..source.." "..player(source,"Health")-30"")
Alternatively I could use 3 times slap ,but it would spam ...
edited 2×, last 14.06.09 11:25:49 am
1
parse("sethealth "..source.." "..player(source,"Health")-30)
Admin/mod comment
This is the wrong thread for such questions. In addition, there is a FAQ which helps. Just read the Server Problems / Guide / Checklist Thread /TheKilledDeath1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
addhook("killplayer","lightningstrike.killplayer") function lightningstrike.killplayer(p,t) end if (txt=="!slay") then parse("killplayer" "..id..") msg2(p, "©255255255The lightning has struck against "..player(p,"name").."!") parse("sv_sound \"sounds/lightningbolt.ogg\"") end
I want it to work like this
!slay 1 result The lightning has struck against Player!
edited 1×, last 14.06.09 05:15:16 pm
I did some corrections:
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
addhook("say","lightningstrike.killplayer") function lightningstrike.killplayer(p,txt) 	if(string.sub(txt,1,5)=="!slay") then 		slayedplayer = string.sub(txt, 7,string.len(txt)) 		parse("killplayer "..slayedplayer) 		msg("©255255255The lightning has struck against "..player(slayedplayer,"name").."!") 		parse("sv_sound \"sounds/lightningbolt.ogg\"") 	end end
TheKilledDeath has written
Tried your code but all it does is closes/crashes(can't tell) CS2D. Yes, the hook "killplayer" does not exist. It should be "say"
I did some corrections:
I did some corrections:
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
addhook("say","lightningstrike.killplayer") function lightningstrike.killplayer(p,txt) 	if(string.sub(txt,1,5)=="!slay") then 		slayedplayer = string.sub(txt, 7,string.len(txt)) 		parse("killplayer "..slayedplayer) 		msg("©255255255The lightning has struck against "..player(slayedplayer,"name").."!") 		parse("sv_sound \"sounds/lightningbolt.ogg\"") 	end end
&& = and
could this work?
if (txt=="!slay&&id")
if (msg=="!slay&&id") do these have same effect?
edited 1×, last 14.06.09 06:03:46 pm
&& = or
| = and
From the other language, and in lua it is "and" "or".
if (txt1=="!help") and (txt2=="cs2d") then
do this
end
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
function string.split(t,d) --Text and Delimiter 	if not d then d = "[^%s]+" end 	local cmd = {} 	for word in string.gmatch(t,d) do 		table.insert(cmd,word) 	end 	return cmd end
What this function will do is return a table with the words you supplied in the string t.
If you give another delimiter (d), like "[^,]+", it will return a table with the words separed with comma.
Example:
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
addhook("say","lightningstrike.killplayer") function lightningstrike.killplayer(p,txt) 	local asd = string.split(txt) 	if(asd[1]=="!slay") then 		local slayedplayer = asd[2] 		parse("killplayer "..slayedplayer) 		msg("©255255255The lightning has struck against "..player(slayedplayer,"name").."!") 		parse("sv_sound \"sounds/lightningbolt.ogg\"") 	end end
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
addhook("say","player_say") function player_say(p,txt) 	if (txt=="!slay") then 		parse("killplayer "..p) 		msg("©255255255The lightning has struck against "..player(p, "name").."!") 		parse("sv_sound \"wc3tft_2d/lightningbolt.ogg\"") 	end end
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
addhook("say","player_say") function player_say(p,txt) 	if (txt=="!slay USER") then 		parse("killplayer " "..player(p, "name")..") 		msg("©255255255The lightning has struck against "..player(p, "name").."!") 		parse("sv_sound \"wc3tft_2d/lightningbolt.ogg\"") 	end end