#define MAX_ROPE_HEIGHT 200.0
#define MIN_ROPE_HEIGHT 10.0
#define ROPE_LENGTH 5.0
#define ROPE_INITIAL_OFFSET 2.5
#define MAX_ROPES 25
enum RopeInfo {
RopeID[MAX_ROPES],
Float: RRX,
Float: RRY,
Float: RRZ,
};
new RopeInformation[MAX_PLAYERS][RopeInfo];
OnLeoRopeInit() {
for(new i = 0; i < MAX_PLAYERS; i++) {
for(new j = 0; j < MAX_ROPES; j++) {
RopeInformation[i][RopeID][j] = -1;
}
}
}
YCMD:rappel(playerid, params[], help) {
new Float:x, Float:y, Float:pz, Float:dist;
GetPlayerPos(playerid, x, y, pz);
new Float:z;
MapAndreas_FindZ_For2DCoord(x, y, z);
new vehicleid = GetPlayerVehicleID(playerid);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SendClientMessage(playerid, COLOR_PURPLE, "[Co-Pilot] Are you fucking crazy?, If you rappel out..The helicopter will crash!");
return 1;
}
if(GetPVarInt(playerid,"rappelling") == 1) {
SendClientMessage(playerid, X11_TOMATO_2, "You are already rappelling!");
return 1;
}
z+=10.0;
if(pz < z) {
SendClientMessage(playerid, X11_TOMATO_2,"The pilot is too low!! Get him to go higher....");
return 1;
}
if(pz > MAX_ROPE_HEIGHT) {
SendClientMessage(playerid, X11_TOMATO_2,"You don't have enough rope! Get the pilot to go lower");
return 1;
}
new Float:OriginalHealth;
GetPlayerHealth(playerid, OriginalHealth);
SetPVarFloat(playerid, "OriginalHealth", OriginalHealth);
RemovePlayerFromVehicle(playerid);
GetPlayerPos(playerid, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]);
SetPlayerPos(playerid, x, y, pz-5);
GameTextForPlayer(playerid, "~B~S.W.A.T ~R~Rappelling", 5000, 1);
SetPlayerHealth(playerid, FLOAT_INFINITY);
SetPVarInt(playerid,"rappelling",1);
ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,0);
dist = GetPlayerDistanceFromPoint(playerid, x, y, z);
new numropes = floatround(floatdiv(dist, ROPE_LENGTH), floatround_ceil);
CreateRope(playerid, numropes);
return 1;
}
CreateRope(playerid, numropes) {
new Float:Angle;
GetPlayerFacingAngle(playerid, Angle);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetTimerEx("stoprapel",6000, false,"i",playerid);
for(new i = 0; i<numropes; i++) {
RopeInformation[playerid][RopeID][i] = CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]-ROPE_INITIAL_OFFSET-(i*ROPE_LENGTH), 0, 0, Angle);
}
}
forward stoprapel(playerid);
public stoprapel(playerid) {
if(GetPVarInt(playerid,"rappelling") == 0) {
return 1;
}
OnStopRappel(playerid);
for(new i=0;i<MAX_ROPES; i++) {
if(RopeInformation[playerid][RopeID][i] == -1) return 1;
DestroyDynamicObject(RopeInformation[playerid][RopeID][i]);
RopeInformation[playerid][RopeID][i] = -1;
}
return 1;
}
YCMD:stoprapelling(playerid, params[], help) {
if(GetPVarInt(playerid,"rappelling") == 0) {
SendClientMessage(playerid, X11_TOMATO_2, "You are not rappelling!");
return 1;
}
OnStopRappel(playerid);
for(new i=0;i<MAX_ROPES; i++) {
if(RopeInformation[playerid][RopeID][i] == -1) return 1;
DestroyDynamicObject(RopeInformation[playerid][RopeID][i]);
RopeInformation[playerid][RopeID][i] = -1;
}
return 1;
}
forward OnStopRappel(playerid);
public OnStopRappel(playerid) {
new Float:OriginalHealth;
OriginalHealth = GetPVarFloat(playerid, "OriginalHealth");
SetPVarInt(playerid, "rappelling", 0);
ClearAnimations(playerid);
SetPlayerHealth(playerid, OriginalHealth);
SetPVarInt(playerid, "RepellTimer", gettime());
DeletePVar(playerid, "OriginalHP");
}
Credits too: Pottus, for helping me fix the destroying objects for the person who they were created for.
#include <file directory\repel.pwn>
OnGameModeInit() { OnLeoRopeInit(); }
MapAndreas Streamer
I would like to know if there are any pictures that show how this script works...
Looks good thought according to the scripting.! |
Sorry I don't get what you mean by screen shots.
It's pretty simple. It spawns rope objects according to the distance you are from the ground UP. It then ejects you from the vehicle settings your position an animation so it looks like your Repelling down a rope. |