Forum

> > CS2D > Scripts > Spawn and get old weapons.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Spawn and get old weapons.

5 replies
To the start Previous 1 Next To the start

old Spawn and get old weapons.

Kirito2K
User Off Offline

Quote
Hi all,
Can some one make this script for me ?

It's about when the player dies and he spawn he get the old weapons he got ..

old Re: Spawn and get old weapons.

Ajmin
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
lastweapon={}

addhook("die","oldwpn")
function oldwpn(id)
lastweapon[id]=player(id,"weapontype")
end

addhook("join","joiner")
function joiner(id)
lastweapon[id]=0
end

addhook("spawn","spawns")
function spawns(id)
if lastweapon[id]>0 then
parse("equip "..id.." "..lastweapon[id].."")
lastweapon[id]=0
end
end

Hope i helped
Regards
Ajmin

old Re: Spawn and get old weapons.

DC
Admin Off Offline

Quote
@user Ajmin:
• This would only re-equip the used weapon and ignore all the other stuff the player had when dying.
• You are using cs2d cmd equip in cs2d lua hook spawn which you never should do. Use the return value of cs2d lua hook spawn instead.

cs2d lua cmd playerweapons returns a list of ALL weapon types a player currently carries. This could be used to implement a script which actually equips all the stuff on spawn. Note that this still wouldn't equip special equipment like armor/nightvision/gas mask. You would have to add additional logic for that.
edited 1×, last 13.12.14 02:01:49 pm

old Re: Spawn and get old weapons.

eledah
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
lastWeps = {}

addhook("die", "_die")
addhook("join", "_join")
addhook("spawn", "_spawn")

function _die(id)
	lastWeps[id] = playerweapons(id)
end

function _join(id)
	lastWeps[id] = {}
end

function arrayToC_Separated(id)
	local C_Separated = ''
	for i = 1, #(lastWeps[id]) do
		C_Separated = C_Separated .. ',' .. lastWeps[id][i]
	end
	return string.sub(C_Separated, 2)
end

function _spawn(id)
	return arrayToC_Separated(id)
end
user DC has written
Note that this still wouldn't equip special equipment like armor/nightvision/gas mask. You would have to add additional logic for that

old Re: Spawn and get old weapons.

Kirito2K
User Off Offline

Quote
@user eledah: Thats for all , i need for specail players , i fotgot to put the script , here it is.

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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
teleportMode = {}
PlayerLastUse = {}
rodion = {64650}
tricky = {112265}
nova = {35065}
pirates = {120840}
hitman = {120792}
paprika = {121205}
mora = {114940}
dragon = {108309}

addhook("join","_adminiuserjoin")
addhook("use","UseTwice")
addhook("menu","_adminmenu")
addhook("spawn","_rspawn")
addhook("usebutton","_te")
addhook("menu","_chestmenu")

function _adminiuserjoin(id)
teleportMode[id]=0
end

function UseTwice(id, event)
     if PlayerLastUse[id] and os.clock() - PlayerLastUse[id] < 0.2 then
          for _, usgn in ipairs(rodion) do
               if player(id,'usgn') == usgn then
                    menu(id,"Happy town Menu,Specail spawn | "..teleportMode[id].."")
                    return 1
               end
          end
          for _, usgn in ipairs(tricky) do
               if player(id,'usgn') == usgn then
                    menu(id,"Happy town Menu,Specail spawn | "..teleportMode[id].."")
                    return 1
               end
          end
          for _, usgn in ipairs(nova) do
               if player(id,'usgn') == usgn then
                    menu(id,"Happy town Menu,Specail spawn | "..teleportMode[id].."")
                    return 1
               end
          end
          for _, usgn in ipairs(pirates) do
               if player(id,'usgn') == usgn then
                    menu(id,"Happy town Menu,Specail spawn | "..teleportMode[id].."")
                    return 1
               end
          end
          for _, usgn in ipairs(hitman) do
               if player(id,'usgn') == usgn then
                    menu(id,"Happy town Menu,Specail spawn | "..teleportMode[id].."")
                    return 1
               end
          end
          for _, usgn in ipairs(paprika) do
               if player(id,'usgn') == usgn then
                    menu(id,"Happy town Menu,Specail spawn | "..teleportMode[id].."")
                    return 1
               end
          end
          for _, usgn in ipairs(mora) do
               if player(id,'usgn') == usgn then
                    menu(id,"Happy town Menu,Specail spawn | "..teleportMode[id].."")
                    return 1
               end
          end
          for _, usgn in ipairs(dragon) do
               if player(id,'usgn') == usgn then
                    menu(id,"Happy town Menu,Specail spawn | "..teleportMode[id].."")
                    return 1
               end
          end
     end
     PlayerLastUse[id] = os.clock()
end

-- Menu Settings
function _adminmenu(id,t,b)
     if t=="Happy town Menu" then
if b==1 and teleportMode[id]==0 then
msg2(id,"©000255111Specail spawn | On")
teleportMode[id]=1
spawn(id)
elseif b==1 and teleportMode[id]==1 then
msg2(id,"©000255111Specail spawn | Off")
teleportMode[id]=0
end
end
end

function _rspawn(id)
for _, usgn in ipairs(rodion) do
if player(id,'usgn') == usgn and teleportMode[id]==1 then
parse("setpos "..id.." 1024 32")
end
for _, usgn in ipairs(tricky) do
if player(id,'usgn') == usgn and teleportMode[id]==1 then
parse("setpos "..id.." 1024 32")
end
for _, usgn in ipairs(nova) do
if player(id,'usgn') == usgn and teleportMode[id]==1 then
parse("setpos "..id.." 1024 32")
end
for _, usgn in ipairs(pirates) do
if player(id,'usgn') == usgn and teleportMode[id]==1 then
parse("setpos "..id.." 6608 2640")
end
for _, usgn in ipairs(hitman) do
if player(id,'usgn') == usgn and teleportMode[id]==1 then
parse("setpos "..id.." 6352 2032")
end
for _, usgn in ipairs(paprika) do
if player(id,'usgn') == usgn and teleportMode[id]==1 then
parse("setpos "..id.." 1024 32")
end
for _, usgn in ipairs(mora) do
if player(id,'usgn') == usgn and teleportMode[id]==1 then
parse("setpos "..id.." 6608 3248")
end
for _, usgn in ipairs(dragon) do
if player(id,'usgn') == usgn and teleportMode[id]==1 then
parse("setpos "..id.." 1024 32")
end
end
end
end
end
end
end
end
end
end 

function _te(id,x,y)
     if entity(x,y,"name") == "Pirates Chest" then 
          menu(id,"Pirates Chest,FN F2000,M4A1,AK47,Heavy Armor,Laser,Portal")
     elseif entity(x,y,"name") == "Mora Chest" then
          menu(id,"Mora Chest,FN F2000,Medic Armor,Machete,Tactical Shield")
     elseif entity(x,y,"name") == "Hitman Chest" then
          menu(id,"Hitman Chest,FN F2000,Medic Armor,Machete,Tactical Shield")
     elseif entity(x,y,"name") == "Global Mod Menu" then
          menu(id,"Mod Portals,Go to Shop,Go to Mod Center,Go to Mod Village")
     elseif entity(x,y,"name") == "Mod Info Menu" then
          menu(id,"Mod Help Menu,Mod Rules")
     end
end

function _chestmenu(id,title,buton)
     if title == "Pirates Chest" then
          if buton == 1 then
          equip(id,91)
          end
          if buton == 2 then
          equip(id,32)
          end
          if buton == 3 then
          equip(id,30)
          end
          if buton == 4 then
          equip(id,81)
          end
          if buton == 5 then
          equip(id,45)
          end
          if buton == 6 then
          equip(id,88)
          end
end
     if title == "Mora Chest" then
          if buton == 1 then
          equip(id,91)
          end
          if buton == 2 then
          equip(id,82)
          end
          if buton == 3 then
          equip(id,69)
          end
          if buton == 4 then
          equip(id,41)
          end
end
     if title == "Hitman Chest" then
          if buton == 1 then
          equip(id,91)
          end
          if buton == 2 then
          equip(id,82)
          end
          if buton == 3 then
          equip(id,69)
          end
          if buton == 4 then
          equip(id,41)
          end
end
     if title == "Mod Portals" then
          if buton == 1 then
          parse("setpos "..id.." 624 242")
          end
          if buton == 2 then
          parse("setpos "..id.." 1747 1875")
          end
          if buton == 3 then
          parse("setpos "..id.." 6124 748")
          end
end
     if title == "Mod Help Menu" then
          if buton == 1 then
          msg2(id,"©2550000001) Do not kick\ban\punish for selfish reasons.")
          msg2(id,"©2550000002) Do not insult\flame\treat to other MODs.")
          msg2(id,"©2550000003) Follow all of the Players Rules.")
          end
end
end

equip = function(id,...)
 for _,wep in ipairs(arg) do
  parse("equip "..id.." "..wep)
 end
end

spawn = function (id)
	parse ("spawnplayer "..id.." -1 -1")
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview