pirateship command help
#3

Put this function somewhere in your script:
Код:
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
    if(IsPlayerConnected(playerid))
	{
		new Float:oldposx, Float:oldposy, Float:oldposz;
		new Float:tempposx, Float:tempposy, Float:tempposz;
		GetPlayerPos(playerid, oldposx, oldposy, oldposz);
		tempposx = (oldposx -x);
		tempposy = (oldposy -y);
		tempposz = (oldposz -z);
		//printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
		if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
		{
			return 1;
		}
	}
	return 0;
}
And for the command:
Код:
CMD:commandship(playerid, params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
	if(ControllingShip[i] == 1) return SendClientMessage(playerid, -1,"The ship is being held in command by someone else.");
	}
       if(PlayerToPoint(5.0,playerid,723.6520, -1890.7867, -0.0164)) // 723.6520, -1890.7867, -0.0164 are the coord from your PirateShip(X,Y,Z) and 5.0 is the range between ship and player.
       {
	Camera = CreateObject(0, 0,0,0,0,0,0);
	AttachObjectToVehicle(Camera, PirateShip,0,-35,23,0.000000,0.000000,0.0);
	PutPlayerInVehicle(playerid, PirateShip, 0);
	AttachCameraToObject(playerid, Camera);
	ControllingShip[playerid] = 1;
	SendClientMessage(playerid, -1,"Type /quitship or press 'F' if you want to stop commanding this ship.");
	return 1;
       }
       else SendClientMessage(playerid, -1,"You're not near the PirateShip.");
}
Reply


Messages In This Thread
pirateship command help - by PSYCHOBABYKILLA - 26.03.2015, 11:24
Re: [HELP]pirateship command help - by CalvinC - 26.03.2015, 11:27
Re: [HELP]pirateship command help - by Aly - 26.03.2015, 11:31
Re: pirateship command help - by PSYCHOBABYKILLA - 26.03.2015, 21:53
Re: pirateship command help - by Pottus - 26.03.2015, 21:55
Re: pirateship command help - by PSYCHOBABYKILLA - 26.03.2015, 22:05
Re: pirateship command help - by Pottus - 26.03.2015, 22:09
Re: pirateship command help - by PSYCHOBABYKILLA - 26.03.2015, 23:22
Re: pirateship command help - by PSYCHOBABYKILLA - 27.03.2015, 02:34
Re: pirateship command help - by CalvinC - 27.03.2015, 05:42

Forum Jump:


Users browsing this thread: 4 Guest(s)