[FilterScript] Repelling Script.
#1

PHP Code:
#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],
    
FloatRRX,
    
FloatRRY,
    
FloatRRZ,
};
new 
RopeInformation[MAX_PLAYERS][RopeInfo];
OnLeoRopeInit() {
    for(new 
0MAX_PLAYERSi++) { 
        for(new 
0MAX_ROPESj++) {
            
RopeInformation[i][RopeID][j] = -1;
        }
    }
}
YCMD:rappel(playeridparams[], help) {
    new 
Float:xFloat:yFloat:pzFloat:dist;    
    
GetPlayerPos(playeridxypz);
    new 
Float:z;
    
MapAndreas_FindZ_For2DCoord(xyz);    
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
        
SendClientMessage(playeridCOLOR_PURPLE"[Co-Pilot] Are you fucking crazy?, If you rappel out..The helicopter will crash!");
        return 
1;
    }
    if(
GetPVarInt(playerid,"rappelling") == 1) {
        
SendClientMessage(playeridX11_TOMATO_2"You are already rappelling!");
        return 
1;
    }
    
z+=10.0;
    if(
pz z) {
        
SendClientMessage(playeridX11_TOMATO_2,"The pilot is too low!! Get him to go higher....");
        return 
1;
    }    
    if(
pz MAX_ROPE_HEIGHT) {
        
SendClientMessage(playeridX11_TOMATO_2,"You don't have enough rope! Get the pilot to go lower");
        return 
1;
    }
    new 
Float:OriginalHealth;
    
GetPlayerHealth(playeridOriginalHealth); 
    
SetPVarFloat(playerid"OriginalHealth"OriginalHealth);  
    
RemovePlayerFromVehicle(playerid);
    
GetPlayerPos(playeridRopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]);
    
SetPlayerPos(playeridxypz-5);    
    
GameTextForPlayer(playerid"~B~S.W.A.T ~R~Rappelling"50001);
    
SetPlayerHealth(playeridFLOAT_INFINITY);
    
SetPVarInt(playerid,"rappelling",1);
    
ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,0);
    
dist GetPlayerDistanceFromPoint(playeridxyz);    
    new 
numropes floatround(floatdiv(distROPE_LENGTH), floatround_ceil);
    
CreateRope(playeridnumropes);
    return 
1;
}
CreateRope(playeridnumropes) {
    new 
Float:Angle;
    
GetPlayerFacingAngle(playeridAngle);
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(playeridxyz);
    
SetTimerEx("stoprapel",6000false,"i",playerid);
    for(new 
0i<numropesi++) {
        
RopeInformation[playerid][RopeID][i] = CreateDynamicObject(19089RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]-ROPE_INITIAL_OFFSET-(i*ROPE_LENGTH), 00Angle);
    }
}
forward stoprapel(playerid);
public 
stoprapel(playerid) {
    if(
GetPVarInt(playerid,"rappelling") == 0) {
        return 
1;
    }
    
OnStopRappel(playerid);
    for(new 
i=0;i<MAX_ROPESi++) {
        if(
RopeInformation[playerid][RopeID][i] == -1) return 1;
        
DestroyDynamicObject(RopeInformation[playerid][RopeID][i]);
        
RopeInformation[playerid][RopeID][i] = -1;
    }
    return 
1;
}
YCMD:stoprapelling(playeridparams[], help) {
    if(
GetPVarInt(playerid,"rappelling") == 0) {
        
SendClientMessage(playeridX11_TOMATO_2"You are not rappelling!");
        return 
1;
    }
    
OnStopRappel(playerid);
    for(new 
i=0;i<MAX_ROPESi++) {
        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(playeridOriginalHealth);
    
SetPVarInt(playerid"RepellTimer"gettime());
    
DeletePVar(playerid"OriginalHP");

Code:
Credits too: Pottus, for helping me fix the destroying objects for the person who they were created for.
So what we have here is simply a script for people being able to repel out of a helicopter.

Install:
Basically, Copy this to your gamemode or your include file
In your main gamemode
IF YOU'RE MAKING THIS IT'S OWN FILE.
Code:
#include <file directory\repel.pwn>
Code:
OnGameModeInit() {
   OnLeoRopeInit();
}
compile an run.. Done..

PLEASE NOTE YOU NEED THE FOLLOWING PLUGINS

Code:
MapAndreas
Streamer
My first release, Hope it doesn't look too crap..

Comments welcome..
There's no bugs that I can see or find

EDIT: Fixed so it sets back to their original HP
Reply


Messages In This Thread
Repelling Script. - by Prokill911 - 13.06.2015, 22:12
Re: Repelling Script. - by Alex Magaсa - 14.06.2015, 12:40
Re: Repelling Script. - by Prokill911 - 14.06.2015, 12:47
Re: Repelling Script. - by GuyYahood1 - 14.06.2015, 14:53
Re: Repelling Script. - by Alex Magaсa - 14.06.2015, 15:56
Re: Repelling Script. - by Prokill911 - 14.06.2015, 20:42
Re: Repelling Script. - by Karan007 - 15.06.2015, 15:51
Re: Repelling Script. - by Threshold - 19.06.2015, 10:08
Re: Repelling Script. - by Prokill911 - 19.06.2015, 19:20
Re: Repelling Script. - by UltraScripter - 19.06.2015, 19:58

Forum Jump:


Users browsing this thread: 1 Guest(s)