Forum




Give Money script
17 replies



i feel stupid now.
edited 2×, last 07.02.16 10:41:56 pm
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
seconds = 3 -- You can change this if you wish addhook("second", "_second") function _second() 	local playerlist = player(0,"tableliving") 	for _, id in pairs(playerlist) do 		if player(id,"money") == 0 then 			timer(seconds*1000, "parse", "setmoney "..id.." 16000") 		end 	end end
edited 2×, last 07.02.16 10:43:04 pm


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
spawn_money = true spawnmoney = { [1] = game("mp_startmoney"); [2] = 16000; } spawn_money_type = 2 spawn_money = true addhook("spawn", "_s") function _s(id) 	if spawn_money then 		parse("setmoney "..id.." "..spawnmoney[spawn_money_type]) 	end end --[[ 1 for set money 2 for 16000 money, you may also set it to any value you like. If you want normal money, set spawn_money to false. ]]
edited 1×, last 08.02.16 08:22:15 am





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
local togive = {} for id = 1, 32 do 	togive[id] = false end function givemoney(id) 	id = tonumber(id) 	togive[id] = false 	 	parse("setmoney " .. id .. " 16000") end function alwayshook() 	for index, id in ipairs(player(0, "tableliving")) do 		if (player(id, "money") == 0 and not togive[id]) then 			togive[id] = true 			 			timer(3000, "givemoney", id) 		end 	end end addhook("always", "alwayshook")
edited 1×, last 08.02.16 09:31:03 am



1
parse("setmoney " .. id .. " 16000")


So by the spawn hook, it will not give 16000 immediately if the player's money is 0, unless he re-spawned again.


@






This time it will only create


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
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
local togive = {} local oldparse = parse for id = 1, 32 do 	togive[id] = false end function givemoney(id) 	id = tonumber(id) 	togive[id] = false 	 	parse("setmoney " .. id .. " 16000") end function checkmoney(id) 	if (player(id, "money") == 0 and not togive[id]) then 		togive[id] = true 		 		timer(3000, "givemoney", id) 	end end function buyhook(id) 	checkmoney(id) end function string:split(delimiter) 	local strs = {} 	 	for index, str in string:gmatch("[^" .. delimiter .. "]+") do 		strs[#strs + 1] = str 	end 	 	return strs end function parse(commands, stop) 	if (stop == 0 and commands:find(";")) then 		for index, str in ipairs(commands:split(";")) do 			local starts, ends = str:find("setmoney") 			 			if (starts and ends) then 				checkmoney(tonumber(str:split("%s")[2])) 			end 		end 	else 		local starts, ends = commands:find("setmoney") 		 		if (starts and ends) then 			checkmoney(tonumber(commands:split("%s")[2])) 		end 	end 	 	return oldparse(commands, stop) end addhook("buy", "buyhook")
edited 2×, last 09.02.16 07:07:29 am


1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
valuemoney = 16000 minmoney = 0 function OnSpawn(id) 	if player(id,'money') <= minmoney then 		parse("setmoney "..id.." "..valuemoney.."") 	end end addhook("spawn","OnSpawn")

1
parse("setmoney "..id.." "..valuemoney.."")


1
"..variable.." == "..variable
is my custom




