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 2322 323 324338 339 Next To the start

old Re: Lua Scripts/Questions/Help

JONY
User Off Offline

Quote
At Yates: yes, but how to make it in Team deathmatch mode?
I know it seems pointless to make turret attack your teammates in team deathmatch, but I am still interested in doing so

Regards,
J.

old Re: Lua Scripts/Questions/Help

Chex
User Off Offline

Quote
It's impssible. Sorry. A turret_rotate and turret_aim and turret_fire function would be nice, but is unreleased.
What is the weaponid of knife?

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
Knife = 50
I think everyone could make a script like that easily.
But I don't have any time... and I hate not to have time...
I want to make new awesome scripts (I've got many ideas)
But... you know.
+
1
image("gfx/cars/car.png",0,0,132+id) --I don't know if this works, I'm in rush.
You just have to put an image in the path "gfx/cars/" named "car.png" and change it to your needs.

old Re: Lua Scripts/Questions/Help

Yates
Reviewer Off Offline

Quote
Yeah okay, you might think it is easy but Noone on this site has made one.
If you or someone else could make one for me where i can change the cost, img and name of it i would be very gratefull.
And you can upload it so everyone can use..
Noone here has made one or uploaded it..
Just buy a car and you have a menu like F6 or somethign where you can use the cars you have bought or even park them.

Why i need well, making a GTA rp map..
I don't upload my stuff here i just give to Fg clan and play them.
I have the pics i need but not the lua,
Got the pics from SKY i think..

old Re: Lua Scripts/Questions/Help

J4x
User Off Offline

Quote
im making a mod so imake this script, it send me this error :
bad argument #1 to player (number expected got nil.)
1
2
3
4
5
6
addhook("second","health")
function health(id)
if player (id,"health") > 99 then
parse("sethealth "..id.." +1")
end
end

old Re: Lua Scripts/Questions/Help

Yates
Reviewer Off Offline

Quote
Anyone help me..
When i say !car i buy a car but i dont even have enough money, the script gives me money..
Can somebody help me..?
Spoiler >


Edit: @Nemesis, I don't know much about scripting but i think your 99 must be 0 for it to work

old Re: Lua Scripts/Questions/Help

J4x
User Off Offline

Quote
i dont think so, becaus i like that when a pleyr has less than 100 it starts getting life... i think the problem is in the +1 but i dont know how to solve it

old Re: Lua Scripts/Questions/Help

ohaz
User Off Offline

Quote
FN_Nemesis has written
im making a mod so imake this script, it send me this error :
bad argument #1 to player (number expected got nil.)
1
2
3
4
5
6
addhook("second","health")
function health(id)
if player (id,"health") > 99 then
parse("sethealth "..id.." +1")
end
end


1
2
3
4
5
6
7
8
addhook("second", "health")
function health()
	for i=1,32 do
		if (player(i, "health") > 99) then
			parse("sethealth "..i.." +1")
		end
	end
end
The second hook doesn't have the id of any player as a parameter.
edited 2×, last 09.12.10 08:39:22 pm

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
addhook("second", "health")
function health()
     for i=1,32 do
	if player(id,"exists") then
          if (player(i, "health") > 99) then
               parse("sethealth "..i.." "..player(id,"health")+1) --does sethealth id +1 work?(idk so just try this)
          end
	end
     end
end
should work...
edited 1×, last 10.12.10 05:50:19 pm

old Re: Lua Scripts/Questions/Help

RyceR
User Off Offline

Quote
Simple script to choose pistol at spawn:
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
addhook("spawn","pistol")
function pistol(id)
	parse('hudtxt2 '..id..' 1 "1: USP" 13 200')
	parse('hudtxt2 '..id..' 2 "2: Glock" 13 212')
	parse('hudtxt2 '..id..' 3 "3: Deagle" 13 224')
	parse('hudtxt2 '..id..' 4 "4: P228" 13 236')
	parse('hudtxt2 '..id..' 5 "5: Elite" 13 248')
	parse('hudtxt2 '..id..' 6 "6: Five-Seven" 13 260')
	menu(id,"Choose Pistol@i,USP,Glock,P228,Deagle,Elite,Five-Seven")
	if player(id,"bot") then
		bot=math.random(1,6)
		parse("equip "..id.." "..bot)
		parse("setweapon "..id.." "..bot)
	end
end

addhook("menu","pistoll")
function pistoll(id,title,sel)
	if title == "Choose Pistol" then
		if sel == 1 then
			parse("equip "..id.." 1")
			parse("setweapon "..id.." 1")
			parse('hudtxt2 '..id..' 1 "  " 13 140')
			parse('hudtxt2 '..id..' 2 "  " 13 140')
			parse('hudtxt2 '..id..' 3 "  " 13 140')
			parse('hudtxt2 '..id..' 4 "  " 13 140')
			parse('hudtxt2 '..id..' 5 "  " 13 140')
			parse('hudtxt2 '..id..' 6 "  " 13 140')
		end
		if sel == 2 then
			parse("equip "..id.." 2")
			parse("setweapon "..id.." 2")
			parse('hudtxt2 '..id..' 1 "  " 13 140')
			parse('hudtxt2 '..id..' 2 "  " 13 140')
			parse('hudtxt2 '..id..' 3 "  " 13 140')
			parse('hudtxt2 '..id..' 4 "  " 13 140')
			parse('hudtxt2 '..id..' 5 "  " 13 140')
			parse('hudtxt2 '..id..' 6 "  " 13 140')
		end
		if sel == 3 then
			parse("equip "..id.." 3")
			parse("setweapon "..id.." 3")
			parse('hudtxt2 '..id..' 1 "  " 13 140')
			parse('hudtxt2 '..id..' 2 "  " 13 140')
			parse('hudtxt2 '..id..' 3 "  " 13 140')
			parse('hudtxt2 '..id..' 4 "  " 13 140')
			parse('hudtxt2 '..id..' 5 "  " 13 140')
			parse('hudtxt2 '..id..' 6 "  " 13 140')
		end
		if sel == 4 then
			parse("equip "..id.." 4")
			parse("setweapon "..id.." 4")
			parse('hudtxt2 '..id..' 1 "  " 13 140')
			parse('hudtxt2 '..id..' 2 "  " 13 140')
			parse('hudtxt2 '..id..' 3 "  " 13 140')
			parse('hudtxt2 '..id..' 4 "  " 13 140')
			parse('hudtxt2 '..id..' 5 "  " 13 140')
			parse('hudtxt2 '..id..' 6 "  " 13 140')
		end
		if sel == 5 then
			parse("equip "..id.." 5")
			parse("setweapon "..id.." 5")
			parse('hudtxt2 '..id..' 1 "  " 13 140')
			parse('hudtxt2 '..id..' 2 "  " 13 140')
			parse('hudtxt2 '..id..' 3 "  " 13 140')
			parse('hudtxt2 '..id..' 4 "  " 13 140')
			parse('hudtxt2 '..id..' 5 "  " 13 140')
			parse('hudtxt2 '..id..' 6 "  " 13 140')
		end
		if sel == 6 then
			parse("equip "..id.." 6")
			parse("setweapon "..id.." 6")
			parse('hudtxt2 '..id..' 1 "  " 13 140')
			parse('hudtxt2 '..id..' 2 "  " 13 140')
			parse('hudtxt2 '..id..' 3 "  " 13 140')
			parse('hudtxt2 '..id..' 4 "  " 13 140')
			parse('hudtxt2 '..id..' 5 "  " 13 140')
			parse('hudtxt2 '..id..' 6 "  " 13 140')
		end
	end
end

old Re: Lua Scripts/Questions/Help

Yates
Reviewer Off Offline

Quote
Can someone tell me what's wrong with this..?
It gives me money when i buy the car..
I want it to take 10.000 of me and not give

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
CARS = {}
CARS_MAXSPEED = 25
CARS_ACCELERATION = function(speed) return speed/2 + 1 end
CARS_DECELERATION = function(speed) return -speed/2 - 1 end
CARS_IMAGEPATH = "gfx/Yates-CityLife/car.bmp"
CARS_PRICE = 10000

if not addmoney then
     function addmoney(id, amount)
          if player(id, 'money') >= amount then
               parse(string.format("setmoney %i %i", id, player(id, 'money') - amount))
               return true
          end
          return false
     end
end

function addcar(x, y)
     table.insert(CARS, {x = x, y = y, speed = 0, image = image(CARS_IMAGEPATH, x, y, 0), rot = 0})
end

function carpos(car, x, y)
     local tilex, tiley = math.floor(car.x/32), math.floor(car.y/32)
     if not tile(tilex, tiley, 'walkable') then
          return false
     end
     for _, id in ipairs(player(0, 'table')) do
          if car.driver and car.driver ~= id and player(id, 'health') > 0 and math.abs(x - player(id, 'x')) < 16 and math.abs(y - player(id, 'y')) < 16 then
               parse(string.format("customkill %i Car %i", car.driver, id))
          end
     end
     car.x, car.y = x, y
     if car.driver then
          parse(string.format("setpos %i %i %i", car.driver, x, y))
     else
          imagepos(car.image, x, y, car.rot)
     end
     return true
end

addhook("ms100", "CARms100")
function CARms100()
     for id, car in pairs(CARS) do
          if car.driver then
               if not player(car.driver, 'exists') or player(car.driver, 'health') <= 0 then
                    car.driver = nil
                    car.speed = math.min(CARS_MAXSPEED, car.speed + CARS_DECELERATION(car.speed))
               else
                    car.rot = player(car.driver, 'rot')
                    car.speed = math.min(CARS_MAXSPEED, car.speed + CARS_ACCELERATION(car.speed))
               end
          elseif car.speed > 0 then
               car.speed = math.min(CARS_MAXSPEED, car.speed + CARS_DECELERATION(car.speed))
          end
          if car.speed > 0 then
               local rot = math.rad(car.rot - 180)
               if not carpos(car, car.x - math.sin(rot)*car.speed, car.y + math.cos(rot)*car.speed) then
                    if car.driver then
                         parse(string.format("customkill %i Car %i", car.driver, car.driver))
                    end
                    freeimage(car.image)
                    parse(string.format("explosion %i %i 128 250 %i", car.x, car.y, car.driver or 0))
                    parse(string.format("effect \"fire\" %i %i 256 128", car.x, car.y))
                    CARS[id] = nil
               end
          end
     end
end

addhook("use", "CARuse")
function CARuse(id,event,data,x,y)
     x, y = player(id, 'x'), player(id, 'y')
     for _, car in pairs(CARS) do
          if not car.driver and math.abs(car.x - x) < 32 and math.abs(car.y - y) < 32 then
               car.speedmod = player(id, 'speedmod')
               parse(string.format("speedmod %i 0", id))
               car.driver = id
               freeimage(car.image)
               car.image = image(CARS_IMAGEPATH, 1, 0, 200+id)
                break
          elseif car.driver == id then
               parse(string.format("speedmod %i %i", id, car.speedmod))
               car.driver = nil
               freeimage(car.image)
               car.image = image(CARS_IMAGEPATH, player(id, 'x'), player(id, 'y'), 0)
                break
          end
     end
end

local bought, nomoney = "You have bought a car for $" .. CARS_PRICE .. ".", "You do not have enough money to buy a car. ($" .. CARS_PRICE .. ")"
addhook("say", "CARsay")
function CARsay(id,message)
     if message == "!car" then
          if addmoney(id, -CARS_PRICE) then
               addcar(player(id, 'x'), player(id, 'y'))
               msg2(id, bought)
          else
               msg2(id, nomoney)
          end
          return 1
     end
end

old Re: Lua Scripts/Questions/Help

Yasday
User Off Offline

Quote
@RyceR
n1: (you don't need to write this much)
Spoiler >


@Yates
n2: (lol should work)
Spoiler >
To the start Previous 1 2322 323 324338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview