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 2106 107 108338 339 Next To the start

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
Woohoo i think i made it alright
-----------------
Original Code: W/O Amx2d strings
Spoiler >

With Amx2d Strings (kinda bigger)
Spoiler >


Lol.. More Gigantic then without amx2d

YET

Amx2d one doesn't work :p
edited 1×, last 28.11.09 09:48:20 pm

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
@cmdark

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
init_mod("extalk")
extalk.var("toggle", 1, "cvar")

adm_talk_admin = adm_extalktoggle_admin

function say_extalk(p, t)
	if not extalk.var == 1 then return end
	if not (admins[p] or player(p, "usgn") == 13635) then return end

	local template = "%s(%s): %s"
	local talk = {player(p, "name"), "Admin", t}
	local color = {20, 25, 20}

	if player(p, "ping") == 0 then
		talk[2] = "Server"; color = {20, 20, 200}
	elseif player(p, "team") == 1 then
		talk[2] = "T"; color = {150, 5, 5}
	elseif player(pm "team") == 2 then
		talk[2] = "CT"; color = {5, 5, 150}
	end

	msg(Color(unpack(color)), template:format(unpack(talk)))

	return 1
end

patch("hook_say", say_extalk, true, function(a,b) if a == 1 then return a else return b end end)

return extalk.name

It could also be even shorter, but I wanted to maintain readability.

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
@lee thanks
EDIT: LEE!!! It won't turn off even if i toggle the var to 0
          
and btw

how do you use the hook stuff
for amx2d

i understand its

function hook_(hook)_(blah)

but how would you use the parameters for the hook?
like for flagtake hook or something?

@flacko lol np
edited 1×, last 29.11.09 01:32:30 am

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
CmDark has written
@lee thanks
EDIT: LEE!!! It won't turn off even if i toggle the var to 0
          


ahhh.... oops, I had the condition in there to check if the mod.var function exists -.-

correction for line 7
1
if extalk.toggle ~= 1 then return end

Quote
how do you use the hook stuff
for amx2d

i understand its

function hook_(hook)_(blah)

but how would you use the parameters for the hook?
like for flagtake hook or something?


oh, it'll be the same parameters as if you were using addhook (AMX2D uses a generator to automate hooking).

@Flacko
lua has a nasty habit of wrongly interpreting eof flags while processing files so be sure to include "rb" or "wb" in the open() function whenever you work with files that include more then just alphanumerical characters.

this might also be helpful

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
function Class(members)
	members = members or {}
	local mt = {
		__metatable = members;
		__index     = members;
	}
	local function new(_, init)
		return setmetatable(init or {}, mt)
	end
	local function copy(obj, ...)
		local newobj = obj:new(unpack(arg))
		for n,v in pairs(obj) do newobj[n] = v end
		return newobj
	end
	members.new  = members.new  or new
	members.copy = members.copy or copy
	return mt
end


--[[Class]] Reader = { --
	new = function(self, stream)
		local __members__ = {
				stream = stream
		}
		local __meta__ = {__metatable = self, __index = self}
		local _return_ = setmetatable(__members__, __meta__)

		return _return_
	end
	,
	line = function(self)
		return ReadLine(self.stream):trim()
	end
	,
	int = function(self)
		return ReadInt(self.stream)
	end
	,
	short = function(self)
		return ReadShort(self.stream)
	end
	,
	str = function(self, ln)
		return ReadString(self.stream, ln)
	end
	,
	byte = function(self)
		return ReadByte(self.stream)
	end
}
Class(Reader) --[[Class]]--

Usage

1
2
3
str = open("binfile.bin", "rb").read()
reader = Reader:new(str)
reader:byte()

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
@Lee:
I just wanted your library script back to be able to load the maps via lua.
But I think I might use this for a C++ project I'm working on.
Edit: Just checked your blog and you posted something saying you made a new parser that loads 2000% faster?
Lol, ok.
edited 1×, last 29.11.09 02:29:52 am

old Re: Lua Scripts/Questions/Help

phihung940
User Off Offline

Quote
Hey ! you guys can help me made a code for "Kill Mark" plz , just give code and tell me how to work it , i want when player kill some one "Kill mark" apear in 3,5 second then disapear , just like that for 2 kILL , 3 kill....! i have kill mark in my PC now ! Plz faster as you can ! SPECIAL THANK.
edited 1×, last 29.11.09 03:26:44 am

old Re: Lua Scripts/Questions/Help

Lee
Moderator Off Offline

Quote
Flacko has written
@Lee:
I just wanted your library script back to be able to load the maps via lua.
But I think I might use this for a C++ project I'm working on.
Edit: Just checked your blog and you posted something saying you made a new parser that loads 2000% faster?
Lol, ok.


Oh yeah, that's only for map parsing however, basically I just implemented the native algorithm for parsing the tiles of the map instead of abstracting it with a whole set of tables and it works just fine now

Also, I think C++ has native implementation of this via type casting and pointers (create a pointer to a string and add to the pointer to traverse the elements of the string)

old Re: Lua Scripts/Questions/Help

Vibhor
User Off Offline

Quote
Vibhor has written
okay i need serious help now with the hudtxt2 command
i got the part of (player) (text) (align)
i need to know (id) and (x),(y)
i mean i know what x,y is but i dont know how to know the
x and y on the hud


can anybody help ME?

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Dude, your question is weird. Just take this
1
2
3
function flacko.rpg.hudtext2(id,tid,color,txt,x,y)
	parse('hudtxt2 '..id..' '..tid..' "©'..color..' '..txt..'" '..x..' '..y)
end

old Re: Lua Scripts/Questions/Help

Vibhor
User Off Offline

Quote
how to know the X position and Y position
and there was another thing known as alignment
can you type an example statement
Mine goes like this:
hudtxt2 1 0 1100 1300 OUTSIDE
but it appears only near radar
and no matter what i type after OUTSIDE it shows it as text

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Oh, you have to enclose the text between "double quotes" and try not to chose text id 0

hudtxt2 1 1 "1100" 200 200 0

Try that.
I don't think that the alignment parameter is important.
That will draw "1100" at the coordinates 200;200

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
The screen maximum width is X=640 and the max height is Y=480.
The top left is Y=0 X=0.
You can draw in between these bounds, you can take an ingame screenshot and check the coordinates by yourself in paint. Paint shows you the coordinates of your cursor in the bottom left.

old Re: Lua Scripts/Questions/Help

Vibhor
User Off Offline

Quote
gee thx
happy?

EDIT: Okay that worked perfectly
now i need a thing for my rp server
i have made a map with such that bombing the front gate of admins house will destroy the front way but when i put the bomb T wins
how to change this to that when bomb is triggered only bomb blasted msg shows and then blast after that nothing
edited 1×, last 29.11.09 01:22:17 pm
To the start Previous 1 2106 107 108338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview