-[IFwsI]-
You need an account to view all sections/topics

Help with LUA Scripts

Page 1 of 2 1, 2  Next

View previous topic View next topic Go down

Help with LUA Scripts

Post by Nighthawk on Fri Oct 30, 2015 9:44 am

Do not make new topics. If you require help with scripts post them here and anyone who's willing can help you right here.
avatar
Nighthawk
-[IFwsI]- Co-Leader
-[IFwsI]- Co-Leader

Gender : Male Posts : 2424
Points : 2900
Join date : 2014-01-02
Age : 18
Location : Outside The Gates Of Your Mind

View user profile http://bit.ly/irfandahir

Back to top Go down

Re: Help with LUA Scripts

Post by Se7en on Fri Oct 30, 2015 4:03 pm

avatar
Se7en
Site user
Site user

Gender : Male Posts : 1162
Points : 1341
Join date : 2013-12-07
Age : 17
Location : Israel

View user profile http://slowpoke101.forum.st/

Back to top Go down

Re: Help with LUA Scripts

Post by alaa on Fri Oct 30, 2015 4:50 pm

here it is.
avatar
alaa
Site user
Site user

Gender : Male Posts : 1073
Points : 1210
Join date : 2015-01-24
Age : 17
Location : ramallah

View user profile

Back to top Go down

Re: Help with LUA Scripts

Post by zAzz on Fri Oct 30, 2015 5:34 pm

How do you make the free day system?
It's so difficult lol, alot of breakable and dynwalls..
avatar
zAzz
Site user
Site user

Gender : Male Posts : 287
Points : 362
Join date : 2015-10-17
Age : 17
Location : Argentina

View user profile http://unrealsoftware.de/profile.php?userid=99264

Back to top Go down

Re: Help with LUA Scripts

Post by cracker22 on Fri Oct 30, 2015 6:06 pm

zAzz LeL
ITS Not script ...
avatar
cracker22
Site user
Site user

Gender : Male Posts : 298
Points : 384
Join date : 2015-09-16
Location : in Your cs2d :P

View user profile

Back to top Go down

Re: Help with LUA Scripts

Post by alaa on Fri Oct 30, 2015 6:24 pm

u can put the freeday randomly from the editor not from a script, but the scan needs a script tho, and soushi gave it for you.
avatar
alaa
Site user
Site user

Gender : Male Posts : 1073
Points : 1210
Join date : 2015-01-24
Age : 17
Location : ramallah

View user profile

Back to top Go down

Re: Help with LUA Scripts

Post by piWi. on Fri Oct 30, 2015 6:49 pm

@zAzz, i rate you to ask someone who you know that he know this stuff. If you have to ask for every small function in the editor, how is it to read the tutorial about creating maps in the editor of cs:2d. I know that you are already able to make some stuff but it will help surely, so you can read it before you ask here. If you are interested click on this.

Also you can learn more if you take a look on california jail, like cracker said, it isnt a script and you are able to create it with the trigger_if.

The freeday system gets triggered by a trigger_if and a random function. fill in this:
Code:
math.random(1, 100) <= 10

Than create a trigger_start, which trigger the trigger_if where you filled this in. Than chose the stuff what should get triggered by a probability of 10% to 100 %, you can change the 10 to every number.

Anyway i would rate you to think about another system instead of a Freeday because it is the idea of lubo and it would be better if it is unique.

Regards
avatar
piWi.
Site user
Site user

Gender : Male Posts : 1312
Points : 1450
Join date : 2015-07-13
Age : 100
Location : Germany

View user profile http://unrealsoftware.de/profile.php?userid=144441

Back to top Go down

Re: Help with LUA Scripts

Post by Nighthawk on Fri Oct 30, 2015 8:47 pm

@se7en, m8.
Nighthawk wrote:
And here
avatar
Nighthawk
-[IFwsI]- Co-Leader
-[IFwsI]- Co-Leader

Gender : Male Posts : 2424
Points : 2900
Join date : 2014-01-02
Age : 18
Location : Outside The Gates Of Your Mind

View user profile http://bit.ly/irfandahir

Back to top Go down

Re: Help with LUA Scripts

Post by Se7en on Sat Oct 31, 2015 7:20 pm

Nighthawk wrote:@se7en, m8.
Nighthawk wrote:
And here

LUA ERROR: sys/lua/autorun/stats.lua:3: '=' expected near 'initArray'
-> [C]: in function 'dofile'
-> [string "dofile("sys/lua/autorun/stats.lua")"]:1: in main chunk

pls?

Edit: nvm u typed fucntion instead of function

Edit2:
LUA ERROR: sys/lua/autorun/stats.lua:32: attempt to index field '?' (a number value)
-> sys/lua/autorun/stats.lua:32: in function
-> in Lua hook 'endround', params: 5
image show when i join but disappear when i restart :c

Edit3: I fixed it c:
avatar
Se7en
Site user
Site user

Gender : Male Posts : 1162
Points : 1341
Join date : 2013-12-07
Age : 17
Location : Israel

View user profile http://slowpoke101.forum.st/

Back to top Go down

Re: Help with LUA Scripts

Post by Mommy123 on Sun Nov 01, 2015 3:40 am

zAzz wrote:How do you make the free day system?
It's so difficult lol, alot of breakable and dynwalls..
You does't need lua script. First time, i have same question. But, now i have one jail map which have freeday system : http://www.unrealsoftware.de/files_show.php?file=16608. It need lot of NPC, dyn_wall, and explosion. But, you can also use script to make freeday system with math.random.
avatar
Mommy123
Site user
Site user

Gender : Male Posts : 102
Points : 116
Join date : 2015-08-06
Age : 16
Location : Indonesia

View user profile

Back to top Go down

Re: Help with LUA Scripts

Post by zAzz on Wed Nov 04, 2015 6:06 am

piWi. wrote:@zAzz, i rate you to ask someone who you know that he know this stuff. If you have to ask for every small function in the editor, how is it to read the tutorial about creating maps in the editor of cs:2d. I know that you are already able to make some stuff but it will help surely, so you can read it before you ask here. If you are interested click on this.

Also you can learn more if you take a look on california jail, like cracker said, it isnt a script and you are able to create it with the trigger_if.

The freeday system gets triggered by a trigger_if and a random function. fill in this:
Code:
math.random(1, 100) <= 10

Than create a trigger_start, which trigger the trigger_if where you filled this in. Than chose the stuff what should get triggered by a probability of 10% to 100 %, you can change the 10 to every number.

Anyway i would rate you to think about another system instead of a Freeday because it is the idea of lubo and it would be better if it is unique.

Regards

Thanks! Thanks Aloot!!, i suck sh*t at scripting lmao
Btw, anyone knows how to make the func_hit compatible with snowballs?
Or can anyone make a fast script for it if it isn't a pain in the ass?
avatar
zAzz
Site user
Site user

Gender : Male Posts : 287
Points : 362
Join date : 2015-10-17
Age : 17
Location : Argentina

View user profile http://unrealsoftware.de/profile.php?userid=99264

Back to top Go down

Re: Help with LUA Scripts

Post by Se7en on Wed Nov 04, 2015 7:59 am

http://pastie.org/private/pygpbb9sudcuhhhtksl5w
Hi I made this level and exp system, I only have one problem, I dont know how to make it save since I have no idea how io. stuff work so... unless you want to teach me I need you to add it in the missing functions.

Code:
function load(id)
   
end

function save(id)
   for id = 1,32 do
      
   end
end

This code is already in there so you shouldnt recreate it!

Also I need the best saving system you can make, that mean anti lag + map change + leaving + any other way to quit the server because my last saving system... rip
avatar
Se7en
Site user
Site user

Gender : Male Posts : 1162
Points : 1341
Join date : 2013-12-07
Age : 17
Location : Israel

View user profile http://slowpoke101.forum.st/

Back to top Go down

Re: Help with LUA Scripts

Post by Frªncis on Tue Jan 26, 2016 9:54 am

Hi guys! I hope you can help me with 2 scripts :/

1:
Code:
function hc.moderation.kick_say_command(p, id)
     local array = {}
     local kick_reason = ""
     array = explode(" ", id)
     for i=2, #array do
          kick_reason = kick_reason.." "..array[i]
     end
     hc.exec(p, "kick " .. array[1]..' "'..kick_reason..'"')
end

function explode(div,str)
  if (div=='') then return false end
  local pos,arr = 0,{}
  for st,sp in function() return string.find(str,div,pos,true) end do
    table.insert(arr,string.sub(str,pos,st-1))
    pos = sp + 1
  end
  table.insert(arr,string.sub(str,pos))
  return arr
end

How to make it that a mod can't kick a other mod or higher? If you can do that then pls send the full code here! Thank you!

PS: Add a error msg like "You can't kick Mod1 or higher."

2:
Code:
   hc.add_menu_command("-[IFwsI]- Jail", hc.moderation.rero, hc.REROUT, hc.COMMAND_MENU_KEY, { category = "Friend Server" })

function hc.moderation.rero(p,func)
local entries = {
            { title = "Yes: Connect -[IFwsI]- Jail!", value = true },
            { title = "No: Don't connect -[IFwsI]- Jail!", value = false }
        }
        hc.show_menu(p, "Connect -[IFwsI]- Jail?", entries, func)
end

where i put this parse code for make it work? O.o
Code:
function hc.moderation.rero(p, _, item)
      parse("reroute "..p.." 149.202.65.171:36532")
end
avatar
Frªncis
Site user
Site user

Gender : Male Posts : 163
Points : 229
Join date : 2014-06-16
Age : 17
Location : Jail

View user profile http://dr2d.omgforum.net/

Back to top Go down

Re: Help with LUA Scripts

Post by Soushiant.iR on Wed Jan 27, 2016 9:22 pm

Replace
Code:
hc.exec(p, "kick " .. array[1]..' "'..kick_reason..'"')

with
Code:
if hc.is_moderator(array[1]) then
 msg2(p,"NOPE")
else
 hc.exec(p, "kick " .. array[1]..' "'..kick_reason..'"')
end

_________________
memes
avatar
Soushiant.iR
Moderator
Moderator

Gender : Male Posts : 1266
Points : 1419
Join date : 2011-12-21
Age : 19
Location : Earthend

View user profile http://project-extract.site50.net/Download/gui.html

Back to top Go down

Re: Help with LUA Scripts

Post by Frªncis on Wed Jan 27, 2016 10:21 pm

Thanks! and with the rerout script ehm just forgot it, I have it already. Razz
avatar
Frªncis
Site user
Site user

Gender : Male Posts : 163
Points : 229
Join date : 2014-06-16
Age : 17
Location : Jail

View user profile http://dr2d.omgforum.net/

Back to top Go down

Re: Help with LUA Scripts

Post by zAzz on Sat Feb 06, 2016 2:16 am

Can someone help me?, It doesn't work Crying or Very sad
Code:

triggers = {
freeday = {cell1, cell2, cell3, cell4, cell5, cell6, cell7, cell8, cell9, cell10, itemz, freeday, freedayz, freedaysecret, startsecret, thedelayz2, itemz2},
warzone = {warz, thedelayz, warzs, rain}
}
addhook(startround, roundstart)
function roundstart()
    local const_rand = math.random(1,100)
    if const_rand > 90 then
          for i=1,#triggers.freeday do
              parse('trigger '..triggers.freeday[i])
          end
    elseif const_rand <= 5 then
          for i=1,#triggers.warzone do
              parse('trigger '..triggers.warzone[i])
          end
          for k,v in pairs (player(0,"tableliving")) do
              if player(v,"team") == 1 then
                    parse("setpos "..v.." 5520 "..math.random(54,65)*32+16)
              else
                    parse("setpos "..v.." 6384 "..math.random(54,65)*32+16)
              end
          end
    end
end
 
--
-- Scan Script
--
 
scanners = {
        {119,137,'hasWeapons','hasNoWeapons'}
        {53,129,'hasWeapons1','hasNoWeapons1'}
}
addhook(movetile,movetile_hook)
function movetile_hook(id, x, y)
    for _,i in pairs (scanners) do
          if x == scanners[_][1] and y == scanners[_][2] then
              if #playerweapons(id)  1 then
                    parse(trigger ..scanners[_][3])
              else
                    parse(trigger ..scanners[_][4])
              end
          end
    end
end

What's wrong?
avatar
zAzz
Site user
Site user

Gender : Male Posts : 287
Points : 362
Join date : 2015-10-17
Age : 17
Location : Argentina

View user profile http://unrealsoftware.de/profile.php?userid=99264

Back to top Go down

Re: Help with LUA Scripts

Post by Soushiant.iR on Sat Feb 06, 2016 5:37 am

Code:
triggers = {
   freeday = {'cell1', 'cell2', 'cell3',
            'cell4', 'cell5', 'cell6',
            'cell7', 'cell8', 'cell9',
            'cell10', 'itemz', 'freeday',
            'freedayz', 'freedaysecret',
            'startsecret', 'thedelayz2', 'itemz2'},
   warzone = {'warz', 'thedelayz', 'warzs', 'rain'}
}
addhook("startround", "roundstart")
function roundstart()
   local const_rand = math.random(1,100)
   parse("msg "..const_rand)
    if const_rand > 90 then
      for i=1,#(triggers.freeday) do
         parse('trigger '..triggers.freeday[i])
      end
    elseif const_rand <= 5 then
      for i=1,#(triggers.warzone) do
         parse('trigger '..triggers.warzone[i])
      end
      for k,v in pairs (player(0,"tableliving")) do
         if player(v,"team") == 1 then
            parse("setpos "..v.." 5520 "..math.random(54,65)*32+16)
         else
            parse("setpos "..v.." 6384 "..math.random(54,65)*32+16)
         end
      end
    end
end
avatar
Soushiant.iR
Moderator
Moderator

Gender : Male Posts : 1266
Points : 1419
Join date : 2011-12-21
Age : 19
Location : Earthend

View user profile http://project-extract.site50.net/Download/gui.html

Back to top Go down

Re: Help with LUA Scripts

Post by zAzz on Sat Feb 06, 2016 9:23 am

Still doesn't work o_O
avatar
zAzz
Site user
Site user

Gender : Male Posts : 287
Points : 362
Join date : 2015-10-17
Age : 17
Location : Argentina

View user profile http://unrealsoftware.de/profile.php?userid=99264

Back to top Go down

Re: Help with LUA Scripts

Post by Nighthawk on Sat Feb 06, 2016 10:47 am

1.Don't put it in autorun. Link it via server.lua.
2. Check the console for errors.
3. If errors, report here else check if the hooks in the script are being called
4. If the hooks are being called, something is wrong in the universe or you have multiple hooks clashing else you have the wrong file encoding set for the lua script.
5. Change file encoding: http://www.unrealsoftware.de/forum_posts.php?post=374427
avatar
Nighthawk
-[IFwsI]- Co-Leader
-[IFwsI]- Co-Leader

Gender : Male Posts : 2424
Points : 2900
Join date : 2014-01-02
Age : 18
Location : Outside The Gates Of Your Mind

View user profile http://bit.ly/irfandahir

Back to top Go down

Re: Help with LUA Scripts

Post by Soushiant.iR on Sat Feb 06, 2016 9:04 pm

It worked for me so idk mb there are some other part of your code is interfering with it
avatar
Soushiant.iR
Moderator
Moderator

Gender : Male Posts : 1266
Points : 1419
Join date : 2011-12-21
Age : 19
Location : Earthend

View user profile http://project-extract.site50.net/Download/gui.html

Back to top Go down

Re: Help with LUA Scripts

Post by zAzz on Sat Feb 06, 2016 10:38 pm

Thanks guys i fixed it Very Happy
avatar
zAzz
Site user
Site user

Gender : Male Posts : 287
Points : 362
Join date : 2015-10-17
Age : 17
Location : Argentina

View user profile http://unrealsoftware.de/profile.php?userid=99264

Back to top Go down

Re: Help with LUA Scripts

Post by Nighthawk on Sun Feb 07, 2016 4:08 pm

It's always best practice to tell how you fixed it incase others have the same problem.
avatar
Nighthawk
-[IFwsI]- Co-Leader
-[IFwsI]- Co-Leader

Gender : Male Posts : 2424
Points : 2900
Join date : 2014-01-02
Age : 18
Location : Outside The Gates Of Your Mind

View user profile http://bit.ly/irfandahir

Back to top Go down

Re: Help with LUA Scripts

Post by Se7en on Sun Feb 07, 2016 6:07 pm

Code:
hudtxt2(id,ar.hudids[2],"©️255255255","NEXT WEAPON:",635,380,2)

What is wrong with this line?
It will place the hud at the top left of the screen Sad
avatar
Se7en
Site user
Site user

Gender : Male Posts : 1162
Points : 1341
Join date : 2013-12-07
Age : 17
Location : Israel

View user profile http://slowpoke101.forum.st/

Back to top Go down

Re: Help with LUA Scripts

Post by _Yank on Sun Feb 07, 2016 7:08 pm

@Se7en: hudtxt2 is CS2D console command not a lua function. You can use the lua function called "parse" to execute CS2D commands:
Code:
parse("hudtxt2 "..id.." "..ar.hudids[2].." \"©255255255NEXT WEAPON:\" 635 380 2")

Note: \" is used to "tell" the script that " is the character " itself and not a script keyword.
avatar
_Yank
Site user
Site user

Gender : Male Posts : 394
Points : 654
Join date : 2012-06-01
Age : 17
Location : Under your bed

View user profile http://ares2d.tk

Back to top Go down

Re: Help with LUA Scripts

Post by Se7en on Sun Feb 07, 2016 7:21 pm

Edit: NVM I found out that there's two of these lines and I replaced only one of them
thanks

Code:
hudtxt2(id,ar.hudids[1],"©️255255255",itemtype(ar.weapons[ar.level[id]+1],"name").." ("..ar.level[id].."/"..#ar.weapons..")",635,430,2)
hudtxt(ar.hudids[3],"©️"..tm[player(id,"team")].."","Lead: ("..ar.level[id]..") "..player(id,"name").."",5,110,0)

I need help to convert these two into what Yank made but I failed because of the mass strings Sad
avatar
Se7en
Site user
Site user

Gender : Male Posts : 1162
Points : 1341
Join date : 2013-12-07
Age : 17
Location : Israel

View user profile http://slowpoke101.forum.st/

Back to top Go down

Re: Help with LUA Scripts

Post by Sponsored content


Sponsored content


Back to top Go down

Page 1 of 2 1, 2  Next

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum