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 2167 168 169338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Admirdee has written
@Anders4000

I guess this is what you need read =/

http://www.lua.org/pil/11.1.html


Thank you (: I'm gonna go ahead!

*Update: Lol! I actually understand it now I didn't thought i would do (;

Now the only thing i need is to get rid of the "attempt to call a nil value" (:

I know that the error is in the "akd_setpos_script_team"-section (i'll make that bold)
And i think that the error is that i'm using both nil, "" and {}...

Here is my full 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
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
[spoiler]
--[[ Info:
Script: AKD Setpos Script.

Credits:
1. Blazzingxx						- Helped with the "!setpos" command.

Features:
1. !Setpos <x> <y>					- Teleports the player to the desired location (in tiles).
2. !Save						- Saves the curret location.
3. !Load						- Loads the saved location.
4. !pps or !PlayerPositions				- Gives a list of all players locations.
One line from the !pps would look like this:		Name: XXX  |  ID: XXX  |  Player-position: XXX x XXX

Highlights:
1. You don't have to use capital or small letters.
2. When you change team the saved location is deleted.
--]]

function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end

savex = initArray(32)
savey = initArray(32)

admin={27747}		-- IMPORTANT: This is my USGN!

addhook("say","akd_setpos_script_setpos_say")
function akd_setpos_script_setpos_say(id, message)
	local cmd, m = {}, [[[^ ]+]]
	for word in string.gmatch(message, m) do table.insert(cmd, word); end
	if (string.sub(string.lower(message), 1, 7)=="!setpos") then
		if not (player(id, "health")==0) then
			local lenght = #cmd
			if (lenght==3) then
				local x, y = cmd[2], cmd[3]
				if (map("xsize")>=x-1) and (map("ysize")>=y-1) then
					parse ([[setpos ]]..id..[[ ]]..x*32-16 ..[[ ]]..y*32-16)
				elseif (lenght==3) and (map("xsize")+1<x+0) or (map("ysize")+1<y+0) then
					msg2(id, "©255000000Setpos ERROR: Too Big Parameters!")
				end
			elseif (lenght<3) then
				msg2(id, "©255000000Setpos ERROR: Not Enough Parameters!")
			elseif (lenght>3) then
				msg2(id, "©255000000Setpos ERROR: Too Many Parameters!")
			end
		else
			msg2(id, [[©255000000Setpos ERROR: You can't use command "!Setpos" when you are dead!]])
		end
	end
end

addhook("always","akd_setpos_script_always")
function akd_setpos_script_always()
	rot={}
	for id = 1, game("sv_maxplayers"), 1 do
		if player(id,"exists") then
			rot[id] = player(id,"rot")
			ppx = math.ceil(player(id, "x")+1)
			ppy = math.ceil(player(id, "y")+1)
			parse([[hudtxt2 ]]..id..[[ 6 "©000255000Player-Position:" 5 170]])
			parse([[hudtxt2 ]]..id..[[ 7 "©000255000Pixels: ]]..ppx..[[ x ]]..ppy..[[" 5 183]])
			parse([[hudtxt2 ]]..id..[[ 8 "©000255000Tiles: ]]..player(id,"tilex")+1 ..[[ x ]]..player(id,"tiley")+1 ..[[" 5 196]])
			if (savex[id]==nil) or (savey[id]==nil) then
				parse([[hudtxt2 ]]..id..[[ 9 "©000255000Saved location: No saved location!" 5 209]])
			else
				parse([[hudtxt2 ]]..id..[[ 9 "©000255000Saved location: ]]..savex[id]..[[ x ]]..savey[id]..[[" 5 209]])
			end
		end
	end
end

addhook("say","akd_setpos_script_save_load_say")
function akd_setpos_script_save_load_say(id, message)
	rot={}
	rot[id] = player(id,"rot")
	if (string.lower(message)=="!load") then
		if not (player(id, "health")==0) then
			if (savex[id]==nil) or (savey[id]==nil) then
				msg2(id, "©255000000No saved location to load!")
			else
				parse([[setpos ]]..id..[[ ]]..savex[id]*32-16 ..[[ ]]..savey[id]*32-16)
				msg2(id, "©000255000Location successfully loaded!")
			end
		else
			msg2(id, [[©255000000Setpos ERROR: You can't use command "!Load" when you are dead!]])
		end
	end
	if (string.lower(message)=="!save") then
		if not (player(id, "health")==0) then
			savex[id] = player(id,"tilex")+1
			savey[id] = player(id,"tiley")+1
			if (savex[id]==player(id,"tilex")+1) and (savey[id]==player(id,"tiley")+1) then
				msg2(id, "©000255000Location successfully saved!")
			else
				msg2(id, "©255000000Location not saved!")
			end
		else
			msg2(id, [[©255000000Setpos ERROR: You can't use command "!Save" when you are dead!]])
		end
	end
end

[b]addhook("team","akd_setpos_script_team")[/b]
function akd_hud_pp_save_team(id)
	if not (savex[id]=="") or not (savex[id]==nil) or not (savex[id]=={}) then
		savex[id]=nil
		savey[id]=nil
	end
[b]end[/b]

addhook("say","akd_setpos_script_pps_say")
function akd_setpos_script_pps_say(id, message)
	if (player(id, "usgn")==admin) then
		if (string.lower(message)=="!playerpositions") or (string.lower(message)=="!pps") then
			msg2(id, "©255255255Player Positions:")
			for i = 1, game("sv_maxplayers"), 1 do
				if player(i, "exists") then
					if not (player(i, "health")==0) then
						msg2(id, [[©255255255Name: ]]..player(i,"name")..[[  |  ID: ]]..i..[[  |  Player-position: ]]..player(i,"tilex")+1 ..[[ x ]]..player(i,"tiley")+1)
					else
						msg2(id, [[©255255255Name: ]]..player(i,"name")..[[ *DEAD*  |  ID: ]]..i)
					end
				end
			end
		end
	end
end

print("©000255000AKD Setpos Script successfully launched!")
[/spoiler]

Another thing: Can't you tell me what the "look" does in the hook "team"?
edited 3×, last 20.02.10 09:56:12 pm

old Re: Lua Scripts/Questions/Help

DRoNe
User Off Offline

Quote
1
attempt to perform arithmetic on filed '?' (a nil value)

What is this ??? O.O
How i repair it ?
edited 1×, last 20.02.10 09:55:00 pm

old Re: Lua Scripts/Questions/Help

Decks
User Off Offline

Quote
someone clever can help me with my problem?

its very important for me how create lua scrypt for other specmode for spectators or simple player

someone help me?

old Re: Lua Scripts/Questions/Help

Admir
User Off Offline

Quote
Anders4000 has written
Another thing: Can't you tell me what the "look" does in the hook "team"?


It's player skin selection, for example

0 - Seal Team
1 - GSG9
2 - SAS
3 - GIGN

I don't know for vip

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
Yamato4147 has written
Can anyone please make a script for me that triggers map button thanks

just enter the button name @ btt (button to trigger)

1
2
3
4
5
6
7
btt = " "

addhook ("second", "sec")

function sec ()
	parse("trigger "..btt)
end

old Re: Lua Scripts/Questions/Help

Anders4000
User Off Offline

Quote
Admirdee has written
Anders4000 has written
Another thing: Can't you tell me what the "look" does in the hook "team"?


It's player skin selection, for example

0 - Seal Team
1 - GSG9
2 - SAS
3 - GIGN

I don't know for vip


Ohh :p Thank you (:

old Re: Lua Scripts/Questions/Help

dENd
User Off Offline

Quote
Ive came with this idea by playing STALKER Clear Sky!
It should be something like events for example bleeding it should be that every sec you lose a small amount of hp and the pos where the player is standing (the one that bleeds) should apear a blood decal...now to stop bleeding u must get bandage or F2-Inventory-[bandage X3]
now bleeding isnt the only event there should be hunger, weight(to many stuff in inventory)...
NOW FOR MENU
It should be simple
F2 opens a menu called Backpack or Inventory,it should contain current weapons,equipment,bandages,medikits...
The should be something like a carry limiter like 10 stuff max.!...
Contact me if you are a good scriptier who will help
- Email address (only visible with login) -

btw.bamdages and medikits could be pickedup by player.

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
I hate stalker, and I hate scripts completely based on games alredy made even more.
edited 1×, last 25.02.10 12:44:38 am

old Re: Lua Scripts/Questions/Help

Homer
User Off Offline

Quote
Alright, I am trying to write something in a text document, like something simple, and it isn't needed to be read, I just need it to write it, could someone pls tell me how to do that, I'm not getting anything from other scripts I'm looking at.

old Re: Lua Scripts/Questions/Help

- Dark Void -
User Off Offline

Quote
@Homer

use the io.open() function
read the spoiler for more info from www.lua.org
Spoiler >


Example: important stuff in bold
You want to write a file named: MyDoc.txt
You want to write a variable and some text.
1
2
3
4
5
[b]my_var[/b]=16*2

[b]file[/b]=[i]io.open[/i]("[b]MyDoc.txt[/b]", [b]"w"[/b]) --Select the file to read/write, put it in write mode
file[b]:[/b][i]write[/i]("My Variable is: "[b]..[/b]my_var[b]..[/b]) --write the data
file[b]:[/b][i]close[/i]()  --Close the file
this would then create a file named MyDoc.txt in you CS2D folder with this written inside "My Variable is: 32"
also try using different modes to see what happens and try to write other data to the file

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
I think i'm slow or something

but i never noticed this thing til today,

1
2
3
4
5
6
7
8
9
10
11
12
cmid = 0
	pwnid = 0
	for admid = 1,32 do
		if player(admid,"usgn") == ##### then
			cmid = admid
		break
		end
		if player(admid,"usgn") == ##### then
			pwnid = admid
		break
		end
	end

This shit works

old Re: Lua Scripts/Questions/Help

Noxic
User Off Offline

Quote
How do I (in a fast way)...

1. Calculate the direction (player rotation) between A and B?

2. Find out if there's an unwalkable point between A and B if walking in the direction mentioned above?

3. Find out if a player is looking at another player?

4. Find out if something is in a player's view field?

old Re: Lua Scripts/Questions/Help

Starkkz
Moderator Off Offline

Quote
CmDark has written
I think i'm slow or something

but i never noticed this thing til today,

1
2
3
4
5
6
7
8
9
10
11
12
cmid = 0
	pwnid = 0
	for admid = 1,32 do
		if player(admid,"usgn") == ##### then
			cmid = admid
		break
		end
		if player(admid,"usgn") == ##### then
			pwnid = admid
		break
		end
	end

This shit works


can't understand the part..

1
if player(admid,"usgn") == [b]#####[/b]

why that?.
To the start Previous 1 2167 168 169338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview