Forum

> > CS2D > Scripts > [REQ] Frisk and Fine commands
Forums overviewCS2D overview Scripts overviewLog in to reply

English [REQ] Frisk and Fine commands

5 replies
To the start Previous 1 Next To the start

old [REQ] Frisk and Fine commands

Luan5006
User Off Offline

Quote
Hi. I'm working on a lightRP server and I haven't found any commands similar to these two in any other script.
I have some scripting experience with pawno from a few years ago, when I used to work with SA:MP, so I'm looking at scripts from RP gamemodes, tutorials and etc to catch the basics, but I pretty much have no idea on how to start a command from scratch.
So it would be great if any of you guys could do one of these or both commands, if possible. I'll try to learn everything I can from it so I start doing some of my own

I have no idea if they are hard to do or something, but I'll be grateful if someone tries to do it.

!Frisk
This command would only be available for CTs to use.
You would have to type something like "!frisk id".
It would return "*Player* is carrying a weapon." to the CT if the guy being frisked has a weapon other than Wrench and Knife.
It would return "*Player* is unarmed." to the CT if the guy being frisked has no weapon other than the Wrench and Knife.
It would be great if you could make it so it can only be used from close range, not sure if it's possible.

!Fine
This command would only be available for CTs to use.
You would have to type something like "!fine id".
It would take away $500 from the player who got fined and give $500 to the CT who used it.
A message would pop up to everyone in the server saying "*Player* has been fined by *CT player*."
Again, it would be great if it could only be used from close range.

Thanks for reading and trying to do them if you did
If I missed on these commands from any script available, please post a link for them here, if you can. Thanks :3

old Re: [REQ] Frisk and Fine commands

Cure Pikachu
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
addhook("say","saycommands")
function saycommands(id,txt)
	if player(id,"team") >= 2 then
		if string.lower(string.sub(txt,1,7)) == "!frisk " then
			local t2 = tonumber(string.sub(txt,8))
			if t2 and player(t2,"exists") and player(t2,"health") > 0 and player(id,"health") > 0 then
				local x1 = player(id,"x")
				local y1 = player(id,"y")
				local x2 = player(t2,"x")
				local y2 = player(t2,"y")
				local dist = math.sqrt((x1-x2)^2+(y1-y2)^2)
				if dist <= 32 then
					local a = 0
					for _, w in ipairs(playerweapons(t2)) do
						if w ~= 50 and w ~= 74 then
							a = a + 1
						end
					end
					if a > 0 then
						msg2(id,"©255000000"..player(t2,"name").." is carrying at least 1 weapon!")
					else
						msg2(id,"©000255000"..player(t2,"name").." is unarmed!")
					end
				end
			end
		elseif string.lower(string.sub(txt,1,6)) == "!fine " then
			local t2 = tonumber(string.sub(txt,7))
			if t2 and player(t2,"exists") and player(t2,"health") > 0 and player(id,"health") > 0 then
				local x1 = player(id,"x")
				local y1 = player(id,"y")
				local x2 = player(t2,"x")
				local y2 = player(t2,"y")
				local dist = math.sqrt((x1-x2)^2+(y1-y2)^2)
				if dist <= 32 then
					-- GTA style
					-- If victim has less than $500, you take all of his money
					local m = math.min(500,player(t2,"money"))
					parse("setmoney "..t2.." "..player(t2,"money")-m)
					parse("setmoney "..id.." "..player(id,"money")+m)
					msg("©255000000"..player(t2,"name").." has been fined by "..player(id,"name").." for $"..m.."!")
				end
			end
		end
	end
end
EDIT: Added the "can only be used at close range" part.
EDIT2: Careless mistake. Silly me.
edited 7×, last 18.01.13 06:37:52 am

old Re: [REQ] Frisk and Fine commands

Luan5006
User Off Offline

Quote
Thanks, but I got an error and the commands didn't work

[02:11:11] LUA ERROR: sys/lua/PolisCommands.lua:33: attempt to perform arithmetic on global 'y2' (a nil value)

old Re: [REQ] Frisk and Fine commands

Luan5006
User Off Offline

Quote
They are working fine now, thanks a bunch
I tried to do an error message such as "Format: !frisk id" to show up when a player doesn't type in an ID number but I failed at it. I tried copying some code from other scripts but I still couldn't get it to work. Could you please make that for me?

old Re: [REQ] Frisk and Fine commands

Cure Pikachu
User Off Offline

Quote
Well since I am back from some "corrupted tempban", alright.
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
addhook("say","saycommands")
function saycommands(id,txt)
	if player(id,"team") >= 2 then
		if string.lower(string.sub(txt,1,7)) == "!frisk " then
			local t2 = tonumber(string.sub(txt,8))
			if t2 and t2 >= 1 and t2 <= 32 then 
				if player(t2,"exists") and player(t2,"health") > 0 and player(id,"health") > 0 then
					local x1 = player(id,"x")
					local y1 = player(id,"y")
					local x2 = player(t2,"x")
					local y2 = player(t2,"y")
					local dist = math.sqrt(x1-x2)^2+(y1-y2)^2)
					if dist <= 32 then
						local a = 0
						for _, w in ipairs(playerweapons(t2)) do
							if w ~= 50 and w ~= 74 then
								a = a + 1
							end
						end
						if a > 0 then
							msg2(id,"©255000000"..player(t2,"name").." is carrying at least 1 weapon!")
						else
							msg2(id,"©000255000"..player(t2,"name").." is unarmed!")
						end
					end
				end
			else
				msg2(id,"©255000000Format: !frisk <id>")
			end
		elseif string.lower(string.sub(txt,1,6)) == "!fine " then
			local t2 = tonumber(string.sub(txt,7))
			if t2 and t2 >= 1 and t2 <= 32
				if player(t2,"exists") and player(t2,"health") > 0 and player(id,"health") > 0 then
					local x1 = player(id,"x")
					local y1 = player(id,"y")
					local x2 = player(t2,"x")
					local y2 = player(t2,"y")
					local dist = math.sqrt((x1-x2)^2+(y1-y2)^2)
					if dist <= 32 then
						-- GTA style
						-- If victim has less than $500, you take all of his money
						local m = math.min(500,player(t2,"money"))
						parse("setmoney "..t2.." "..player(t2,"money")-m)
						parse("setmoney "..id.." "..player(id,"money")+m)
						msg("©255000000"..player(t2,"name").." has been fined by "..player(id,"name").." for $"..m.."!")
					end
				end
			else
				msg2(id,"©255000000Format: !fine <id>")
			end
		end
	end
end
edited 1×, last 14.09.16 09:48:23 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview