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

Help with LUA Scripts

Page 2 of 2 Previous  1, 2

View previous topic View next topic Go down

Re: Help with LUA Scripts

Post by Se7en on Sun Feb 21, 2016 5:04 pm

Code:
addhook("projectile","_projectile")
function _projectile(id,weapon,x,y)
   if (weapon==86) then
      local gut = math.random(1,91)
      parse("spawnitem "..gut.." "..x.." "..y)
   elseif (weapon==54) then
      local flare = math.random(25,91)
      parse("spawnitem "..flare.." "..x.." "..y)
   elseif (weapon==53) then
      local smoke = math.random(50,91)
      parse("spawnitem "..smoke.." "..x.." "..y)
   end
end

Error:
Code:
ERROR: spawnitem - position is out of map bounds!

plis help
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 ZxC on Sun Feb 21, 2016 5:28 pm

@Se7en: Even though the projectile reference tells X and Y position in pixels, spawnitem only accepts tile positions. Some people tend to forget this and is the one of the main reason why CS2D triggers this issue. To fix this, simply use math.floor function from Math library for both X and Y variables. Like this:

Code:
function _projectile(id, weapon, x, y)
   if (weapon == 86) then
      local gut = math.random(1, 91)
      parse("spawnitem ".. gut .." ".. math.floor(x/32) .." ".. math.floor(y/32))
   elseif (weapon == 54) then
      local flare = math.random(25, 91)
      parse("spawnitem ".. flare .." ".. math.floor(x/32) .." ".. math.floor(y/32))
   elseif (weapon == 53) then
      local smoke = math.random(50, 91)
      parse("spawnitem ".. smoke .." ".. math.floor(x/32) .." ".. math.floor(y/32))
   end
end

addhook("projectile","_projectile")

Now it should work properly without giving any further technical error. Please, keep this in mind this tip whenever you attempt to use spawnitem command within projectile hook!
avatar
ZxC

Gender : Male Posts : 11
Points : 21
Join date : 2016-02-09
Age : 18
Location : Italy

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

Back to top Go down

Re: Help with LUA Scripts

Post by Se7en on Sun Feb 21, 2016 5:50 pm

Thanks, how can you remove the effects of the flare and smoke after dropped?

This is a lottery script
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 ZxC on Sun Feb 21, 2016 6:12 pm

freeprojectile frees (removes) instantly any type of a projectile if its value type is declared inside the snippet of code. You must also incorporate a timer function within freeprojectile in "function" argument parameter. Why you should do that because it makes sense: after you dropped a smoke grenade for example, why the effect must vanish instantly? Guess the answer.

So, if we want the flare effect to disappear after 12 seconds are elapsed for example, the snippet of timer function should be like this (already added in the main snippet of code anyways).
Code:
function _projectile(id, weapon, x, y)
   if (weapon == 86) then
      local gut = math.random(1, 91)
      parse("spawnitem ".. gut .." ".. math.floor(x/32) .." ".. math.floor(y/32))
      timer(12000, "freeprojectile", gut)
   elseif (weapon == 54) then
      local flare = math.random(25, 91)
      parse("spawnitem ".. flare .." ".. math.floor(x/32) .." ".. math.floor(y/32))
      timer(12000, "freeprojectile", flare)
   elseif (weapon == 53) then
      local smoke = math.random(50, 91)
      parse("spawnitem ".. smoke .." ".. math.floor(x/32) .." ".. math.floor(y/32))
      timer(12000, "freeprojectile", smoke)
   end
end

addhook("projectile","_projectile")

12000 = 12 seconds (in ms - milliseconds). You can change the time parameter nevertheless as you wish.
avatar
ZxC

Gender : Male Posts : 11
Points : 21
Join date : 2016-02-09
Age : 18
Location : Italy

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

Back to top Go down

Re: Help with LUA Scripts

Post by gozugosu on Tue May 03, 2016 10:25 pm

Idk where to post this so im going for here.
Is there any helpfull advice how to change this  childish new mod (wepons,skins etc.)
Much love for anyone who help me.
avatar
gozugosu
Site user
Site user

Posts : 375
Points : 410
Join date : 2015-09-07
Age : 19
Location : Home

View user profile

Back to top Go down

Re: Help with LUA Scripts

Post by Zer0o on Tue May 03, 2016 10:39 pm

gozugosu wrote:Idk where to post this so im going for here.
Is there any helpfull advice how to change this  childish new mod (wepons,skins etc.)
Much love for anyone who help me.

Pretty simple fix (as long as the new update doesnt change how sprites are handled); the sprites are in \Counter-Strike 2D\gfx\player and \Counter-Strike 2D\gfx\weapons, you just have to download the old ones somewhere and replace the files. You can probably download an older version of CS2D to get em

Zer0o
Site user
Site user

Gender : Male Posts : 64
Points : 76
Join date : 2015-03-16
Location : Good ol' Germania

View user profile

Back to top Go down

Re: Help with LUA Scripts

Post by Se7en on Tue May 03, 2016 11:50 pm

open launcher.exe and select mods choose classic and go back to first tab, then create batch file and close

open the new batch file that appeared (u can create shortcut and change icon/name later)
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 gozugosu on Thu May 05, 2016 5:26 pm

Both not working but yeah...thanks anyways.
If u guys know any other solution i'l be very thankfull
avatar
gozugosu
Site user
Site user

Posts : 375
Points : 410
Join date : 2015-09-07
Age : 19
Location : Home

View user profile

Back to top Go down

Re: Help with LUA Scripts

Post by Frªncis on Fri May 20, 2016 3:21 pm

Hey guys. I want this script in hc > modules > Messaging but i don't know how to make it. I hope anyone can help me. THANKS Very Happy

Code:
addhook("say","_say")
function _say(id,txt)
     if string.sub(txt,1,6)=="!warn " then
               local p = string.sub(txt,7)
               warn_func_r(id,tonumber(p))
              return 1
     end
end

warn_func={}

function warn_func_r(id,p)
     if player(p,"exists") then
          if warn_func[p]==nil then warn_func[p]=0 end
          if warn_func[p]==0 then
               msg("\169255255255"..player(p,"name").." \169255255000WARNED ( 1 ) \169255255255"..player(id,"name"))
            parse("slap "..p.."")
               warn_func[p]=1
          elseif warn_func[p]==1 then
               msg("\169255255255"..player(p,"name").." \169255255000WARNED ( 2 ) \169255255255"..player(id,"name"))
            parse("killplayer "..p.."")
               warn_func[p]=2
           
          elseif warn_func[p]==2 then
               msg("\169255255255"..player(p,"name").." \169255255000WARNED ( 3 ) \169255255255"..player(id,"name"))
               parse("kick "..p.." 'WARNS: 3'")
               warn_func[p]=3
          end
        end
     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 Se7en on Fri May 20, 2016 3:46 pm

Francis this should be in the moderation file... Unless you want everyone to have access to it...
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 Fri May 20, 2016 3:53 pm

But this is a command, i can get it on hc.cfg that only mods and higher can use it.
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 Se7en on Fri May 20, 2016 4:45 pm

I know... it needs to be in moderation file...
Example:

Code:
hc.add_say_command("rcon", hc.moderation.rcon_command, hc.RCON_LEVEL, "<command>", "Execute an rcon command.")

in moderation.lua
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 Fri May 20, 2016 11:06 pm

ok... But i just want it in HC :/
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 Frªncis on Fri Jun 10, 2016 10:18 pm

I still need it <_<
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 Nighthawk on Fri Jun 10, 2016 11:27 pm

1. Open messaging.lua

2. Add this line in the hc.messaging.init() function
Code:
hc.add_say_command("warn", hc.messaging.warn_command, hc.MODERATOR1, "[<id>]", "Warn a player", true)

3. Add this AFTER the hc.messaging.init() function
Code:
warn_func={}

function hc.messaging.warn_command(id,p)
    if player(p,"exists") then
          if warn_func[p]==nil then warn_func[p]=0 end
          if warn_func[p]==0 then
              msg("\169255255255"..player(p,"name").." \169255255000WARNED ( 1 ) \169255255255"..player(id,"name"))
            parse("slap "..p.."")
              warn_func[p]=1
          elseif warn_func[p]==1 then
              msg("\169255255255"..player(p,"name").." \169255255000WARNED ( 2 ) \169255255255"..player(id,"name"))
            parse("killplayer "..p.."")
              warn_func[p]=2
         
          elseif warn_func[p]==2 then
              msg("\169255255255"..player(p,"name").." \169255255000WARNED ( 3 ) \169255255255"..player(id,"name"))
              parse("kick "..p.." 'WARNS: 3'")
              warn_func[p]=3
          end
        end
    end
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 Frªncis on Sat Jun 25, 2016 3:35 pm

Can you make that mods can't warn other mods or higher?
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 Sponsored content


Sponsored content


Back to top Go down

Page 2 of 2 Previous  1, 2

View previous topic View next topic Back to top


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