English Give Weapon

10 replies
Goto Page
To the start Previous 1 Next To the start
04.05.12 06:51:39 pm
Up
Jhony
User
Offline Off
When say :
Code:
1
!set weapon [ID] [WEAPON]


Goes a gun to the ID selected

Example :

!set weapon <ID OF PLAYER> <WEAPON>

!set weapon 1 45
msg2(id,"You Have a new weapon!")

help?
04.05.12 06:58:27 pm
Up
Alistaire
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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

addhook('say', 'giveweapon')

function giveweapon(id, msg)
     local a = totable(msg)
     if a[1] == '!set' then
          if a[2] == weapon then
               parse('equip '..a[3]..' '..a[4])
               msg2(a[3], You've got a new weapon!')
          end
     end
end
edited 2×, last 04.05.12 07:14:27 pm
IMG:http://i.imgur.com/5zhwOTP.png
04.05.12 07:12:06 pm
Up
Jhony
User
Offline Off
user Alistaire has written:
Code:
1
2
3
4
5
6
7
8
9
10
11
addhook('say', 'giveweapon')

function giveweapon(id, msg)
     local a = totable(msg)
     if a[1] == !set then
          if a[2] == weapon then
               parse('equip '..a[3]..' '..a[4])
               msg2(a[3], You've got a new weapon!')
          end
     end
end


LUA ERROR: sys/lua/buil.lua:5: unexpected symbol near '!'
04.05.12 07:12:42 pm
Up
Cure Pikachu
User
Offline Off
@user Alistaire: I can easily spot some major errors. Fixed.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function totable(t,match)
     local cmd = {}
     if not match then
          match = "[^%s]+"
     else
          match = "[^"..match.."]+"
     end
     for word in string.gmatch(t,match) do
          table.insert(cmd,word)
     end
     return cmd
end

addhook('say','giveweapon')

function giveweapon(id,txt)
     local a = totable(txt)
     if a[1] == "!set" then
          if a[2] == "weapon" then
               parse('equip '..a[3]..' '..a[4])
               msg2(tonumber(a[3]),"You've got a new weapon!")
          end
     end
end
edited 1×, last 04.05.12 07:13:37 pm
IMG:https://i.imgur.com/uUrye71.png
IMG:https://i.imgur.com/xpsyQRX.png
04.05.12 07:13:17 pm
Up
Alistaire
User
Offline Off
user Cure Pikachu has written:
@user Alistaire: I can easily spot some major errors. Fixed.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function totable(t,match)
     local cmd = {}
     if not match then
          match = "[^%s]+"
     else
          match = "[^"..match.."]+"
     end
     for word in string.gmatch(t,match) do
          table.insert(cmd,word)
     end
     return cmd
end

addhook('say','giveweapon')

function giveweapon(id, msg)
     local a = totable(msg)
     if a[1] == "!set" then
          if a[2] == "weapon" then
               parse('equip '..a[3]..' '..a[4])
               msg2(tonumber(a[3]),"You've got a new weapon!")
          end
     end
end


You kidding me? I didn't add apastrophes at the a[1] == !set

You added a useless function for something which already exists.
IMG:http://i.imgur.com/5zhwOTP.png
04.05.12 09:50:35 pm
Up
EP
User
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
addhook("say","a")
function a(id,txt)
     if txt:sub(1,1) == "!" then
          if txt:sub(1,4) == "!set" then
               local pl = string.sub(txt,6,7)
               local iid = string.sub(txt,9,10)
               parse("equip "..pl.." "..iid)
          return 1
          end
     end
end
04.05.12 10:12:57 pm
Up
Alistaire
User
Offline Off
user EP has written:
Code:
1
2
3
4
5
6
7
8
9
10
11
addhook("say","a")
function a(id,txt)
     if txt:sub(1,1) == "!" then
          if txt:sub(1,4) == "!set" then
               local pl = string.sub(txt,6,7)
               local iid = string.sub(txt,9,10)
               parse("equip "..pl.." "..iid)
          return 1
          end
     end
end


That doesn't work bro. He wants the function to be !set weapon, not !set.
IMG:http://i.imgur.com/5zhwOTP.png
04.05.12 11:34:22 pm
Up
Infinite Rain
Reviewer
Offline Off
user Alistaire has written:
user Cure Pikachu has written:
@user Alistaire: I can easily spot some major errors. Fixed.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function totable(t,match)
     local cmd = {}
     if not match then
          match = "[^%s]+"
     else
          match = "[^"..match.."]+"
     end
     for word in string.gmatch(t,match) do
          table.insert(cmd,word)
     end
     return cmd
end

addhook('say','giveweapon')

function giveweapon(id, msg)
     local a = totable(msg)
     if a[1] == "!set" then
          if a[2] == "weapon" then
               parse('equip '..a[3]..' '..a[4])
               msg2(tonumber(a[3]),"You've got a new weapon!")
          end
     end
end


You kidding me? I didn't add apastrophes at the a[1] == !set

You added a useless function for something which already exists.


Yep he added just few useless lines.
Well, theres one more way to do this. But everything already done.
A thousand may fall at your side, ten thousand at your right hand, but it will not come near you. You will only look with your eyes and see the recompense of the wicked. - Psalm 91:7-8 ESV
05.05.12 06:14:01 am
Up
MikuAuahDark
User
Offline Off

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("say","_say")
function _say(id,txt)
     if txt:sub(1,11)=="!set weapon" then
          pl = 0
          weaponid = 0
          if txt:sub(14,14)~=" " then
               pl = tonumber(txt:sub(13,14))
               weaponid = tonumber(txt:sub(16))
          else
               pl = tonumber(txt:sub(13,13))
               weaponid = tonumber(txt:sub(15))
          end
          if player(pl,"exists") then
               if itemtype(weaponid,"name")~=nil then
                    parse("equip "..pl.." "..weaponid)
                    msg2(pl,"You Have a new weapon!@C")
               end
          end
     end
end
Hello? Are you there, Tae Hanazono?
05.05.12 10:25:53 am
Up
Alistaire
User
Offline Off
user MikuAuahDark has written:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
addhook("say","_say")
function _say(id,txt)
     if txt:sub(1,11)=="!set weapon" then
          pl = 0
          weaponid = 0
          if txt:sub(14,14)~=" " then
               pl = tonumber(txt:sub(13,14))
               weaponid = tonumber(txt:sub(16))
          else
               pl = tonumber(txt:sub(13,13))
               weaponid = tonumber(txt:sub(15))
          end
          if player(pl,"exists") then
               if itemtype(weaponid,"name")~=nil then
                    parse("equip "..pl.." "..weaponid)
                    msg2(pl,"You Have a new weapon!@C")
               end
          end
     end
end


Well this works, but if you want more functions, the best would be my script. You could add a line like elseif a[2] == 'health' then etc. etc.
IMG:http://i.imgur.com/5zhwOTP.png
08.06.12 05:53:43 am
Up
Ariiel
User
Offline Off
Or use give weapons lua by Daky_Sky that is only for admin

Code:
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
adminlist = {12345}

function isadmin(id)
     for _, usgn in ipairs(adminlist) do
          if player(id,"usgn")==usgn then
               return true
          end
     end
     return false
end

function rp_msg2(id,clr,txt)
     if player(id,"exists") then
          msg2(id,"©"..clr..txt)
     end
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

addhook("say","GiveWeapons")
function GiveWeapons(id,txt)
     local p = totable(txt)
     local cmd = tostring(p[1])
     if cmd == "!setwpn" then
          if isadmin(id) then
               local pl = tonumber(p[2])
               local weapon = tonumber(p[3])
               if pl ~= nil and weapon ~= nil then
                    if player(pl,"exists") then
                         parse("equip "..pl.." "..weapon)
                         rp_msg2(pl,"000255000",player(id,"name").." gave you New Weapon!")
                         rp_msg2(id,"000255000","You gave new Weapon ID["..weapon.."] to "..player(pl,"name"))
                    end
               end
          end
          return 1
     end
end
«Ariiel» LoL~*
To the start Previous 1 Next To the start