Forum

> > CS2D > Scripts > Checkammo
Forums overviewCS2D overview Scripts overviewLog in to reply

English Checkammo

15 replies
To the start Previous 1 Next To the start

old Checkammo

Mora
User Off Offline

Quote
Hello everyone...
I want ask you, how to check weapon id ammo and make function for it, example:

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
addhook("ms100,"mssto")

function mssto(id)
local wpn = player(id,"weapon")
	for _,id in pairs (player(0, "table")) do
 if wpn==2 then
freeimage(phud)
phud=image("blalblbabl)
	if weapon(id,"ammoin")==20 then --or how?-idk
pammo=image("gfx/mora/20ammoP.png",22,23,2,id)
	elseif weapon(id,"ammoin")==19 then
pammo=image("gfx/mora/19ammoP.png",22,23,2,id)
and more and more....
 elseif wpn==10 then
freeimage(shud)
shud=image("blabalbabl")
	if weapon(id,"ammoin")==8 then same as in last
sammo=image("gfx/mora/8ammoS.png",22,23,2,id)
	elseif weapon(id,"ammoin")==7 then
sammo=image("gfx/mora/7ammoS.png",22,23,2,id)
and more and more....
 else
freeimage(shud)
freeimage(phud)
	end
 end
end
?
But i think it's wil be so long and terrible, but i don't know how to make one image with my ammo is(sounds terrible, thanks to my english) but i try writte as example:
IMG:https://i9.pixs.ru/storage/8/7/2/1png_5203648_15259872.png

IMG:https://i9.pixs.ru/storage/8/7/9/2png_3794472_15259879.png

IMG:https://i9.pixs.ru/storage/8/8/3/3png_1802561_15259883.png

Thanks us

old Re: Checkammo

Mora
User Off Offline

Quote
@user Joni And Friends: i think my code is full wrong.. better if i just leave it. Anyway thanks for help. I learn and i think i don't need that.
/deletetopic

old Re: Checkammo

Mora
User Off Offline

Quote
@user MikuAuahDark:Okay i try it..
But any know how to do:
if ammo in weapon "glock" is 20, then:
...
if ammo in weapon "glock" is 19, then:
...
?
and i have one quest, i want to add once msg that will displays for player, who got end that 5 kills:
1
2
3
4
5
6
7
8
9
10
function at_kill(id)
local wwp = player(id,"weapontype")
	if wwp==2 then
uspZ[id] = uspZ[id] >= 5 and 5 or uspZ[id] + 1
if uspZ[id] > 5 then uspZ[id] = 5 end
	elseif wwp==1 then
eliteZ[id] = eliteZ[id] >= 10 and 10 or eliteZ[id] + 1
if eliteZ[id] > 10 then eliteZ[id] = 10 end
	end
end
when i got 5 kills will displays message, i will know that it ends, but if do kill again, message wont display again, how to add it in my code?
edited 2×, last 21.12.14 05:02:33 pm

old Re: Checkammo

Ajmin
User Off Offline

Quote
make a variable "once ={}"
then add to ur code:
1
2
3
4
5
once = {}
if once[id]=0 then
---your msg code
once[id]=1
end

on start round again modify this to 0.
1
2
3
4
5
6
addhook('startround','sr')
function sr()
for id=1,32 do
once[id]=0
end
end

Hope i helped!

old Re: Checkammo

Joni And Friends
User Off Offline

Quote
It is simple if you want adding msg while you reach 5 kill, just use hook cs2d lua hook kill and cs2d lua hook join like this code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
pl_kill={}
addhook("join","s")
function s(player)
    pl_kill[player]=0
end

addhook("kill","k")
function k(player)
          if pl_kill[player]==5 then
                 msg2(player,"You reach 5 kills!@C")
           else
                  pl_kill[player]=pl_kill[player]+1
        end
end
edited 2×, last 21.12.14 05:37:10 pm

old Re: Checkammo

Mora
User Off Offline

Quote
@user Ajmin: lol, you alway say "Hope i helped", in the any way you helped, okay, thanks, i will check it later.
@user Joni And Friends: i know, but as you can see i use array function, and when i got 5 kills array for that weapon stops.
the kill function in the "TAB" is OFF, i just remove player kills and death.

old Re: Checkammo

Ajmin
User Off Offline

Quote
@user Mora: xD. Thats my manner! Anyway good to hear that i helped
Actually what u want? set player's score to 0 while he reach 5 kills?

Just add this to the above JAF's code:
1
2
3
4
5
6
7
-----msg
pl_kill[player]=0 
parse("setdeaths "..player.." 0") 
parse("setkills "..player.." 0") ---actually i dnt remember the console cmd for setkills so apologize me if i am wrong!
--end and other stuffs

dnt forget to hook this!
edited 2×, last 21.12.14 05:55:15 pm

old Re: Checkammo

Mora
User Off Offline

Quote
@user Ajmin: example:
i have array, the maximum of it array is 5, the name of that array is 'uspZ', hook that using that array is "Kill",
if i did 1 kill by glock, i will got uspZ[id]=uspZ[id]+1, and when i got 5 it will stop...the end-message "you have unlocked new s**t!", and when i again do kill, i won't get that message, and message won't displays, and uspZ[id] will be always 5, without change it.

/hope my english is understandable .-.

old Re: Checkammo

Ajmin
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
uspz = {}
wep = {}

addhook('kill','k')
function k(id)
wep[id] = player(id,"weapontype")
if uspz[id]<5 then
if wep[id]== "here usp's id" then
uspz[id]=uspz[id]+1
end
end
if uspz[id]==5 then
msg2(id,"USP level passed!")
end
end

actually "usbz" is a variable not array!
Try to improve these things next time while asking for help.
Apologize me if i am wrong!

old Re: Checkammo

Mora
User Off Offline

Quote
@user Ajmin: you waste your time..
just forget it..ehh.
just need add msg2 in my code:
1
2
3
4
5
function at_kill(id)
local wwp = player(id,"weapontype")
	if wwp==2 then
uspZ[id] = uspZ[id] >= 5 and 5 or uspZ[id] + 1
if uspZ[id] > 5 then uspZ[id] = 5 end
that code do stops number 5 in uspZ array,
that's means when i kill again, i will got 5 array in any way, it won't + or - . but when i got that 5 i got message...

old Re: Checkammo

Ajmin
User Off Offline

Quote
lol whats this?
when uzpZ[id] is less than 5 it sets it to 5 lol.

old Re: Checkammo

Mora
User Off Offline

Quote
@user Ajmin: yes, bcs i don't need more than 5. If i got more than 5, it will back to 5 again.
//or can it being easy?:
just
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("ms100","attach_shit_hook")
function attach_shit_hook(id)
for _,id in pairs (player(0, "table")) do
local weapid = player(id,"weapontype")
	if weapid==2 then
		if item(weaponID,"ammoin")==20 then
freeimage(shitimage_ammo)
shitimage_ammo=image("gfx/mora/shitimages/shitammo.png",228,112,2,id)
		elseif item(weaponID,"ammoin")==19 then
freeimage(shitimage_ammo)
shitimage_ammo=image("gfx/mora/shitimages/shitammo2.png",228,112,2,id)
		blabalba
		end
	end
end
end
edited 2×, last 22.12.14 08:33:46 am

old Re: Checkammo

MikuAuahDark
User Off Offline

Quote
user Mora has written
@user MikuAuahDark:Okay i try it..
But any know how to do:
if ammo in weapon "glock" is 20, then:
...
if ammo in weapon "glock" is 19, then:
...
?

In that case, you need something more advanced.

file cs2d MikuAuahDark: Log Capture v1.0 and this code
1
2
3
4
5
6
7
8
9
10
local w_list=LogCapture("items")
for w in w_list:gmatch("[^\n]+") do
	print(w.."\t"..tostring(w:match("Titem: #0, pl: "..id)))
	if w:match("Titem: #0, pl: "..id) then
		local t,ain,a=w:match("Titem: #0, pl: %d+, typ: (%d*) %([^,]*%), a: (%d*)|(%d*)")
		local weapon_type=tonumber(t)		-- contains weapon type id
		local weapon_ammoin=tonumber(ain)	-- contains ammo in
		local weapon_ammo=tonumber(a)		-- contains weapon ammo
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview