Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 261 62 63338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
redefinder has written
Flacko has written
Quote
You can't place more than 9 buttons in a single Lua menu, try using different pages.

Yes i know,i was asking if anyone could tell me how to make more classes by making different pages with next.PLEASE HELP!


Leegao gave you a link...

old Getting started with lua.

Anders4000
User Off Offline

Quote
Hi all...

i'm a little bit noob if we are talking about lua scripting

But couldn't someone make a tut and post it on youtube or something??

I realy wanna make mods and just fun scripts...


- Akd

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
is it possible make a script that on second hook and hit by combining? I want to make that player choose class and when hit enemy and his hp -3 PER second, could someone
show me a basic for that

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Admirdee has written
is it possible make a script that on second hook and hit by combining? I want to make that player choose class and when hit enemy and his hp -3 PER second, could someone
show me a basic for that


Make a table to store the "poisoned" players, then use the hit hook to "poison" a player.
Use the second hook to cycle through the table and if the player is poisoned, reduce it's health
You can check the RPG script that I uploaded some months ago
http://www.unrealsoftware.de/files_show.php?file=1486

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Admirdee has written
I still don't get it, the script make my brain confuse
I need more VERY basic script


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function makemeatableplz(size,value)
	local imatable={}
	for i=1,size do
		imatable[i]=value
	end
	return imatable
end

poisonedplayers = makemeatableplz(32,false) --This will let us know when a player is poisoned

---->HOOKS WITH THEIR FUNCS<-----

addhook("hit","my_hit_func")
function my_hit_func(id,src)
	if(SRC CAN POISON) then --replace this acording to ur script
		poisonedplayers[id]=true --Player is poisoned
	end
end

addhook("second","my_sec_func")
function my_sec_func()
	for i=1,32 do --Cycle through players
		if(poisonedplayers[i]==true) then
			parse("sethealth "..i.." "..player(i,"health")-3)--Decrease health
		end
	end
end

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
how do you make buildings
i do not understand this
1
2
function base_1(id,t,x,y)
	build(id,8,x+1,y+1,t)
please help
edited 1×, last 03.10.09 11:54:54 pm

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Admirdee has written
1
poisonedplayers = makemeatableplz(32,false)

what is the false for?


I could have used false or 0, i chosed false.
If you keep reading the script you will find that I wrote true, i also could have written 1 instead of true

Edit; more info here:
http://www.lua.org/pil/2.2.html

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
starkzzz has written
hey, can help me with this lua...

addhook("attack", "admod")
function admod(id,wpn)
parse("strip "..id.." 10")
parse("equip "..id.." 10")
parse("setweapon "..id.." 10")
end

this function is only on m3, i need put to all weapons.
is no_reload lua i need help with it please


The attack hook has only got one parameter and it's ID.
You have to do this:
1
2
3
4
5
6
7
addhook("attack", "admod")
function admod(id,wpn)
	local weapon=player(id,"itemtype")
	parse("strip "..id.." "..weapon)
	parse("equip "..id.." "..weapon)
	parse("setweapon "..id.." "..weapon)
end

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
1
2
3
4
5
6
addhook("hit","my_hit_func")
function my_hit_func(id,src)
     if(SRC CAN POISON) then --replace this acording to ur script
          poisonedplayers[id]=true --Player is poisoned
     end
end

the source can be replace with classes id?

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
try just using

parse("equip "..id.." "..weapon)

the function parameter 'wpn' is correct since it's not used by the code and merely functions as an auxiliary variable.

old Save A Variable

Toa Hero 92
User Off Offline

Quote
Hi, I want to make a script that will stream a players position to me. I thought of this as a start but I don't think it will work, because i don't know how how to save x, y, tilex, tiley as variables. To be more specific, I want it to stream to me in the chat, and the message to be like playerid is at pixel x, y and tile tilex, tiley. (with no bold or italics of course). It will know who to send the message to by a pre-provided usgn id number (which will be mine and my rcon admin's). Ok, um... I think that is all you'll need to know, because i know that you're not lua noobs (unlike me XP), so.. here is the code I thought of:

1
2
3
4
5
6
7
8
9
10
11
12
addhook("join","adminhaspos")
function adminhaspos(id)

--Admin Usgn Id List--
[i]the admin usgn list will go here is the form of :[/i]
admin1 = usgnidnum
admin2 = usgnidnum
[i]etc...[/i]
if (id>0)then
if (player(id, "usgn") ==[i]any of the values saved in the list[/i]
[i]maybe a menu could be put here with a text input field for the player's id that you want to track. !!! I don't have any clue on how to do this so please help!!![/i]
then parse("sv_msg2 " ..id.." [i]the player they wanted to track[/i] is at "..player(id,"x").." "..player(id,"y").." in pixels and at "..player(id,"tilex").." "..player(id,"tiley").." in tiles")

But I don't think this will work, so please help me, and, if you would like to help me develop it I would not dream of saying No, but then you should know that all i know of lua programming is from the example provided with the game and from the good people of this forum thread.

F.Y.I. I don't check back often.

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
[b]
--Admin Usgn Id List-- 
admins = {}
admins[usgnidnum] = true
admins[usgnidnum2] = true
--keep listing the admins in this pattern
[/b]
--String.Split - splits a string into a table based on spaces or other delimiters.
function string.split(t, b)
	local cmd = {}
	local match = "[^%s]+"
	if b then
		match = "%w+"
	end
	if type(b) == "string" then match = "[^"..b.."]+" end
	if not t then return invalid() end
	for word in string.gmatch(t, match) do
		table.insert(cmd, word)
	end
	return cmd
end

--Resolves USGN to the current game's Player IDs, if not found, returns nil
function resolve_usgn(usgn)
	if usgn < 1 then return end
	for i=1,32 do
		if player(i, 'usgn') == usgn then return i
	end
end

--Finds the location of the player at id and msg2's it to the player at orig
function get_position(id, orig)
	if id < 1 then return end
	local msg = "sv_msg2 %s The player is at %s %s in pixels and %s %s in tiles"
	parse(msg:format(orig, player(id, 'x'), player(id, 'y'), player(id, 'tilex'), player(id, 'tiley')))
end

--Broadcasts the position of the other_player to all of the admins
function broadcast_admins(other_player) 
	for admin in pairs(admins) do
		local id = resolve_usgn(admin)
		if id then get_position(other_player, id) end
	end
end

--Say hook
function position_say(id, text)
	if not admins[player(id, 'usgn')] then return end

	local cmd = text:split()
	if cmd[1] == "!position" then
		local _id_ = tonumber(cmd[2])
		if not _id_ then return end
		broadcast_admins(_id_)
		return 1
	end
end
addhook("say", "position_say")

Usage: go into chat and type in !position ID and this will automatically broadcasts the ID to all of the administrators.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Admirdee has written
1
2
3
4
5
6
addhook("hit","my_hit_func")
function my_hit_func(id,src)
     if(SRC CAN POISON) then --replace this acording to ur script
          poisonedplayers[id]=true --Player is poisoned
     end
end

the source can be replace with classes id?


If you mean something like replacing
1
if(SRC CAN POISON)
with something like
1
if(player_classes[src]==CLASS_THAT_CAN_POISON) then
Yes, you can and you should do it if you want the script to work

@Starkzzz:
Try using this as leegao said:
1
2
3
4
5
addhook("attack", "admod")
function admod(id,wpn)
local weapon=player(id,"itemtype")
parse("equip "..id.." "..weapon)
end
edited 1×, last 05.10.09 03:44:49 am

old New Problem

starkzzz
COMMUNITY BANNED Off Offline

Quote
ohh i look the console and start new problem...

LUA ERROR: sys/lua_noreload.lua: 4 attempt to concatenate local 'weapon' (a boolean value)

Then what is the problem?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
starkzzz has written
LUA ERROR: sys/lua_noreload.lua: 4 attempt to concatenate local 'weapon' (a boolean value)

Then what is the problem?

LOL... Atleast can you show your code if changed something?

I guess its this code?
1
2
3
4
5
addhook("attack", "admod")
function admod(id,wpn)
local weapon=player(id,"itemtype")
parse("equip "..id.." "..weapon)
end

function admod(id,wpn)

but I guess you are calling "weapon" value.

There is local weapon = player(id,"itemtype") ,but function already have weapon parameter.
To the start Previous 1 261 62 63338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview