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 2256 257 258338 339 Next To the start

old Re: Lua Scripts/Questions/Help

Mr_God
User Off Offline

Quote
1
2
3
4
5
help me script
if player go in tiles parse he can't go in tiles water in RPG
but i don't used it @ @
help me pls
thkx :)

old Questions

sixpack
User Off Offline

Quote
Hello there Unreal Software Scripters!

I need your help for two things:

>How to make a lua script that picks a random number between 2 numbers I give. Like Pick a number from 1 to 10.

>How to make a script like:
An admin can say:
!kick 1 or !kick 2
[I know how to make the say func etc. but I don't know how to make a command that can accept a number.]
[I have to do right now:]
if(txt=="!kick 1") then
parse(command)
end
if(txt=="!kick 2") then
parse(command)
end

old Re: Lua Scripts/Questions/Help

RAVENOUS
BANNED Off Offline

Quote
@ Daknob - Try math.random() / for example: math.random(1,10) = a random number between 1 and 10.


Could someone please tell me why my gaming is crashing when I make one shot with the P228?

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
addhook("spawn","spawn_hook")
addhook("attack","att_hook")
addhook("kill","kill_hook")

------

function Array(m)
     local array = {}
     for i = 1, m do
          array[i]=0
     end
     return array
end

just_equipped = Array('sv_maxplayers')

parse("mp_damagefactor 50")

function spawn_hook(id)
	return 4
end

just_equipped = {}
function att_hook(id)
     if just_equipped[id] then
          just_equipped[id] = nil
          return
     end
     if (player(id,"weapontype") == 4) then
          parse("strip "..id.." 4")
     end
end

function kill_hook(killer)
    parse("equip "..killer.." 4")
    just_equipped[killer] = true
end

old Re: Lua Scripts/Questions/Help

CJ7
BANNED Off Offline

Quote
just_equipped = Array('sv_maxplayers')


You can't call it with a string..



just_equipped = Array(game('sv_maxplayers'))

would be better.

old Re: Lua Scripts/Questions/Help

Snake_Eater
User Off Offline

Quote
Hi all.
Can anybody explain me the timer function or give an sample like if I say !laser I have to wait 5 seconds then I get laser and 10 sec later I lose laser again.
pls don't give me something like addhook("sec.....")
I NEED TIMER Function not a second hook.
pls help

old Re: Lua Scripts/Questions/Help

TimeQuesT
User Off Offline

Quote
try this(i didn't tested)

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
lazer = {}
lazercount = {}

addhook ("say","samplesay")
function samplesay(id,txt)
if lazer[id]==nil then
lazer[id]= 1
lazercount[id] = 10
timer(1000,"samplelazercountdown",id,11)
end


end

function samplelazercountdown(id)
if lazercount[id]>0 then
lazercount[id]=lazercount[id]-1
if lazercount[id]==5 then
msg2(id,"you got laz0r!!")
parse ("equip "..id.." 45")
end
else
parse ("strip "..id.." 45")
lazercount[id]=-1
end
end

old Re: Lua Scripts/Questions/Help

Evool
User Off Offline

Quote
Evool has written
Hi, please help me
I have often asked question: How make button, which on first used - off, and second used - on?

Very sorry for my bad english


Please help!

old Re: Lua Scripts/Questions/Help

Snake_Eater
User Off Offline

Quote
EDIT:

timer(1000,"samplelazercountdown",id........--How to get in there a second parameter or a third?
edited 1×, last 11.09.10 01:24:45 pm

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
@Celil_can: They share the same object id (30), however, what makes them different one from another is the player attribute (zombie = 1, hcrab = 2, snark = 3)

@Snake_Eater: You can concatenate a whitespace and the second/third parameter you want.
Example:
timer(1000,"asd",id.." "..wpn.." "..x)

Then you will have to divide that string using the whitespaces.
Here's a function by leegao that will do that for you:
1
2
3
4
5
6
7
8
9
function string.split(text,delimiter)
	local buff = {}
	delimiter = delimiter or " "
	delimiter = "[^"..delimiter.."]+"
	for w in string.gmatch(text,delimiter) do
		table.insert(buff,w)
	end
	return buff
end

old Re: Lua Scripts/Questions/Help

Alex_Aaa789
User Off Offline

Quote
This is a part of my License Lua:
1
2
3
4
5
6
7
8
9
addhook(buildattempt,rp_build)
function rp_build(id)
if rp_license[id]==true then
return 0
elseif rp_license[id]==false then
return 1
msg2(id,""..copyright.."255000000You must to be licensed to build!@C")
end
end

It said end is excepted to close 'if'. Who know what i have to correct it?

old Re: Lua Scripts/Questions/Help

murilog
User Off Offline

Quote
Code:
addhook("leave","RPsave")
function RPsave(id)
if (player(id,"usgn") > 0) then
f = assert(io.open('sys/lua/saved/'..player(id,"usgn")..'.txt','w'))
f:write(rp_cr[id])
f:close()
msg2(id,"©000255000Jogo salvo com sucesso!@C")
else
msg2(id,"©000255000Falha ao salvar o jogo!@C")
end
rp_cr[id] = 0
end

addhook("join","RPload")
function RPload(id)
if (player(id,"usgn") > 0) then
msg2(id,'Seu U.S.G.N. ID é : '..player(id,"usgn")..'@C')
f = io.open('sys/lua/saved/'..player(id,"usgn")..'.txt','r')
if (f ~= nil) then
RPTransition(id,f)
f:close()
else
msg2(id,'Falha ao carregar seu Save!@C')
end
else
msg2(id,'Falha ao carregar seu Save!@C')
end
end

addhook("say","SaySaveLoad")
function SaySaveLoad(id,txt)
if (txt=="!save") then
if (player(id,"usgn") > 0) then
msg2(id,'Salvando U.S.G.N. : '..player(id,"usgn")..'@C')
f = assert(io.open('sys/lua/saved/'..player(id,"usgn")..'.txt','w'))
f:write(rp_cr[id])
f:close()
msg2(id,"©000255000Jogo salvo com sucesso!@C")
else
msg2(id,"©000255000Falha ao salvar o jogo!@C")
end
end
if (txt=="!load") then
if (player(id,"usgn") > 0) then
msg2(id,'Carregando U.S.G.N. : '..player(id,"usgn")..'@C')
f = io.open('sys/lua/saved/'..player(id,"usgn")..'.txt','r')
if (f ~= nil) then
RPTransition(id,f)
f:close()
else
msg2(id,'Falha ao carregar seu Save!@C')
end
else
msg2(id,'Falha ao carregar seu Save!@C')
end
end
end

function RPTransition(id,f:read("*all"))
rp_cr[id] = f
msg2(id,'Save carregado com sucesso!@C')
parse('hudtxt2 '..id..' 3 "©000000255Dinheiro : R$ '..rp_cr[id]..'" 17 430')
end

What's wrong ?

and , can make !givemoney <id> <amount> whit this script

old Re: Lua Scripts/Questions/Help

Flacko
User Off Offline

Quote
Alex_Aaa789 has written
This is a part of my License Lua:
It said end is excepted to close 'if'. Who know what i have to correct it?

Try this
1
2
3
4
5
6
7
8
9
addhook("buildattempt","rp_build")
function rp_build(id)
	if rp_license[id]==true then
		return 0
	elseif rp_license[id]==false then
		msg2(id,copyright.."©255000000You must to be licensed to build!@C")
		return 1
	end
end

old Re: Lua Scripts/Questions/Help

Alex_Aaa789
User Off Offline

Quote
Thanks it was fixed, but
Whole Lua:

Spoiler >


LUA ERROR: sys/lua/RP_Aaa789/License.lua:11: attempt to call global 'Array' (a nil value)
edited 2×, last 11.09.10 03:38:39 pm

old Re: Lua Scripts/Questions/Help

CeLiL_CaN
User Off Offline

Quote
Flacko has written
@Celil_can: They share the same object id (30), however, what makes them different one from another is the player attribute (zombie = 1, hcrab = 2, snark = 3)


How i can use this with cs2d cmd spawnobject ??

old Help

comba13
User Off Offline

Quote
Hey Guys,How to make dispenser give money until full to player?Me noob.

old Re: Lua Scripts/Questions/Help

kalis
User Off Offline

Quote
@Alex_Aaa789
i'm kalis
error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function initArray(m)
local array = {}
for i = 1, m do
array[i]=0
end
return array
end

rp_license = initArray(32,false)

addhook("buildattempt","rp_build")
function rp_build(id)
if rp_license[id]==true then
return 0
end
if rp_license[id]==false then
msg2(id,copyright.."©255000000You must to be licensed to build!@C")
return 1
end
end
To the start Previous 1 2256 257 258338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview