Similar topics
Search
Latest topics
Football Script
5 posters
Monolith Forums :: Scripting :: Scripts
Page 1 of 1
Football Script
This is a football trainer by me..
It spawn the ball in the half of the map..
Have fun
It spawn the ball in the half of the map..
Have fun
- Spoiler:
-- Football Script
-- Author: Starkkz
-- Version 1.0
fb = {ball = {}}
function array(s,v)
local a = {}
for i = 1, s do
a[i] = v
end
return a
end
fb.ball.imgdir = "gfx/!SDK/ball.png"
fb.ball.x = map("xsize")*16
fb.ball.y = map("ysize")*16
fb.ball.speed = 0
fb.ball.rot = 0
fb.ball.addrot = 0
fb.ball.img = image(fb.ball.imgdir,0,1,0)
fb.ball.kickspeed = {[false] = 0,[true] = 4.5}
fb.ball.kickmode = array(32,false)
imagescale(fb.ball.img,0.15,0.15)
imagepos(fb.ball.img,fb.ball.x,fb.ball.y,0)
addhook("startround","fb.start")
function fb.start()
fb.ball.x = map("xsize")*16
fb.ball.y = map("ysize")*16
fb.ball.speed = 0
fb.ball.rot = 0
fb.ball.addrot = 0
for i = 1, 32 do
fb.ball.kickmode[i] = false
end
fb.ball.img = image(fb.ball.imgdir,0,1,0)
imagescale(fb.ball.img,0.15,0.15)
imagepos(fb.ball.img,fb.ball.x,fb.ball.y,0)
end
function fb.ball.effect(r)
fb.ball.addrot = fb.ball.addrot + r
imagepos(fb.ball.img,fb.ball.x,fb.ball.y,fb.ball.rot+fb.ball.addrot)
end
addhook("use","fb.use")
function fb.use(id,e)
if e == 0 then
if fb.ball.kickmode[id] == true then
fb.ball.kickmode[id] = false
elseif fb.ball.kickmode[id] == false then
fb.ball.kickmode[id] = true
end
end
end
addhook("always","fb.always")
function fb.always()
for _, id in pairs(player(0,"table")) do
if player(id,"health") > 0 then
local dist = math.sqrt((player(id,"x")-fb.ball.x)^2 + (player(id,"y")-fb.ball.y)^2)
local ang
if dist < 20 then
ang = math.atan2(player(id,"y")-fb.ball.y,player(id,"x")-fb.ball.x) + math.pi/2
fb.ball.rot = math.deg(ang)
fb.ball.speed = 3.5 + fb.ball.kickspeed[fb.ball.kickmode[id]]
else
ang = math.rad(fb.ball.rot)
end
local xt,yt = fb.ball.x - math.sin(ang)*fb.ball.speed, fb.ball.y + math.cos(ang)*fb.ball.speed
if xt <= 160 then
fb.ball.x = fb.ball.x + 1
fb.ball.effect(0)
return
end
if xt >= (map("xsize")-5)*32 then
fb.ball.x = fb.ball.x - 1
fb.ball.effect(0)
return
end
if yt >= (map("ysize")-4)*32 then
fb.ball.y = fb.ball.y - 1
fb.ball.effect(0)
return
end
if yt <= 128 then
fb.ball.y = fb.ball.y + 1
fb.ball.effect(0)
return
end
if tile(math.floor(xt/32),math.floor(yt/32),"walkable") == false then
fb.ball.rot = -fb.ball.rot
ang = math.rad(fb.ball.rot)
end
if fb.ball.speed > 0 then
fb.ball.x = fb.ball.x - math.sin(ang) * fb.ball.speed
fb.ball.y = fb.ball.y + math.cos(ang) * fb.ball.speed
fb.ball.speed = fb.ball.speed - 0.1
fb.ball.effect(4)
end
end
end
end
Starkkz- Posts : 30
Rep : 0
Join date : 2010-06-11
Re: Football Script
Very well done, I can ell already you'll be a massive credit to Monolith.
Craig- Posts : 57
Rep : 0
Join date : 2010-06-07
Age : 33
Re: Football Script
Yea i find a bug..
if in the server are more players the ball go more fast..
Fixed..
if in the server are more players the ball go more fast..
Fixed..
- Spoiler:
-- Football Script
-- Author: Starkkz
-- Version 1.0
fb = {ball = {}}
function array(s,v)
local a = {}
for i = 1, s do
a[i] = v
end
return a
end
fb.ball.imgdir = "gfx/!SDK/ball.png" -- Directory of the image
fb.ball.x = map("xsize")*16
fb.ball.y = map("ysize")*16
fb.ball.speed = 0
fb.ball.rot = 0
fb.ball.addrot = 0
fb.ball.img = image(fb.ball.imgdir,0,1,0)
fb.ball.kickspeed = {[false] = 0,[true] = 4.5}
fb.ball.kickmode = array(32,false)
imagescale(fb.ball.img,0.15,0.15)
imagepos(fb.ball.img,fb.ball.x,fb.ball.y,0)
addhook("startround","fb.start")
function fb.start()
fb.ball.x = map("xsize")*16
fb.ball.y = map("ysize")*16
fb.ball.speed = 0
fb.ball.rot = 0
fb.ball.addrot = 0
for i = 1, 32 do
fb.ball.kickmode[i] = false
end
fb.ball.img = image(fb.ball.imgdir,0,1,0)
imagescale(fb.ball.img,0.15,0.15)
imagepos(fb.ball.img,fb.ball.x,fb.ball.y,0)
end
function fb.ball.effect(r)
fb.ball.addrot = fb.ball.addrot + r
imagepos(fb.ball.img,fb.ball.x,fb.ball.y,fb.ball.rot+fb.ball.addrot)
end
addhook("use","fb.use")
function fb.use(id,e)
if e == 0 then
if fb.ball.kickmode[id] == true then
fb.ball.kickmode[id] = false
elseif fb.ball.kickmode[id] == false then
fb.ball.kickmode[id] = true
end
end
end
addhook("always","fb.always")
function fb.always()
local ang
for _, id in pairs(player(0,"table")) do
if player(id,"health") > 0 then
local dist = math.sqrt((player(id,"x")-fb.ball.x)^2 + (player(id,"y")-fb.ball.y)^2)
if dist < 20 then
ang = math.atan2(player(id,"y")-fb.ball.y,player(id,"x")-fb.ball.x) + math.pi/2
fb.ball.rot = math.deg(ang)
fb.ball.speed = 3.5 + fb.ball.kickspeed[fb.ball.kickmode[id]]
else
ang = math.rad(fb.ball.rot)
end
end
end
if ang then
xt = fb.ball.x - math.sin(ang) * fb.ball.speed
yt = fb.ball.y + math.cos(ang) * fb.ball.speed
if xt <= 160 then
fb.ball.x = fb.ball.x + 1
fb.ball.effect(0)
return
end
if xt >= (map("xsize")-5)*32 then
fb.ball.x = fb.ball.x - 1
fb.ball.effect(0)
return
end
if yt >= (map("ysize")-4)*32 then
fb.ball.y = fb.ball.y - 1
fb.ball.effect(0)
return
end
if yt <= 128 then
fb.ball.y = fb.ball.y + 1
fb.ball.effect(0)
return
end
if tile(math.floor(xt/32),math.floor(yt/32),"walkable") == false then
fb.ball.rot = -fb.ball.rot
ang = math.rad(fb.ball.rot)
end
if fb.ball.speed > 0 then
fb.ball.x = fb.ball.x - math.sin(ang) * fb.ball.speed
fb.ball.y = fb.ball.y + math.cos(ang) * fb.ball.speed
fb.ball.speed = fb.ball.speed - 0.1
fb.ball.effect(4)
end
end
end
Starkkz- Posts : 30
Rep : 0
Join date : 2010-06-11
Re: Football Script
I noticed that, but didn't really think hard about it.
WhiteWolf- Posts : 226
Rep : 12
Join date : 2010-06-11
Re: Football Script
Blazzingxx made one almost exactly like this, except it had goals. And color teams.
Debt- Posts : 10
Rep : 0
Join date : 2010-06-13
Re: Football Script
Don't talk me about "Blazzingxx" he's my enemy.. thanks him i lost my scripts.
Starkkz- Posts : 30
Rep : 0
Join date : 2010-06-11
Re: Football Script
Debt wrote:Blazzingxx made one almost exactly like this, except it had goals. And color teams.
OWNED DEBT.
WhiteWolf- Posts : 226
Rep : 12
Join date : 2010-06-11
Monolith Forums :: Scripting :: Scripts
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Fri Sep 09, 2011 4:58 pm by WhiteWolf
» Last to post wins
Fri Sep 09, 2011 4:57 pm by WhiteWolf
» COMBAT ARMS WOOOOO
Tue Oct 19, 2010 10:59 pm by viperjake31
» Its over (Bye)
Wed Sep 22, 2010 10:05 pm by Supanooba
» Sorry guys...
Wed Sep 22, 2010 10:01 pm by Supanooba
» bad feeling...
Tue Sep 21, 2010 1:16 pm by Supanooba
» This game...
Sun Sep 19, 2010 10:01 am by Supanooba
» Me, D@rk T3mpl4r, Hacking?
Sun Sep 19, 2010 12:36 am by D@rk T3mpl4r
» fractured my arm and leg
Sat Sep 18, 2010 9:08 pm by Supanooba