//Pirate Ship by TonyII #include <a_samp> #include <zcmd> new PirateObject, PirateFence, PirateRopes, PirateShip; new Camera; new ControllingShip[MAX_PLAYERS]; public OnFilterScriptInit() { print("\n--------------------------------------"); print("Pirate Ship by TonyII is running"); print("--------------------------------------\n"); PirateObject = CreateObject(8493,0,0,-100,0,0,0); PirateFence = CreateObject(9159,0,0,-100,0,0,0); PirateRopes = CreateObject(8981,0,0,-100,0,0,0); PirateShip = AddStaticVehicleEx(454, 723.6520, -1890.7867, -0.0164, 180.0000, -1, -1, -1); AttachObjectToVehicle(PirateObject, PirateShip, 0.809999, 1.439998, 16.650209, 0.000000, 0.000000, 0.000000); AttachObjectToVehicle(PirateRopes, PirateShip, 0.294999, -4.665059, 16.250276, 0.000000, 0.000000, 0.000000); AttachObjectToVehicle(PirateFence, PirateShip, 0.784999, 1.439998, 16.655208, 0.000000, 0.000000, 0.000000); return 1; } public OnFilterScriptExit() { return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if (newkeys & KEY_SECONDARY_ATTACK) { if(ControllingShip[playerid] == 1) { ControllingShip[playerid] = 0; new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z); SetPlayerPos(playerid, X,Y+2,Z+6); SetCameraBehindPlayer(playerid); DestroyObject(Camera); } } return 1; } 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."); } 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; } CMD:quitship(playerid, params[]) { if(ControllingShip[playerid] == 0) return SendClientMessage(playerid, -1,"You do not command the ship."); ControllingShip[playerid] = 0; new Float:X,Float:Y,Float:Z; GetPlayerPos(playerid, X,Y,Z); SetPlayerPos(playerid, X,Y+2,Z+6); SetCameraBehindPlayer(playerid); DestroyObject(Camera); return 1; }
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; }
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."); }
Re: [HELP]pirateship command help Your last post was removed, so it probably isn't too clever to post another one about the same. But if you've tried, show your attempt and how it didn't work. |
Default Re: pirateship command help I hope your not planning on letting players surf the pirate ship it won't work as expected and just end up killing players / sending them flying. |
stock IsPlayerInRangeOfVehicle(playerid, veh, Float: range) { if( !IsPlayerConnected( playerid ) ) return 0; if( !IsValidVehicle( veh ) ) return 0; new Float: x, Float: y, Float: z ; GetVehiclePos( veh, x, y, z ); if( IsPlayerInRangeOfPoint( playerid, range, x, y, z ) ) return 1; return 0; }
IsPlayerInRangeOfVehicle(playerid, veh, Float: range)
{
if( !IsPlayerConnected( playerid ) || !IsValidVehicle( veh ) ) return 0;
new
Float: x,
Float: y,
Float: z
;
GetVehiclePos( veh, x, y, z );
return IsPlayerInRangeOfPoint(playerid, range, x, y, z);
}