English Start item

6 replies
Goto Page
To the start Previous 1 Next To the start
14.06.18 04:19:26 pm
Up
NikiCheL
User
Offline Off
us Hi, everybody

> Who can make a script for me?

Well, in General, this script should be a menu. and in it for example Molotov / off Molotov / on. This means a birth without Molotov and a on with Molotov. I apologize in advance for my English

Help me pliz
15.06.18 07:29:12 am
Up
JERE LAHORCA
User
Offline Off
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
48
49
50
51
52
53
plSp = {
     he = {},
     motv = {},
     wrn = {},
     kev = {},
     nv = {}
}
for i = 1,32 do
     plSp.he[i] = 'OFF'
     plSp.motv[i] = 'OFF'
     plSp.wrn[i] = 'OFF'
     plSp.kev[i] = 'OFF'
     plSp.nv[i] = 'OFF'
end

addhook('serveraction','start_items')
function start_items(id,action)
if action==1 then
               menu(id,'Start Player Item,HE|IS '..plSp.he[id]..',Motolov Cocktail|IS '..plSp.motv[id]..',Wrench|IS '..plSp.wrn[id]..',Kevlar + Helm|IS '..plSp.kev[id]..',Night Vision|IS '..plSp.nv[id])
end
end

addhook('menu','spawnItems')
function spawnItems(id,mnu,btn)
     if mnu == 'Start Player Item' then
          local E,D = '\169000255000ENABLED@C','\169255000000DISABLED@C'
          if btn == 1 then
               if plSp.he[id] == 'OFF' then plSp.he[id] = 'ON' else plSp.he[id] = 'OFF' end
               if plSp.he[id] == 'OFF' then msg2(id,'HE '..D) else msg2(id,'HE '..E) end
          elseif btn == 2 then
               if plSp.motv[id] == 'OFF' then plSp.motv[id] = 'ON' else plSp.motv[id] = 'OFF' end
               if plSp.motv[id] == 'OFF' then msg2(id,'Motolov Cocktail '..D) else msg2(id,'Motolov Cocktail '..E) end
          elseif btn == 3 then
               if plSp.wrn[id] == 'OFF' then plSp.wrn[id] = 'ON' else plSp.wrn[id] = 'OFF' end
               if plSp.wrn[id] == 'OFF' then msg2(id,'Wrench '..D) else msg2(id,'Wrench '..E) end
          elseif btn == 4 then
               if plSp.kev[id] == 'OFF' then plSp.kev[id] = 'ON' else plSp.kev[id] = 'OFF' end
               if plSp.kev[id] == 'OFF' then msg2(id,'Kevlar + Helm '..D) else msg2(id,'Kevlar + Helm '..E) end
          elseif btn == 5 then
               if plSp.nv[id] == 'OFF' then plSp.nv[id] = 'ON' else plSp.nv[id] = 'OFF' end
               if plSp.nv[id] == 'OFF' then msg2(id,'Night Vision '..D) else msg2(id,'Night Vision '..E) end
          end
     end
end

addhook('spawn','spawnItem')
function spawnItem(id)
     if plSp.he[id] == 'ON' then parse('equip '..id..' 51') end
     if plSp.motv[id] == 'ON' then parse('equip '..id..' 73') end
     if plSp.wrn[id] == 'ON' then parse('equip '..id..' 74') end
     if plSp.kev[id] == 'ON' then parse('equip '..id..' 58') end
     if plSp.nv[id] == 'ON' then  parse("spawnitem 59 "..player(id,"tilex").." "..player(id,"tiley")) end
end


I assumed you wanted something like iran town
السلام في سوريا
15.06.18 08:00:33 am
Up
NikiCheL
User
Offline Off
@user JERE LAHORCA: Thank you. You helped me.
16.06.18 12:32:57 am
Up
Rainoth
Moderator
Offline Off
@user JERE LAHORCA: You could just use a single table for this. No need to make a separate key for every item he'll want to add.
16.06.18 06:12:06 am
Up
JERE LAHORCA
User
Offline Off
user Rainoth you do it :]
السلام في سوريا
16.06.18 05:15:20 pm
Up
Rainoth
Moderator
Offline Off
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
48
items = {
     spawn = "",
     off = {51, 73, 74, 58, 59},
     on = {},
     menuString = "Start player items",
     hooks = {"serveraction","menu","spawn"},
     admin = 155954
}

for k,hook in pairs (items.hooks) do
     addhook(hook, "_"..hook)
end

function getMenu() 
     for k,v in pairs (items.off) do
          menuString = menuString..","..itemtype(v,"name").."|DISABLED"
     end
     for k,v in pairs (items.on) do
          menuString = menuString..","..itemtype(v,"name").."|ENABLED"
     end
end

function _serveraction(id, b)
     if player(id,"usgn") == items.admin then
          menu(id,getMenu())
     end
end

function _menu(id, t, b)
     if t == "Start player items" then
          if items.off[b] ~= nil then
               items.on[b] = items.off[b]
               items.off[b] = nil
          end
          if items.on[b] ~= nil then
               items.off[b] = items.on[b]
               items.on[b] = nil
          end
          for k,v in pairs (items.on) do
               items.spawn = items.spawn..tostring(v)..","
          end
          items.spawn = items.spawn:sub(1,items.spawn:len()-1)
     end
end

function _spawn(id)
     return items.spawn
end


@user JERE LAHORCA: Something like this, I suppose?
This way he wouldn't need to change every single function in your script when he wants to add a new item (unless it would exceed the menu size which is 9 but the same would apply to your script).
Didn't test it but I doubt that guy will come back to see this one and you could see what I'm getting at.
17.06.18 07:41:02 pm
Up
NikiCheL
User
Offline Off
@user Rainoth: Thank you
To the start Previous 1 Next To the start