Forum

> > CS2D > Scripts > Start item
Forums overviewCS2D overview Scripts overviewLog in to reply

English Start item

6 replies
To the start Previous 1 Next To the start

old Start item

NeptooN
User Off Offline

Quote
us Hi, everybody

> Who can make a script for me?

Well, in General, this script should be a menu. and in it for example Molotov / off Molotov / on. This means a birth without Molotov and a on with Molotov. I apologize in advance for my English

Help me pliz

old Re: Start item

j0kER aR
User 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
plSp = {
     he = {},
     motv = {},
     wrn = {},
     kev = {},
     nv = {}
}
for i = 1,32 do
     plSp.he[i] = 'OFF'
     plSp.motv[i] = 'OFF'
     plSp.wrn[i] = 'OFF'
     plSp.kev[i] = 'OFF'
     plSp.nv[i] = 'OFF'
end

addhook('serveraction','start_items')
function start_items(id,action)
if action==1 then
               menu(id,'Start Player Item,HE|IS '..plSp.he[id]..',Motolov Cocktail|IS '..plSp.motv[id]..',Wrench|IS '..plSp.wrn[id]..',Kevlar + Helm|IS '..plSp.kev[id]..',Night Vision|IS '..plSp.nv[id])
end
end

addhook('menu','spawnItems')
function spawnItems(id,mnu,btn)
     if mnu == 'Start Player Item' then
          local E,D = '\169000255000ENABLED@C','\169255000000DISABLED@C'
          if btn == 1 then
               if plSp.he[id] == 'OFF' then plSp.he[id] = 'ON' else plSp.he[id] = 'OFF' end
               if plSp.he[id] == 'OFF' then msg2(id,'HE '..D) else msg2(id,'HE '..E) end
          elseif btn == 2 then
               if plSp.motv[id] == 'OFF' then plSp.motv[id] = 'ON' else plSp.motv[id] = 'OFF' end
               if plSp.motv[id] == 'OFF' then msg2(id,'Motolov Cocktail '..D) else msg2(id,'Motolov Cocktail '..E) end
          elseif btn == 3 then
               if plSp.wrn[id] == 'OFF' then plSp.wrn[id] = 'ON' else plSp.wrn[id] = 'OFF' end
               if plSp.wrn[id] == 'OFF' then msg2(id,'Wrench '..D) else msg2(id,'Wrench '..E) end
          elseif btn == 4 then
               if plSp.kev[id] == 'OFF' then plSp.kev[id] = 'ON' else plSp.kev[id] = 'OFF' end
               if plSp.kev[id] == 'OFF' then msg2(id,'Kevlar + Helm '..D) else msg2(id,'Kevlar + Helm '..E) end
          elseif btn == 5 then
               if plSp.nv[id] == 'OFF' then plSp.nv[id] = 'ON' else plSp.nv[id] = 'OFF' end
               if plSp.nv[id] == 'OFF' then msg2(id,'Night Vision '..D) else msg2(id,'Night Vision '..E) end
          end
     end
end

addhook('spawn','spawnItem')
function spawnItem(id)
     if plSp.he[id] == 'ON' then parse('equip '..id..' 51') end
     if plSp.motv[id] == 'ON' then parse('equip '..id..' 73') end
     if plSp.wrn[id] == 'ON' then parse('equip '..id..' 74') end
     if plSp.kev[id] == 'ON' then parse('equip '..id..' 58') end
     if plSp.nv[id] == 'ON' then  parse("spawnitem 59 "..player(id,"tilex").." "..player(id,"tiley")) end
end

I assumed you wanted something like iran town

old Re: Start item

Rainoth
Moderator Off Offline

Quote
@user j0kER aR: You could just use a single table for this. No need to make a separate key for every item he'll want to add.

old Re: Start item

Rainoth
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
items = {
	spawn = "",
	off = {51, 73, 74, 58, 59},
	on = {},
	menuString = "Start player items",
	hooks = {"serveraction","menu","spawn"},
	admin = 155954
}

for k,hook in pairs (items.hooks) do
	addhook(hook, "_"..hook)
end

function getMenu() 
	for k,v in pairs (items.off) do
		menuString = menuString..","..itemtype(v,"name").."|DISABLED"
	end
	for k,v in pairs (items.on) do
		menuString = menuString..","..itemtype(v,"name").."|ENABLED"
	end
end

function _serveraction(id, b)
	if player(id,"usgn") == items.admin then
		menu(id,getMenu())
	end
end

function _menu(id, t, b)
	if t == "Start player items" then
		if items.off[b] ~= nil then
			items.on[b] = items.off[b]
			items.off[b] = nil
		end
		if items.on[b] ~= nil then
			items.off[b] = items.on[b]
			items.on[b] = nil
		end
		for k,v in pairs (items.on) do
			items.spawn = items.spawn..tostring(v)..","
		end
		items.spawn = items.spawn:sub(1,items.spawn:len()-1)
	end
end

function _spawn(id)
	return items.spawn
end

@user j0kER aR: Something like this, I suppose?
This way he wouldn't need to change every single function in your script when he wants to add a new item (unless it would exceed the menu size which is 9 but the same would apply to your script).
Didn't test it but I doubt that guy will come back to see this one and you could see what I'm getting at.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview