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

Join the forum, it's quick and easy

-[IFwsI]-
You need an account to view all sections/topics
-[IFwsI]-
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Help with LUA Scripts

+9
ZxC
_Yank
Nighthawk
zAzz
Soushiant.iR
Mommy123
piWi.
cracker22
alaa
13 posters

Page 2 of 2 Previous  1, 2

Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Se7en 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
Se7en
Se7en
Site user
Site user

Gender : Male Posts : 1163
Points : 1342
Join date : 2013-12-07
Age : 23
Location : Israel

http://slowpoke101.forum.st/

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by ZxC 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!
ZxC
ZxC

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

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

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Se7en 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
Se7en
Se7en
Site user
Site user

Gender : Male Posts : 1163
Points : 1342
Join date : 2013-12-07
Age : 23
Location : Israel

http://slowpoke101.forum.st/

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by ZxC 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.
ZxC
ZxC

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

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

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by gozugosu 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.
gozugosu
gozugosu
Site user
Site user

Posts : 376
Points : 413
Join date : 2015-09-07
Age : 25
Location : Home

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Zer0o 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

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Se7en 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)
Se7en
Se7en
Site user
Site user

Gender : Male Posts : 1163
Points : 1342
Join date : 2013-12-07
Age : 23
Location : Israel

http://slowpoke101.forum.st/

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by gozugosu 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
gozugosu
gozugosu
Site user
Site user

Posts : 376
Points : 413
Join date : 2015-09-07
Age : 25
Location : Home

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Frªncis 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
Frªncis
Frªncis
Site user
Site user

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

http://dr2d.omgforum.net/

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Se7en Fri May 20, 2016 3:46 pm

Francis this should be in the moderation file... Unless you want everyone to have access to it...
Se7en
Se7en
Site user
Site user

Gender : Male Posts : 1163
Points : 1342
Join date : 2013-12-07
Age : 23
Location : Israel

http://slowpoke101.forum.st/

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Frªncis 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.
Frªncis
Frªncis
Site user
Site user

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

http://dr2d.omgforum.net/

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Se7en 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
Se7en
Se7en
Site user
Site user

Gender : Male Posts : 1163
Points : 1342
Join date : 2013-12-07
Age : 23
Location : Israel

http://slowpoke101.forum.st/

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Frªncis Fri May 20, 2016 11:06 pm

ok... But i just want it in HC :/
Frªncis
Frªncis
Site user
Site user

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

http://dr2d.omgforum.net/

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Frªncis Fri Jun 10, 2016 10:18 pm

I still need it <_<
Frªncis
Frªncis
Site user
Site user

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

http://dr2d.omgforum.net/

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Nighthawk 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
Nighthawk
Nighthawk
-[IFwsI]- Co-Leader
-[IFwsI]- Co-Leader

Gender : Male Posts : 2426
Points : 2902
Join date : 2014-01-02
Age : 25
Location : Outside The Gates Of Your Mind

http://bit.ly/irfandahir

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Frªncis Sat Jun 25, 2016 3:35 pm

Can you make that mods can't warn other mods or higher?
Frªncis
Frªncis
Site user
Site user

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

http://dr2d.omgforum.net/

Back to top Go down

Help with LUA Scripts - Page 2 Empty Re: Help with LUA Scripts

Post by Sponsored content


Sponsored content


Back to top Go down

Page 2 of 2 Previous  1, 2

Back to top


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