PDA

View Full Version : Ship/Attachtoobj Problem...


wild8900
05-21-2008, 07:37 AM
For some reason this script attaches the player but it warps them around and weirds up the positions on other peoples clients... what am I doing wrong?
if(playertouchsme&&!playerattached){
playerx=x+7.5;
playery=y+9;
attachplayertoobj 0,id;
timeout=0.05;
}

//#CLIENTSIDE
function onCreated(){
drawunderplayer();
setshape2(18, 38, {
00,00,00,22,22,22,22,22,22,22,22,22,22,22,22,00,00 ,00,
00,00,00,22,22,00,00,00,00,00,00,00,00,22,22,00,00 ,00,
00,00,00,22,22,00,00,00,00,00,00,00,00,22,22,00,00 ,00,
00,00,22,22,22,00,00,00,00,00,00,00,00,22,22,22,00 ,00,
00,22,22,22,22,00,00,22,22,22,22,00,00,22,22,22,22 ,00,
22,22,00,22,22,22,22,22,22,22,22,00,00,22,22,00,22 ,22,
22,22,00,22,22,22,22,22,22,22,22,00,00,22,22,00,22 ,22,
22,22,00,22,22,22,22,22,22,22,22,00,00,22,22,00,22 ,22,
22,22,00,22,22,22,22,22,22,22,22,00,00,22,22,00,22 ,22,
22,22,00,22,22,22,22,22,22,22,22,00,00,22,22,00,22 ,22,
22,22,00,00,00,00,00,00,00,00,00,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,00,00,00,00,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,22,22,22,22,00,00,00,00,00,22 ,22,
00,00,00,00,00,00,00,22,22,22,22,00,00,00,00,00,00 ,00,
00,00,00,00,00,00,00,22,22,22,22,00,00,00,00,00,00 ,00,
22,22,00,00,00,00,00,22,22,22,22,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,00,00,00,00,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,00,00,00,00,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,00,00,00,00,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,00,00,00,00,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,00,00,00,00,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,00,00,00,00,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,22,22,22,22,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,22,22,22,22,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,22,22,22,22,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,22,22,22,22,00,00,00,00,00,22 ,22,
22,22,00,00,00,00,00,22,00,00,22,00,00,00,00,00,22 ,22,
22,22,22,00,00,00,00,22,00,00,22,00,00,00,00,22,22 ,22,
22,22,22,22,00,00,00,22,00,00,22,00,00,00,22,22,22 ,22,
22,22,22,22,22,00,00,00,00,00,00,00,00,22,22,22,22 ,22,
00,22,22,22,22,22,00,00,00,00,00,00,22,22,22,22,22 ,00,
00,00,22,22,22,22,22,00,00,00,00,22,00,22,22,22,00 ,00,
00,00,00,22,22,22,22,22,00,00,22,00,00,22,22,00,00 ,00,
00,00,00,00,22,22,22,22,22,22,22,22,22,22,00,00,00 ,00,
00,00,00,00,00,22,22,22,22,22,22,22,22,00,00,00,00 ,00,
00,00,00,00,00,00,22,22,22,22,22,22,00,00,00,00,00 ,00,
00,00,00,00,00,00,00,22,22,22,22,00,00,00,00,00,00 ,00,
00,00,00,00,00,00,00,00,22,22,00,00,00,00,00,00,00 ,00,
});
}
function onTimeout(){
if (keydown(6)){
detachplayer;
player.x=x-4;
player.y=y-4;
setplayerprop #c,You left the boat.;
}
setTimer(0.05);
}

Tigairius
05-21-2008, 07:39 AM
You're mixing GS1 with GS2!
setplayerprop #c,You left the boat.;
player.chat = "You left the boat.";

detachplayer;
detachplayer();

but in all honesty, I'm going to need some other details, does it only happens when it changes levels or what?

wild8900
05-21-2008, 07:45 AM
When I touch the boat it warps the player a few times then centers at the point I tell it to but for some reason other players don't see the updated position or something. I think it fixes if you update level but Im not sure.

Tigairius
05-21-2008, 07:58 AM
I think that's just one of the bugs with attachplayer, it's a bit buggy like that. Try putting attachplayertoobj before player.x/player.y changes in the serverside part of the script.

wild8900
05-21-2008, 08:15 AM
Seems to work but when I reconnect or someone else does it acts the same way...

Tigairius
05-21-2008, 08:17 AM
You might need to detach the player upon reconnection.

Ziro_of_the_Turks
05-21-2008, 07:58 PM
I wanna ride some boats that aren't on GK :(

Or hell, I wanna ride anything on any non-GK server that attaches more than 1 player to the object (that means no 1-player vehicles)

Here's the fun part- Graal is now big enough that I have to ask... Does anyone know where I can find something like this availible to play with? Any open-server with something like that? :(

Tigairius
05-21-2008, 08:04 PM
I have a floating island on N-Pulse that sometimes has up to 20 people on it.

Ziro_of_the_Turks
05-21-2008, 08:56 PM
Show me. plox.

cbk1994
05-21-2008, 10:08 PM
I made a floating elevator for Utopia ...

But yes, attach before changing x/y and deattach at login.

wild8900
05-22-2008, 07:43 AM
Do both functions have to be clientsided or serversided? It still doesnt work...
At first it looks like it works but when you reconnect it messes up the positions of others on your screen...

cbk1994
05-22-2008, 10:35 PM
I would use serverside attach. But, does this even exist? I've only used attach one time.

wild8900
05-23-2008, 05:18 AM
It is serversided... but what about detach?

cbk1994
05-23-2008, 05:30 AM
Definitely serverside or it won't update on the server.

wild8900
05-23-2008, 09:47 AM
both are serversided...

xXziroXx
05-23-2008, 01:45 PM
Here's an example on how to use attachplayer, I use it on Mythic and it works flawless. I've cut out some parts though - but should contain the information you need.


function onPlayerTouchsMe()
{
if (player.x in |x, x + 3| && player.y in |y + 3, y + 7|) {
if (!player.attached && player.dir == 3) player.attachPlayerToObj(0, id);
else if (player.attached && (player.dir == 1 || player.attached && player.dir == 2) && player.x in |x, x +1|) detachPlayer();
}

else if (player.x in |x + 20, x + 21| && player.y in |y + 3, y + 7|) {
if (!player.attached && player.dir == 1) attachPlayerToObj(0, id);
else if (player.attached && player.dir == 3) detachPlayer();
}
}

//#CLIENTSIDE
function onCreated()
{
// SET SHAPE HERE
}

Robin
05-23-2008, 03:34 PM
Thought setshape2 was for serverside?

xXziroXx
05-23-2008, 04:30 PM
Thought setshape2 was for serverside?

It work's either way. In this case, I have to have it clientside since I change the shape of the NPC depending on where the player is - and it refuses to update properly on serverside.

And since this guy is making a ship, he'll most likely want to change shape depending on the direction of the ship, thus he should do it clientsided in a timeout.

wild8900
05-27-2008, 03:09 AM
Hmm... I tried your script with my setshapes and all... at first it looked like it was working right but the same problem appeared when I reconnected.