Given the lack of response so far, I thought that I'd have a go at answering this ...
The issues you are experiencing relate to the way you are testing for collisions and the fact that your world is just one object in the game. The response to collisions with the floor are different that that with the walls, but the collision detection cannot differentiate between these two things.
So one solution is to rebuild your world splitting the walls out separately into another object (and possibly the ceiling while you're at it!).
Alternatively, I think there is a "rough and ready" solution by playing with the collision detection as follows:
At the moment, you are testing for movement in three directions (x,y and z) at the same time. But the as the y-collision is with the floor after jumping, my suggestion is to test for this separately, i.e.
rem Update character in the x and z directions
position object 1,x#,oldy#,z#
yrotate object 1,a#
rem if the object hits anything, reset x# and z# accordingly
if object collision(1,0)>0
x#=oldx#
z#=oldz#
endif
rem Update character in the y direction
position object 1,x#,y#,z#
yrotate object 1,a#
rem if the object hits anything, decrease y# accordingly
if object collision(1,0)>0
playergrav#=0.0
y#=oldy#
endif
I think this code will work if you are controlling the camera synchronisation with the sync command (otherwise, you will see the object move in two steps).
Regarding the ceiling problem, the issue here is that the ceiling is part of the object and so when you collide with it, the code resets the playergrav to zero, allowing you to jump again by pressing the spacebar. I can't think of an easy solution to fix this using the existing code - all I can suggest is to split the ceiling out into another object. Again, the fundamental point is that your response to a ceiling collision is different to a wall.
Hope this helps.