Forum

> > CS2D > Scripts > Armors - Weapons
Forums overviewCS2D overview Scripts overviewLog in to reply

English Armors - Weapons

7 replies
To the start Previous 1 Next To the start

old Armors - Weapons

G3tWr3ck3d
User Off Offline

Quote
Whats the code to make a difference between armors and weapons?
Because I see that cs2d cmd weapon cmd does not have any return values, I would do like:
1
2
3
if weapon(id,'type') == 82 then -- Medic Armor
	parse('Test')
end

old Re: Armors - Weapons

VADemon
User Off Offline

Quote
cs2d lua cmd player(id, "armor") returns different values for kevlar, kevlar+helm, medic, super armor etc.
Remember that kevlar(+helm) values are dynamic, based on remaining armor and custom armors have constant values.

old Re: Armors - Weapons

G3tWr3ck3d
User Off Offline

Quote
What I am trying to do here is, I have 3 codes in one function and they all trigger when I use a menu button.
1
2
3
parse('setarmor '..id..' '..item) -- I use a menu to buy items, they also includes armors
parse('equip '..id..' '..item)
parse('setweapon '..id..' '..item)  -- I want to trigger this if its a weapon and not an armor

It returns into an error in console, saying that player[id] does not have the item 80 or whatever armor I use, so therefore the lua cannot execute the setweapon cmd because obviously an armor is not a weapon

old Re: Armors - Weapons

Rainoth
Moderator Off Offline

Quote
then add
1
if player(id,"armor") ~= 201 or player(id,"armor") ~= 202 then -- or ... and so on

old Re: Armors - Weapons

G3tWr3ck3d
User Off Offline

Quote
1
2
3
4
5
parse('setarmor '..id..' '..item)
parse('equip '..id..' '..item)
if player(id,"armor") ~= 84 or player(id,"armor") ~= 82 then
	parse('setweapon '..id..' '..item)
end

player(id," armor") will just setweapon if the player doesn't have an armor equiped, I want setweapon even if the player has an armor equiped on him

Also:
1
2
3
4
for id = 1, 32 do
	parse('hudtxt2 '..id..' 25 "©255255255'..server..'" '..(340-(string.len('..server..')*7.5))..' 10')
	parse('hudtxt2 '..id..' 26 "©255255255'..webpage..'" '..(315-(string.len("..webpage..")*6.0))..' 25')	
end

Why this code won't run in dedicated server? I thought all the id's would get this hud but they won't get it. Do I strictly have to use it with a hook to run? Cause I just want it to start when the server starts.

Also I don't see any lua hook that can be triggered when server starts or stops
edited 1×, last 10.05.16 10:42:09 pm

old Re: Armors - Weapons

Yates
Reviewer Off Offline

Quote
@user G3tWr3ck3d: Use hudtxt instead of hudtxt2 if every client is supposed to see the same thing. As for the armour goes, it depends if you also want them to buy kevlar, seeing as this can have a value from 0 to 200 (or 250, correct me if I'm wrong). If you want to only use armours like light, heavy, medic etc then simply check if the value is higher or equal to the lowest armour ID and lower or equal to the highest armour ID.

old Re: Armors - Weapons

VADemon
User Off Offline

Quote
@user G3tWr3ck3d: You don't need to cs2d cmd setweapon on armor because a player can only have ONE type of armor at a time, basically it's equipped automatically.

As for armor cs2d lua cmd player(id, "armor") and cs2d cmd setarmor, lua Player armor values:
0 - No armor
x <= 65 - Kevlar
x <= 100 - Kevlar + Helmet
100< x <=200 - Kevlar + Helmet (need confirmation from devs how the damage is blocked here)
201 - Light armor
202 - Armor
203 - Heavy Armor
204 - Medic Armor
205 - Super Armor
206 - Stealth Suite
207-255 - UNUSED

You have to choose what command to use:
cs2d cmd setarmor can set exact armor values, for example kevlar armor that is down to 50%
cs2d cmd equip uses values as if the armor was picked up (full durability)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview