Forum

> > CS2D > Scripts > Help With Mod
Forums overviewCS2D overview Scripts overviewLog in to reply

English Help With Mod

No replies
To the start Previous 1 Next To the start

old Help With Mod

Precel97
User Off Offline

Quote
Can Who Help Me? I Doing Script With Classes - Edit of samples but it's only test script ...
I Want one of my class shot a fireball - undead guard
when i say um... maybe !fire
but my script have error and i don't know how to fix it

this is the one of script part

1
2
3
4
5
6
7
if (sample.classes.class[id]==2) then
addhook("say","sayfireballonlyforclassundeadguard")
function sayfireballonlyforclassundeadguard(id, txt)
     if (txt=="!fireballonlyforclassundeadguard") then
     shootFireball(id)
	end
end

This Is Other Part Of Script

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
if sample==nil then sample={} end
sample.classes={}

-----------------------
-- INITIAL SETUP     --
-----------------------
function initArray(m)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end
sample.classes.class=initArray(32)
function sample.classes.classmenu(id)
	menu(id,"Select your Class,Soldier|Armor+MG,Undead Guard|Last Of Undeads,Engineer|Wrench,Pyro|Flamethrower,Scout|Machete,Sniper|AWP")	
end


-----------------------
-- TEAM -> CLASS     --
-----------------------
addhook("team","sample.classes.team")
function sample.classes.team(id,team)
	if (team>0) then
		sample.classes.classmenu(id)
	end
end

-----------------------
-- SERVERACTION      --
-----------------------
addhook("say","saysraka")
function saysraka(id, txt)
     if (txt=="!Cmenu") then
     sample.classes.classmenu(id)
	end
end
-----------------------
-- CLASS SELECTION   --
-----------------------
addhook("menu","sample.classes.menu")
function sample.classes.menu(id,menu,sel)
	if (menu=="Select your Class") then
		if (sel>=0 and sel<=6) then
			sample.classes.class[id]=sel
			if (player(id,"health")>0) then
				msg2(id,"©255000000Your Class Will Change In Next Round Or When You Die!")
			end
		end
	end
end


-----------------------
-- SPAWN             --
-----------------------
addhook("spawn","sample.classes.spawn")
function sample.classes.spawn(id)
	-- SOLDIER
	if (sample.classes.class[id]<=1) then
		parse ("setmaxhealth "..id.." 150")
		parse ("setarmor "..id.." 202")
		parse ("speedmod "..id.." -5")
		return "40,4,51";
	end
	-- Undead
	if (sample.classes.class[id]==2) then
		parse ("setmaxhealth "..id.." 100")
		parse ("setarmor "..id.." 206")
		parse ("speedmod "..id.." 5")
		return "21,1";
	end
	-- ENGINEER
	if (sample.classes.class[id]==3) then
		parse ("setmaxhealth "..id.." 100")
		parse ("setarmor "..id.." 50")
		return "10,2,74";
	end
	-- PYRO
	if (sample.classes.class[id]==4) then
		parse ("setmaxhealth "..id.." 125")
		parse ("setarmor "..id.." 75")
		return "46,6,73";
	end
	-- SCOUT
	if (sample.classes.class[id]==5) then
		parse ("setmaxhealth "..id.." 75")
		parse ("setarmor "..id.." 0")
		parse ("speedmod "..id.." 15")
		return "5,69,54";
	end
	-- SNIPER
	if (sample.classes.class[id]==6) then
		parse ("setmaxhealth "..id.." 75")
		parse ("setarmor "..id.." 25")
		return "35,3,53";
	end
end
Yeah I know it's a edit of samples class in lua

And This Is A Fire Ball Script - Download

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
rpiconst = 180 / math.pi
imagepath = "sys/lua/fbmod/fireball.png" -- path to image
speed = 25 --speed of fireball
dmg = 100 --damage it does

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

fireball = {x = 0,y = 0,dir = 0,fid = 0,exists=0,rot = 0}
fireballs = initArray(32,fireball) -- each person can only have 1 fireball atm.

function shootFireball(id)
	if(fireballs[id].exists ~= 0) then
		freeimage(fireballs[id].fid)
	end
	fireballs[id] = {x = player(id,"x"),y = player(id,"y"),dir =toRad(player(id,"rot")),fid = 0,exists = 1,rot = player(id,"rot")}
	drawFireball(id)
end


function toRad(deg) -- from degrees to radian
	return (deg / rpiconst)
end

function collision(xpos,ypos,id)
	if((xpos > player(id,"x") - 30) and (xpos <  player(id,"x") + 30)) then
		if((ypos > player(id,"y") - 30) and (ypos <  player(id,"y") + 30)) then
			--msg("collision!")
			return true
		end
	end
	return false
end

function updateFireball(id) --update position, check for bounds
	fireballs[id].y = fireballs[id].y - (math.cos(fireballs[id].dir)*speed)
	fireballs[id].x = fireballs[id].x + (math.sin(fireballs[id].dir)*speed)

	local xpos = fireballs[id].x -- tired of typing the long thing ;P
	local ypos = fireballs[id].y -- ditto

	for i,v in ipairs(player(0,"table")) do -- collision
		if(i ~= id) then
			if(collision(xpos,ypos,i)) then
				parse("sethealth "..i.." "..(player(i,"health")-dmg))
			end
		end
	end


	if(fireballs[id].x > (map("xsize")*32) or fireballs[id].x < 0 or fireballs[id].y > (map("ysize")*32) or fireballs[id].y < 0) then --check for map boundaries
		fireballs[id].exists = 0
		freeimage(fireballs[id].fid)
	else
		imagepos(fireballs[id].fid,fireballs[id].x,fireballs[id].y,fireballs[id].rot)
	end
end

function drawFireball(id) -- draw and rotate.
	fireballs[id].fid=image(imagepath,fireballs[id].x,fireballs[id].y,1)
	imagepos(fireballs[id].fid,fireballs[id].x,fireballs[id].y,fireballs[id].rot)
end

addhook("ms100","my_ms100")
function my_ms100()
	for i,v in ipairs(fireballs) do
		if(v.exists==0) then
			return
		end
		updateFireball(i)
	end
end
Can Who Fix This and maybe add this what i want - shot fireball only for this class

Help plzz
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview