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 2295 296 297338 339 Next To the start

old Re: Lua Scripts/Questions/Help

The Camo
User Off Offline

Quote
TDShuft has written
The Camo has written
try:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function get_enemy(id)
local math_id=math.random(1,32)
 -- for id=1, 32 do
     if math_id==id then
          get_enemy(id)
     else
          if player(math_id,"exists") then
               hunting[id]=math_id
               updatehud(id)
          else
               get_enemy(id)
          end
     end
     updatehud(id)
     get_new_img(id)
end
 -- end

remove lines "--"

--'
that function its to 1 player not to ALL !
"for id=1,32 do" its for all 32 players
--'
and i dont want to change that function i want to change that msg omg ..



It didn't detect ID, Idk why, try searching other functions in the script, you may have added ID=... somewhere, other then that, Idk really..

old Re: Lua Scripts/Questions/Help

EngiN33R
Moderator Off Offline

Quote
Okay, DC, thanks for an appointment.

I require assistance! I have to make a Lua data save system, I know how to do it, but this case is somehow completely different... Save system for the achievements, there are 19 of them, and I'm trying to read them from a file, it succeeds, but always reads 0 even there are 1's. What's the problem? PM me or better leave me your Skype (preferably) or MSN. Or any other IM. I'd be really grateful if you will help.

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
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
58
59
60
61
62
63
function initArray(m)
	local array={}
	for i=1,m do
		array[i]=0
	end
	return array
end



botenemy=initArray(32)
function hook_die_botai(v,ki,w,x,y)
if player(v,"bot") then
ai_respawn(v)
botenemy[v]=ki
ai_sayteam(v,"Shit.. I just got killed by "..player(ki,"name"))
end
end
target=initArray(32)
function hook_always_botai()
for b=1,32 do
if player(b,"bot") then
	if player(botenemy[b],"exists") then
			   target[b]=botenemy[b]
		ai_goto(b,player(target[b],"tilex"),player(target[b],"tiley"))
	else
		target[b]=ai_findtarget(b)
		ai_goto(b,player(target[b],"tilex"),player(target[b],"tiley"))
	end
	if ai_freeline(b,player(target[b],"x"),player(target[b],"y") then
		ai_aim(b,player(target[b],"x"),player(target[b],"y"))
		ai_iattack(b)
	end
end
end
end

function hook_kill_botai(k,v,w,x,y)
if player(k,"bot") and v==botenemy[k] then
botenemy[b]=0
end
end

secwep={1,2,3,4,5,6}
ctwep={10,11,20,21,22,24,35,36,37,39,32,33,34,40}
twep={10,11,20,22,23,24,30,37,34,35,36,38,40,31}
rprim=math.random(0,13)
rsec=math.random(0,5)
function hook_spawn_botai(i)
if player(i,"bot") then
ai_buy(i,51)
ai_buy(i,58)
if player(i,"team")==1 then
ai_buy(i,twep[rprim])
ai_selectweapon(i,twep[rpim])
ai_buy(i,secwep[rsec])
elseif player(i,"team")==2 then
ai_buy(i,ctwep[rpim])
ai_selectweapon(i,ctwep[rpim])
ai_buy(i,secwep[rsec])
end
end
end

This is my stupid attempt at lua AI bot power....
It's kinda.. not even 5% complete.
It Should have no bugs, but idk what to add.
edited 1×, last 30.10.10 06:44:40 am

old Re: Lua Scripts/Questions/Help

FlooD
GAME BANNED Off Offline

Quote
a few weeks ago, i had plans on making a more elaborate ai system... but after i saw how complicated dc's "super primitive" system is, i gave up.

maybe i should try again some time

old Re: Lua Scripts/Questions/Help

mafia_man
User Off Offline

Quote
HaRe has written
Fehuziom has written
How to in Hook Projectile change X Pixels and Y Pixels to X Tile and Y Tile ? (change pixels to tile)


/32

example

1
player(id,"x")/32

You are wrong it's :
1
x = math.floor( player( id, "x") / 32)

old Re: Lua Scripts/Questions/Help

CmDark
User Off Offline

Quote
Uh.. mafia man the original one was correct

oh and my small script isn't really ai, unless if i somehow make it a ton more complex. more of an add-on i guess.

old Re: Lua Scripts/Questions/Help

Glix
User Off Offline

Quote
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
function initArray(size,value)
     local t = {}
     for i=1, size do
          t[i] = value
     end
     return t
end

hasgasmask = initArray(32,0)
gasmaskid = initArray(32,0)

addhook("startround","_startround")
function _startround()
     for i=1,32 do --Loop thru all possible ids
          if player(i,"exists") and player(i,"team") < 3 and player(i,"team") > 0 then --If the player exists and is T or CT
               if hasgasmask[i] == 1 then --And has bought a gasmask, give him the image of it.
                    local id1=image("gfx/todesengel/gasmask.bmp",1,1,200+i)
                    imagescale(id1,1,1)
                    imageblend(id1,0)
                    imagealpha(id1,1.0)
                    gasmaskid[i] = id1
               end
          else --Else, clear the array just in case
               hasgasmask[i] = 0
               gasmaskid[i] = 0
          end
     end
end


addhook("spawn","gfx")
function gfx(id)
parse("hudtxt 0 \"©255255255Press F2 to buy or drop a gasmask\" 4 102 0")
end


addhook("die","_die")
function _die(id) --Remove gasmask from this player
    if hasgasmask[id]==1 then
		freeimage(gasmaskid[id])
		gasmaskid [id] = 0
		dropmask(id)
	end
end


addhook("serveraction","fmenus")
function fmenus(id,btn)
    if (btn==1) then
          menu(id,"Equip,Gasmask| 1000$, Drop the Gasmask")
    end
end




addhook("hit","gashit")
function gashit(id,source,weapon,hpdmg,apdmg)
     if weapon==72 then -- wenn es die waffe mit der id 72 ist // No gas dmg
          if hasgasmask[id] == 1 then
               return 1
          end
     end
end

addhook ("menu","meno")
function meno(id,menoo,sel)
     if menoo=="Equip" then
          if sel==1 then
               if(player(id,"money")>=1000) then
                    if hasgasmask[id] == 0 then
                         parse("setmoney "..id.." "..(player(id,"money")-1000))
                         local id1=image("gfx/todesengel/gasmask.bmp",1,1,200+id)
                         imagescale(id1,1,1)
                         imageblend(id1,0)
                         imagealpha(id1,1.0)
                         hasgasmask[id] = 1
                         gasmaskid[id] = id1 
                    else
                         msg2(id,"©255000000You already have a gasmask!@C")
                    end
               else
                    msg2(id,"©255000000You dont have enough money for a gasmask!@C")
               end
          elseif sel==2 then
               if hasgasmask[id]==1 then
                    freeimage(gasmaskid[id])
                    gasmaskid [id] = 0
                    dropmask(id)
                    msg2(id,"©255000000You dropped your gasmask!@C")
               else
                    msg2(id,"©255000000You dont have a gasmask!@C")
               end
          end
     end
end


maskpath="gfx/todesengel/gasmask.bmp"
maskitms={}
maskimg={}

addhook("movetile","pickup_itms")
function pickup_itms(id,tx,ty)
     for i=1,#maskitms do
          if maskitms[i]~=nil and maskitms[i].exists and hasgasmask[id]==0 and maskitms[i].x==tx and maskitms[i].y==ty then
               maskitms[i].exists=false
               refreshgfx(i,"gasmask",0)
               hasgasmask[id]=1
               parse("sv_sound2 "..id.." items/pickup.wav")
               local id1=image("gfx/todesengel/gasmask.bmp",1,1,200+id)
               imagescale(id1,1,1)
               imageblend(id1,0)
               imagealpha(id1,1.0)
               gasmaskid[id] = id1 
          end
     end
end
function refreshgfx(id,type,mode)
	local rndrot
	if type=="gasmask" then
		if mode==1 then
			if maskimg[id]==nil then
				maskimg[id]=image(maskpath,0,0,0)
			end
			rndrot=math.random(0,359)
			imagepos(maskimg[id],maskitms[id].x*32+16,maskitms[id].y*32+16,rndrot)
			imagescale(maskimg[id],0.9,0.9)
		elseif mode==0 then
			if maskimg[id]~=nil then
				freeimage(maskimg[id])
				maskimg[id]=nil
			end
		else
		print("incorrect MODE setting!")
		end
	end
end

function dropmask(id)
	local tilex,tiley
	tilex=player(id,"tilex")
	tiley=player(id,"tiley")
	hasgasmask[id] = 0
	for i=1,#maskitms+1 do
		if maskitms[i]==nil or not maskitms[i].exists then
			maskitms[i]={}
			maskitms[i].exists=1
			maskitms[i].x=tilex
			maskitms[i].y=tiley
			refreshgfx(i,"gasmask",1)
			break
		end
	end
end

ho make it like you need say !gasmask and he open a menu!


and what worng with that
1
2
3
4
5
6
addhook("say, player_say")
      function say(id, t)
     if player (..id..) say (t==!TeleAdmin) 
  then player (..id..)==tile,y1,y4
 end
end

like he neeed telepor to tiles but no work
edited 1×, last 30.10.10 01:39:38 pm

old HI OR OK

Kurumi
User Off Offline

Quote
How can i get the script when i say ok or hi like cs2dtibiarpg

old Re: Lua Scripts/Questions/Help

Loooser
User Off Offline

Quote
can someone explain this to me
freeimage(id)
in the info it sais removes an image
how can i remove a chosen image not any image?

old Re: Lua Scripts/Questions/Help

sixpack
User Off Offline

Quote
loooser has written
can someone explain this to me
freeimage(id)
in the info it sais removes an image
how can i remove a chosen image not any image?


in the (id) you give the id of the image and it removes only this image.

old Re: Lua Scripts/Questions/Help

Loooser
User Off Offline

Quote
@ knedliik what do you mean with a seeable score?
@kato999 yes example:
1
2
3
4
5
6
addhook("say","say")
function say(id,message)
if (message=="hi") then
parse("trigger triggername")
end
end
@steam-cs2d
try this
1
2
3
4
5
6
addhook("say, player_say")
function player_say(id, t)
if (t==!TeleAdmin) then 
parse("setpos "..id.." "..x.." "..y.."")
end
end

how do i know which id to use for removing a sertan image?(freeimage(id))
edited 1×, last 30.10.10 06:22:59 pm

old Re: Lua Scripts/Questions/Help

Loooser
User Off Offline

Quote
try
1
2
3
4
addhook("spawn","spawn")
function spawn(id)
parse('hudtxt2 '..id..' 0 "©000000000 CT: '..game("winrow_ct")..' T:  '..game("winrow_t")..'" 3 100 0') 
end

how do i know which id to use for removing a sertan image?(freeimage(id))
To the start Previous 1 2295 296 297338 339 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview