Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Hey guys.........
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

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Football Script

View previous topic View next topic Go down

Football Script

Post by Starkkz on Fri Jun 11, 2010 2:35 pm

This is a football trainer by me..
It spawn the ball in the half of the map..
Have fun Very Happy

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

View user profile

Back to top Go down

Re: Football Script

Post by Craig on Fri Jun 11, 2010 2:44 pm

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 : 26

View user profile

Back to top Go down

Re: Football Script

Post by WhiteWolf on Fri Jun 11, 2010 3:04 pm

I tested it.. Not many bugs.
avatar
WhiteWolf

Posts : 226
Rep : 12
Join date : 2010-06-11

View user profile

Back to top Go down

Re: Football Script

Post by Starkkz on Sat Jun 12, 2010 9:43 am

Yea i find a bug..
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

View user profile

Back to top Go down

Re: Football Script

Post by WhiteWolf on Mon Jun 14, 2010 9:47 am

I noticed that, but didn't really think hard about it.
avatar
WhiteWolf

Posts : 226
Rep : 12
Join date : 2010-06-11

View user profile

Back to top Go down

Re: Football Script

Post by Debt on Wed Jul 07, 2010 9:00 pm

Blazzingxx made one almost exactly like this, except it had goals. And color teams.

Debt

Posts : 10
Rep : 0
Join date : 2010-06-13

View user profile

Back to top Go down

Re: Football Script

Post by Starkkz on Wed Aug 04, 2010 8:14 pm

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

View user profile

Back to top Go down

Re: Football Script

Post by WhiteWolf on Thu Aug 05, 2010 7:17 pm

Debt wrote:Blazzingxx made one almost exactly like this, except it had goals. And color teams.

OWNED DEBT.
avatar
WhiteWolf

Posts : 226
Rep : 12
Join date : 2010-06-11

View user profile

Back to top Go down

xD

Post by Defz on Tue Aug 10, 2010 3:01 am

LooL good one

Defz

Posts : 4
Rep : 0
Join date : 2010-08-09

View user profile

Back to top Go down

Re: Football Script

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum