Forum

> > CS2D > Scripts > Lua Scripts/Questions/Help
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Scripts/Questions/Help

6,770 replies
Page
To the start Previous 1 262 63 64338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
@Blazzing:
The attack hook has only got one parameter, the "wpn" parameter is an error that I forgot Dx
1
2
3
4
5
addhook("attack", "admod")
function admod(id)
local weapon=player(id,[b]"weapontype"[/b])
parse("equip "..id.." "..weapon)
end
That should work.
It doesn't matter if you make a function that expects more parameters that the ones that you pass it when you call your function in Lua (unlike C++ :()

old Re: Lua Scripts/Questions/Help

starkzzz
COMMUNITY BANNED Off Offline

Quote
hmm... then this is the problem, jeje
read this

leegao writen this
________________________________________________

try just using

parse("equip "..id.." "..weapon)

the function parameter 'wpn' is correct since it's not used by the code and merely functions as an auxiliary variable.
________________________________________________

Thanks For Help Flacko

Now Can see My lua on http://www.starkcs2d.es.tl/

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
And I maintain that everything that I have posted on the previous post is completely valid given that the wpn parameter is auxiliary and doing one equip is logically correct.

However if you're going to point out the flaws from and trying to discredit help that you are receiving, then I wouldn't expect you to receive much or any help from me from the future.

old Re: Lua Scripts/Questions/Help

saladface27
User Off Offline

Quote
whats wrong with this 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
def=0
atk=0
cap_ratio=1
for i=1,32 do
	playerx[i]=tonumber(player(i,"tilex"))
	playery[i]=tonumber(player(i,"tiley"))
	if(playerx[i]-flag[0]<=cap_dist and playerx[i]-flag[1]<=cap_dist) then
		if(player(i,"team")==defteam) then
			def=def+1
			else
			atk=atk+1
			end
		end
	end
if(def>0)then
	cap_ratio=def/atk
else
	cap_ratio=atk
	end
if(atk>0)then
	cap_time2=cap_time2-mintimeps
else
	captime2=captime2+retimeps
	end
if(captime2<0)then 
	captime2=0 
	end
captime=cap_base/cap_ratio
captime_final=captime-captime2

error is "attempt to perform arithmetic on field '?' (a nil value)"

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
saladface, you probably are using a variable before declaring it.
Maybe, playerx or playery? or flag? or cap dist? or def_team?

old Re: Lua Scripts/Questions/Help

Heartless Soldier
User Off Offline

Quote
I have a little question :P.

Can u change an entity settings with a lua script? for example i want to change the X offset of an image, is it possible?

tank u if u answer me :D.



sorry for my english im from Argentina xD.

good luck for all!

old Re: Lua Scripts/Questions/Help

Vibhor
User Off Offline

Quote
my server keeps crashing
i dont know why?
plz help

EDIT:NP i got it
it was because of the no reload script
edited 1×, last 07.10.09 06:31:52 am

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Vibhor has written
NP i got it
it was because of the no reload script

You see, no reload with attack hook sucks, becouse its called each time you shot.

There is way to make it with relead hook.

And on crashes you havent get nothing on debug mode?

old Re: Lua Scripts/Questions/Help

playa slaya
COMMUNITY BANNED Off Offline

Quote
I do not see point in reload scripts unless you were making it only for admin since you can already have unlimited ammo with sv_infoammo 1

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Vibhor has written
I thought the script would be like the punisher hero in blazzinx's super hero mod
so i needed it

Example of SuperHero no reload idea.

1
2
3
4
addhook('reload','no_reload')
function no_reload(p,m)
		if (m == 1) then parse('equip '..p..' '..player(p,"weapontype")); end
end

old Server Time Constantly

Toa Hero 92
User Off Offline

Quote
Hello, Forum Wizards, It is I, ToaHero92, here yet again with a request for the use of the all encompassing knowledge of lua scripting that only you can provide.

Here is my question Great Ones:

I would like a script that will constantly display display the server time in the upper right corner of the screen... or if that is not possible to make it pop up with the server time every minute like advertising.

old Server Time Constantly

Toa Hero 92
User Off Offline

Quote
Never Mind I was Able to put it into the advertise script....


...... On a Different note I Made This Script

1
2
3
4
5
6
addhook("spray","spraytxty")
function spraytxty(id)

parse("msg ©017213149 "..player(id,"name").." put a spray at "..player(id,"tilex").." "..player(id,"tiley").." !")

end

I tested it and in debug it said this

LUA ERROR: attempt to call a nil value

What is Wrong?

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Spray hook didnt work properly on current CS2D version.

Btw, you cant use this way:
parse('msg"
There is no commands like "msg" , but only "sv_msg"
However you can use
1
msg(txt)

old Re: Lua Scripts/Questions/Help

SQ
Moderator Off Offline

Quote
Toa Hero 92 has written
Is there an alternative?


Say what you exacly wanna to make.
I will answer If its posible.

old Exactly

Toa Hero 92
User Off Offline

Quote
What I want is a way to get the position of a player to be displayed on demand... I have tried this script that leeago made me

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
54
55
56
57
addhook("say", "position_say")

--Admin Usgn Id List--
admins = {}
admins[15345] = true
--keep listing the admins in this pattern

--String.Split - splits a string into a table based on spaces or other delimiters.
function string.split(t, b)
     local cmd = {}
     local match = "[^%s]+"
     if b then
          match = "%w+"
     end
     if type(b) == "string" then match = "[^"..b.."]+" end
     if not t then return invalid() end
     for word in string.gmatch(t, match) do
          table.insert(cmd, word)
     end
     return cmd
end

--Resolves USGN to the current game's Player IDs, if not found, returns nil
function resolve_usgn(usgn)
     if usgn < 1 then return end
     for i=1,32 do
          if player(i, 'usgn') == usgn then return i
     end
end
end
--Finds the location of the player at id and msg2's it to the player at orig
function get_position(id, orig)
     if id < 1 then return end
     local msg = "sv_msg2 %s The player is at %s %s in pixels and %s %s in tiles"
     parse(msg:format(orig, player(id, 'x'), player(id, 'y'), player(id, 'tilex'), player(id, 'tiley')))
end

--Broadcasts the position of the other_player to all of the admins
function broadcast_admins(other_player)
     for admin in pairs(admins) do
          local id = resolve_usgn(admin)
          if id then get_position(other_player, id) end
     end
end

--Say hook
function position_say(id, text)
     if not admins[player(id, 'usgn')] then return end

     local cmd = text:split()
     if cmd[1] == "!position" then
          local _id_ = tonumber(cmd[2])
          if not _id_ then return end
          broadcast_admins(_id_)
          return 1
     end
end

But it doesn't work... (pls try it your self to see, just put your usgnidnum in the list in the place of 15435,...can you see if you can fix it?)

Then I Tried....

1
2
3
4
5
6
addhook("spray","spraytxty")
function spraytxty(id)

parse("sv_msg ©017213149 "..player(id,"name").." put a spray at "..player(id,"tilex").." "..player(id,"tiley").." !")

end

But it doesn't work either apparently.
And don't reference me to the AMX2D script because I can't get it to work and I don't want a complete modification anyway.

So please Help me if you can...

Thank You.



I put all scripts I make in the Sayfunctions Script


FYI I don't check back often
To the start Previous 1 262 63 64338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview