i have for Joinning games.
rem these functoins are used to get the ip and were created by IanM
function GetLocalIP(index as integer)
local ip as string
local p as DWORD
local HOSTENT as DWORD
HOSTENT=make memory(256)
if GetHostName( HOSTENT, 256 ) = 0
HostInfo=GetHostByName( HOSTENT )
if HostInfo <> 0
p=HostInfo+12
p=*p
p=*p
p=p+(index*4)
ip=INET_ntoa( *p )
endif
endif
delete memory HOSTENT
endfunction ip
function GetHostName(memptr as DWORD, size as integer)
local r as integer
local a as DWORD
local s as DWORD
r=call dll(201, "gethostname", memptr, size)
endfunction r
function GetHostByName(memptr as DWORD)
local r as integer
r=call dll(201, "gethostbyname", memptr)
endfunction r
function INET_ntoa(addr as DWORD)
local ip as string
ip=call dll(201, "inet_ntoa", addr)
endfunction ip
function WSAStartup()
local WSADATA as DWORD
local r as integer
local v as WORD
load dll "wsock32.dll",201
WSADATA=make memory(16384)
v=2
r=call dll(201, "WSAStartup", v, WSADATA)
delete memory WSADATA
endfunction r
function WSACleanup()
call dll 201, "WSACleanup"
delete dll 201
endfunction
rem gets and stores ip this function is the one you want to use to get the ip
function getip()
if WSAStartup() = 0
yourip$ = GetLocalIP(0)
WSACleanup()
endif
endfunction yourip$
this one for the shooting.
`#######################################################################
` DarkBasic Dungeon by Hubdule
` Shows huge dungeons
` (c) by Color Arts 2002
` #######################################################################
`----------------------
`FPS Gun Movement Demo
`By Joseph Thomson
`28/01/04
`--------------------------------------------------------
`Please give credit to me if you use this code in any way
`--------------------------------------------------------
`Setup
SYNC ON
SYNC RATE 60
SET DISPLAY MODE 800,600,32
HIDE MOUSE
`Set gun holding-limb position
gunOffsetX AS FLOAT = 15.0
gunOffsetY AS FLOAT = -20.0
gunOffsetZ AS FLOAT = 20.0
`Make main player object and hide it
MAKE OBJECT CUBE 1,10
HIDE OBJECT 1
`Attach a limb and delete the mesh
MAKE MESH FROM OBJECT 1,1
ADD LIMB 1,1,1
DELETE MESH 1
`Make a weapon and attach it to the limb
MAKE OBJECT BOX 2,10,10,100
GLUE OBJECT TO LIMB 2,1,1
`Make matrix to walk on
MAKE MATRIX 1,10000,10000,100,100
`Variables
xPos AS FLOAT
zPos AS FLOAT
speed AS FLOAT = 10.0
xLook AS FLOAT
yAng AS FLOAT
lookSpeed AS FLOAT = 0.2
`The gun bobbing values
gunBobSpeed AS FLOAT = 6.0
gunBobMove AS FLOAT = 3.0
gunBobHeight AS FLOAT = 1.5
gunBobAng AS FLOAT
gunTurnAng AS FLOAT
gunLookAng AS FLOAT
mouseMovementX AS FLOAT
mouseMovementY AS FLOAT
DO
`Store mouse movement
mouseMovementX = MOUSEMOVEX()
mouseMovementY = MOUSEMOVEY()
`Control movement using trig
IF UPKEY()+DOWNKEY()+LEFTKEY()+RIGHTKEY() > 0
IF UPKEY() = 1
INC xPos,SIN(yAng)*speed
INC zPos,COS(yAng)*speed
ENDIF
IF DOWNKEY() = 1
DEC xPos,SIN(yAng)*speed
DEC zPos,COS(yAng)*speed
ENDIF
IF RIGHTKEY() = 1
INC xPos,COS(yAng)*speed
INC zPos,-SIN(yAng)*speed
ENDIF
IF LEFTKEY() = 1
DEC xPos,COS(yAng)*speed
DEC zPos,-SIN(yAng)*speed
ENDIF
`Increase gun-bobbing angle to get gun bobbing
gunBobAng = WRAPVALUE(gunBobAng+gunBobSpeed)
ELSE
`Otherwise slowly change the value to nothing to bring the gun to the centre again
gunBobAng = CURVEANGLE(0,gunBobAng,10)
ENDIF
`Control the gun swaying according to how much the player is turning
gunTurnAng = CURVEANGLE(WRAPVALUE(mouseMovementX),gunTurnAng,10)
gunLookAng = CURVEANGLE(WRAPVALUE(mouseMovementY),gunLookAng,10)
`Position the gun-holding limb and rotate it to give swaying effect
OFFSET LIMB 1,1,gunOffsetX+SIN(gunBobAng)*gunBobMove,gunOffsetY+ABS(COS(gunBobAng))*gunBobHeight,gunOffsetZ
ROTATE LIMB 1,1,gunLookAng,gunTurnAng,0
`Turn player
yAng = WRAPVALUE(yAng + mouseMovementX*lookSpeed)
xLook = WRAPVALUE(xLook + mouseMovementY*lookSpeed)
`Position player object and camera
POSITION OBJECT 1,xPos,100,zPos
ROTATE OBJECT 1,0,yAng,0
PITCH OBJECT DOWN 1,xLook
POSITION CAMERA xPos,100,zPos
ROTATE CAMERA xLook,yAng,0
SYNC
LOOP
and this one for engine
`make a simple image
ink rgb(12,135,242),0
box 0,0,40,40
for r = 1 to 250
`dot rnd(40),rnd(40),rgb(rnd(255),rnd(255),rnd(255))
next r
get image 1,0,0,40,40
`the main settings
sync on
sync rate 75
autocam off
`from here >>>>>>>>>>>>
`this is the player object
make object cube 1,15
position object 1,0,190,0
set object collision on 1
`add some graphics
fog on
fog distance 200
set ambient light 100
`make the ground
make object box 3,1400,10,1400
position object 3,0,-5,0
`check if an object exist, if not, create one and set the collision on it
for i = 50 to 150
`check
if object exist(i)=0
`make one
make object cube i,30+rnd(20)
position object i,rnd(700)-200,-10,rnd(700)-200
endif
`if it exists
if object exist(i)=1
`collision on it
set object collision on i
`graphics :P
texture object i,1
a=rnd(10)
if a=1
xrotate object i,45
endif
endif
next i
make object cube 2,15
position object 2,0,190,90
`to here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< is all optional
dim jumping(300)
dim start_y#(300)
dim jump_angle#(300)
dim jumpable(300)
dim bullet(300,50)
`main loop
do
`sync
sync
`move player
move_player_with_collision(1,0,yang#)
`get the camera angles
yang#=yang#+mousemovex()*0.3
xang#=xang#+mousemovey()*0.3
`get the player object position
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
point object 2,x#,object position y(2),z#
move_aiplayer_with_collision(2,0,object angle y(2),0.3)
`position and rotate the camera
position camera x#,y#,z#
rotate camera wrapvalue(xang#),wrapvalue(yang#),0
`loop
loop
function shoot_bullets(id,action)
if action = 1
endif
if action =0
endif
endfunction
function make_bullets(id,startobj,amount)
for bullet = 1 to amount
if object exist(bullet+startobj)=1
do
sync
print "SYNTAX ERROR"
PRINT "BULLET OBJECT ALREADY EXISTS >> FUNCTION CALL: 'make bullets'"
set cursor 0,0
loop
endif
make object cube bullet+startobj,10
bullet(id,bullet)=1
next bullet
endfunction
function move_aiplayer_with_collision(objectnr,coll,ang#,speed#)
`the angle
objectang#=wrapvalue(ang#)
`get the old positions
yz#=object position y(objectnr)
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=newxvalue(x#,objectang#,abs(sin(objectang#))*speed#)
newz#=z#
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
yhit=1
endif
endif
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=x#
newz#=newzvalue(z#,objectang#,abs(cos(objectang#))*speed#)
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
yhit=1
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if you are not jumping
if jumping(objectnr) = 0
`gravity
start_y#(objectnr) = y# - 2.0
`if you want.. and may jump
if yhit=1 and jumpable(objectnr) = 1
`set the variables right
jumping(objectnr) = 1
jump_angle#(objectnr) = 0
start_y#(objectnr) = object position y(objectnr)
jumpable(objectnr) = 0
endif
endif
`if you are jumping
if jumping(objectnr) = 1
`increse jump angle
jump_angle#(objectnr) = jump_angle#(objectnr) + 5
`if its 180, then stop jumping
if jump_angle#(objectnr) => 180 then jumping(objectnr)=0
endif
`position the object
position object objectnr,x#,start_y#(objectnr) + sin(jump_angle#(objectnr))*40.0,z#
`if hit..
if object collision(objectnr,coll)>0
`restore variables
jumping(objectnr) = 0
jump_angle#(objectnr) = 0
jumpable(objectnr) = 1
`reposition the object
position object objectnr,x#,yz#,z#
endif
yhit=0
endfunction
function move_player_with_collision(objectnr,coll,colang#)
remstart
sliding collision:
move on x
check collision
if hit.. restore x
move on z
check collision
if hit.. restore z
jump and gravity.. y
check collision
if hit.. restore y, jump = able
remend
`get the walk angle
objectang#=colang#
`get the old positions
yz#=object position y(objectnr)
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if 'w' is pressed
if keystate(17)=1
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=newxvalue(x#,objectang#,abs(sin(objectang#)))
newz#=z#
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=x#
newz#=newzvalue(z#,objectang#,abs(cos(objectang#)))
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
`the same is it with all the other directions..
if keystate(31)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+180,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+180,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
if keystate(32)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+90,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+90,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
if keystate(30)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+270,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+270,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
`old pos
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if you are not jumping
if jumping(objectnr) = 0
`gravity
start_y#(objectnr) = y# - 2.0
`if you want.. and may jump
if spacekey()=1 and jumpable(objectnr) = 1
`set the variables right
jumping(objectnr) = 1
jump_angle#(objectnr) = 0
start_y#(objectnr) = object position y(objectnr)
jumpable(objectnr) = 0
endif
endif
`if you are jumping
if jumping(objectnr) = 1
`increse jump angle
jump_angle#(objectnr) = jump_angle#(objectnr) + 2
`if its 180, then stop jumping
if jump_angle#(objectnr) => 180 then jumping(objectnr)=0
endif
`position the object
position object objectnr,x#,start_y#(objectnr) + sin(jump_angle#(objectnr))*30.0,z#
`if hit..
if object collision(objectnr,coll)>0
`restore variables
jumping(objectnr) = 0
jump_angle#(objectnr) = 0
jumpable(objectnr) = 1
`reposition the object
position object objectnr,x#,yz#,z#
endif
endfunction
how do i make it so its all one i tried and it gives me errors.