Forum

> > CS2D > Scripts > Need help with lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English Need help with lua

12 replies
To the start Previous 1 Next To the start

old Need help with lua

Flame
BANNED Off Offline

Quote
I was wondering
What lua is that when you hit a zombie T you're money goes up +5 ?
Acctually I can't find a lua like that
Please help...

old Re: Need help with lua

archmage
User Off Offline

Quote
1
2
3
4
5
6
7
addhook("hit", "hithook")

function hithook(id, src)
	if ( player(src, "team") == 2 and player(id,"team") == 1 and game("sv_gamemode") == 3 ) then
		parse("setmoney "..src.." "..player(src,"money")+5)
	end
end

old Re: Need help with lua

archmage
User Off Offline

Quote
Try this
1
2
3
4
5
6
7
addhook("hit", "hithook")

function hithook(id, src)
     if ( player(src, "team") == 2 and player(id,"team") == 1 and game("sv_gamemode") == 4 ) then
          parse("setmoney "..src.." "..player(src,"money")+5)
     end
end

old Re: Need help with lua

Starkkz
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
addhook("hit","onHit")
function onHit(id,source,wpn,hpdmg,apdmg)
	local gm = tonumber(game("sv_gamemode"))
	if gm == 4 then
		-- Check game mode
		if player(source,"exists") then
			-- Check if the attacker is a player (Not turret, entity, etc)
			if player(source,"team") == 2 and player(id,"team") == 1 then
				-- Give him the money
				parse("setmoney "..source.." "..player(source,"money")+5)
			end
		end
	end
end

old Re: Need help with lua

archmage
User Off Offline

Quote
@Starkks
lol there is no reason to check if the player exists

Other than that our sources are the same. I just did not know that game() returned a string.
1
2
3
4
5
6
7
addhook("hit", "hithook")

function hithook(id, src)
	if ( player(src, "team") == 2 and player(id,"team") == 1 and tonumber(game("sv_gamemode")) == 4 ) then
	parse("setmoney "..src.." "..player(src,"money")+5)
	end
end

old Re: Need help with lua

Starkkz
Moderator Off Offline

Quote
Are you sure?, but if the attacker is a turret?, or an entity?, or just a slap by the admin?. There could get different parameters

old Re: Need help with lua

Starkkz
Moderator Off Offline

Quote
No, i don't want to chat. Also for the next time read before what i said, you have to be always searching the littlest details.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview