Forum

> > CS2D > Scripts > Item Lua
Forums overviewCS2D overview Scripts overviewLog in to reply

English Item Lua

32 replies
Page
To the start Previous 1 2 Next To the start

old Item Lua

limonata
User Off Offline

Quote
Hello all may you do this script?

!i [itemID] gives me that item

!i [id] [itemID] gives item to selected id.

------------------
!i 82 --> I wore medic armor.
!i 2 82 --> id 2 wore medic armor.
------------------------
and !spawn [itemID]

Thank you

old Re: Item Lua

limonata
User Off Offline

Quote
I know i can do this with rcon but I dont want to give rcon to other members. So I need this lua Thanks for your comment.

Is there someone for help me?
edited 1×, last 05.02.13 03:49:47 pm

old Re: Item Lua

sheeL
User Off Offline

Quote
Like this?...

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
function split(string)
     local c = {}
     for word in string.gmatch(string, '[^%s]+') do
          table.insert(c, word)
     end
     return c
end

addhook("say","OnSay")
function OnSay(id,text)
local v = split(text)
if v[1] == "!i" then
	if v[2] == nil then 
		parse("equip "..id.." "..v[3]) 
			msg2(id,"©255255255New Weapon") 
		return 1
		end
	if player(v[2],"exists") then
		parse("equip "..v[2].." "..v[3])
			msg2(v[2],"©255255255Admin "..player(id,"name").." Gave to you a new Weapon")
			return 1
		end
		elseif v[1] == "!spawn" then
		parse("spawnitem "..v[2].." "..v[3].." "..v[4])
		return 1
	end
end

old Re: Item Lua

limonata
User Off Offline

Quote
!i [id] [itemID] is working right.

But I need also !i [id]

!i 83 --> will give me super armor but just me not another.

and !spawn [itemID] --> will spawn that item where am I

and please make for admins

old Re: Item Lua

sheeL
User Off Offline

Quote
oh sorry, my mistake, fixed

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
function split(string)
     local c = {}
     for word in string.gmatch(string, '[^%s]+') do
          table.insert(c, word)
     end
     return c
end

adminList = {xxxxx}

addhook("say","OnSay")
function OnSay(id,text)
local v = split(text)
for _, key in ipairs(adminList) do
if player(id,"usgn") == key then
if v[1] == "!i" then
	if not player(v[2],"exists") then
		parse("equip "..id.." "..v[2]) 
			msg2(id,"©255255255New Weapon") 
		return 1
		end
	if player(v[2],"exists") then
		parse("equip "..v[2].." "..v[3])
			msg2(v[2],"©255255255Admin "..player(id,"name").." Gave to you a new Weapon")
			return 1
		end
		elseif v[1] == "!spawn" then
		parse("spawnitem "..v[2].." "..player(id,"tilex").." "..player(id,"tiley"))
		return 1
		end
		end
	end
end

old Re: Item Lua

limonata
User Off Offline

Quote
@user sheeL: Thank you so much

And I have one question more. I am sorry I am disturbing you

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
members = {xxxxx,xxxxx}

local a = members

addhook("say","command")
function command(id,txt)
for _, usgn in pairs(members) do
if player(id,"usgn") == usgn then
if string.sub(txt, 1, 2) == "!k" then
local kid = string.sub(txt, 4, 5)
parse("kick "..kid)
msg2(a,"©255000000Kicked Player: "..player(id,"name"))
return 1
end
end
end
end

This is wrong script. I hope you understand what I want.
When I kicked someone there will be a msg like "limonata kicked (playerName)" This message will be appear for just members other player cant see.

old Cool for You

Gajos
BANNED 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
admins = {1,108942}
commands = {"!equip","!spawn","!kick"}

cmd = {}
addhook("say","cmd.say")
function cmd.say(id,txt)
	local p = ToTable(txt)
	local cmd = string.lower(p[1])
	if txt:sub(1,1) == "!" and txt ~= "rank" then
		if cmd == commands[1] then
			if Player[id].admin then
				local pl = tonumber(p[2])
				local item = tonumber(p[3])
				if pl ~= nil and item ~= nil then
					parse("equip "..pl.." "..item)
				elseif pl ~= nil and item == nil then
					parse("equip "..id.." "..pl)
				else
					msg2(id,string.char(169).."200000000Correct syntax: "..commands[1].." [playerid] <itemid>")
				end
			else
				noadm(id)
			end
		elseif cmd == commands[2] then
			if Player[id].admin then
				local item = tonumber(p[2])
				if item ~= nil then
					parse("spawnitem "..item.." "..player(id,"tilex").." "..player(id,"tiley"))
				else
					msg2(id,string.char(169).."200000000Correct syntax: "..commands[2].." <itemid>")
				end
			else
				noadm(id)
			end
		elseif cmd == commands[3] then
			if Player[id].admin then
				local pl = tonumber(p[2])
				if pl ~= nil then
					msg2(id,string.char(169).."200000000"..player(pl,"name").." has been kicked!")
					parse("kick "..pl)
				else
					msg2(id,string.char(169).."200000000Correct syntax: "..commands[3].." <playerid>")
				end
			else
				noadm(id)
			end
		else
			msg2(id,string.char(169).."200000000Unknown command: ["..txt.."]")
		end
		return 1
	end
end

Player = {}
addhook("join","cmd.join")
function cmd.join(id)
	if not player(id,"bot") then
		Player[id] = {}
		Player[id].admin = false
		for _, i in pairs(admins) do
			if player(id,"usgn") == i then
				Player[id].admin = true
			end
		end
	end
end

function noadm(id)
	msg2(id,string.char(169).."200000000You don't have enough level to do this!")
end

function ToTable(t, match)
	local cmd = {};
	if not match then match = "[^%s]+" end
	for word in string.gmatch(t,match) do
		table.insert(cmd,word)
	end
	return cmd
end

old Re: Item Lua

Gajos
BANNED Off Offline

Quote
user limonata has written
@user Gajos: Thank you so much Its really perfect

Thank you for appreciating my work.
If you need help, write the PM to me.
Spoiler >

old Re: Item Lua

Shawni
User Off Offline

Quote
user limonata has written
@user sheeL: Thank you so much

And I have one question more. I am sorry I am disturbing you

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
members = {xxxxx,xxxxx}

local a = members

addhook("say","command")
function command(id,txt)
for _, usgn in pairs(members) do
if player(id,"usgn") == usgn then
if string.sub(txt, 1, 2) == "!k" then
local kid = string.sub(txt, 4, 5)
parse("kick "..kid)
msg2(a,"©255000000Kicked Player: "..player(id,"name"))
return 1
end
end
end
end

This is wrong script. I hope you understand what I want.
When I kicked someone there will be a msg like "limonata kicked (playerName)" This message will be appear for just members other player cant see.


Its because
1
msg2(a,"©255000000Kicked Player: "..player(id,"name"))
edited 1×, last 06.02.13 05:32:20 pm

old Re: Item Lua

limonata
User Off Offline

Quote
I know dude But I want that message just will be appear for members. Did u understand?

member = {}

old Re: Item Lua

EngiN33R
Moderator Off Offline

Quote
To send the message to members you'll need to do it like so:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
members = {xxxxx,xxxxx}

addhook("say","command")
function command(id,txt)
	if string.sub(txt, 1, 2) == "!k" then
		local kid = string.sub(txt, 4, 5)
		for _, usgn in pairs(members) do
			if player(id,"usgn") == usgn then
				parse("kick "..kid)
				for __,pid in pairs(player(0,"table")) do
					if player(pid,"usgn")==usgn then
					msg2(pid,"©255000000Kicked Player: "..player(id,"name"))
					end
				end
			end
		end
		return 1
	end
end

EDIT: I forgot an end, sorry.
edited 1×, last 05.02.13 10:09:14 pm

old Re: Item Lua

limonata
User Off Offline

Quote
Engin33r thank you so much

Edit: Engin33r may you add kicked player? I mean limonata kicked (playerName)

I tiried this but it gave an error: LUA ERROR: sys/lua/ca3.lua:145: attempt to call a string value
Line 140: local pl = tonumber(p[2])
Line 141: if cmd == "!k" then
Line 142: parse("kick "..pl)
Line 143: for __,pid in pairs(player(0,"table")) do
Line 144: if player(pid,"usgn")==usgn then
Line 145: msg2(pid,"©255000000Admin"..player(id,"name")"Kicked" ..player(pl,"name"))
edited 1×, last 05.02.13 10:59:34 pm

old Re: Item Lua

sheeL
User Off Offline

Quote
user limonata has written
Line 145: msg2(pid,"©255000000Admin"..player(id,"name")"Kicked" ..player(pl,"name"))


msg2(pid,"©255000000Admin "..player(id,"name").." Kicked "..player(pl,"name"))

old Re: Item Lua

limonata
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
local p = totable(txt)
local cmd = tostring(p[1])
local pl = tonumber(p[2])
if cmd == "!k" then
parse("kick "..pl)
for __,pid in pairs(player(0,"table")) do
                    if player(pid,"usgn")==usgn then
                         msg2(pid,"©255000000Admin "..player(id,"name").." Kicked "..player(pl,"name"))
                    end
               end
return 1

Line 8 doesnt work. When I kicked bot. bot kicked but there isnt any message.

old Re: Item Lua

wotaan
User Off Offline

Quote
Because u kicked it first. After that u cant reach his name again. Try this one.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
members = {xxxxx,xxxxx}

addhook("say","command")
function command(id,txt)
     if string.sub(txt, 1, 2) == "!k" then
          local kid = string.sub(txt, 4, 5)
          for _, usgn in pairs(members) do
               if player(id,"usgn") == usgn then
                    for __,pid in pairs(player(0,"table")) do
                         if player(pid,"usgn")==usgn then
                         msg2(pid,"©255000000Kicked Player: "..player(id,"name"))
                         end
                    end
				 parse("kick "..kid)
               end
			end
         return 1
     end
end
edited 2×, last 06.02.13 12:39:09 pm

old Re: Item Lua

limonata
User Off Offline

Quote
wootan thank you I solved my problem you are right.


Edit: wootan may u make this?


elseif string.sub(txt,1,4) == "!res" then
local reset = string.sub(txt,6,7)
parse("restart "..reset)
for __,pid in pairs(player(0,"table")) do
if player(pid,"usgn")==usgn then
msg2(pid,"©255000000"..player(id,"name").. ..reset.. "Saniyelik Restart Atti ")
end
end
           return 1

it gives error. Please fix
edited 1×, last 06.02.13 12:28:14 pm
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview