26.03.2015, 11:31
Put this function somewhere in your script:
And for the command:
Код:
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."); }