Kirko |
12-23-2015 01:33 PM |
Mount
So I've been working on a 2 person mount script but having trouble with the passenger sticking to the driver. When the driver is inbetween two levels on a gmap the passenger will begin warping all over the place and when I enter a new level, the passenger will stay in previous level. I was lucky to get some help by a few individuals and fix some of my crappy scripting but I still can't seem to fix these problems.
Here is the portion that involves the passenger.
PHP Code:
function onActionServerSide(cmd){
switch(cmd){
case "unFollow":
temp.pl = findplayer(params[1]);
temp.pl.clientr.passenger_driver = null;
temp.pl.clientr.driver = null;
clientr.passenger_driver = null;
clientr.driver = null;
break;
case "warpPlayer":
temp.pl = findplayer(player.clientr.driver);
player.setlevel2(temp.pl.level.name, player.x, player.x);
break;
}
}
//#CLIENTSIDE
function onCreated(){
hideInviteIcon();
if(clientr.passenger_driver != null || clientr.driver != null)
onLeave();
}
function onActionClientSide(temp.cmd){
switch(cmd){
case "follow":
this.following = findplayer(clientr.driver);
onTimeOut();
break;
case "unFollow":
onLeave();
break;
default:
break;
}
}
function onTimeOut(){
temp.pl = findplayer(clientr.driver);
if(temp.pl == null) return onLeave();
if(clientr.driver != null){
moveToDriver();
setTimer(0.05);
}else{
onLeave();
}
}
function moveToDriver(){
temp.driverAccount = findPlayer(clientr.driver);
player.dir = temp.driverAccount.dir;
if(player.level.name != temp.driverAccount.level.name){
if(!(this.lastUsed > timevar2 )) {
triggerserver("weapon", this.name, "warpPlayer");
player.chat = "forcewarp";
this.lastUsed= timevar2 + 5;
}
}
player.x = temp.driverAccount.x - vecx(temp.driverAccount.dir) * 2;
player.y = temp.driverAccount.y - vecy(temp.driverAccount.dir) * 2;
}
function onLeave(){
temp.driverAccount = findPlayer(clientr.driver);
player.x = temp.driverAccount.x;
player.y = temp.driverAccount.y;
this.timeout = 0;
if(clientr.driver != null)
triggerserver("gui", this.name, "unFollow", this.following);
else
triggerserver("gui", this.name, "unFollow", passenger_driver);
this.following = null;
}
function GraalControl.onKeyDown(temp.keycode, temp.keystring, temp.scancode) {
switch (temp.keycode) {
case VK_A:
if(clientr.driver != null)
onLeave();
break;
}
}
|