SA-MP Forums Archive
[FilterScript] Repelling Script. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Repelling Script. (/showthread.php?tid=577755)



Repelling Script. - Prokill911 - 13.06.2015

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


Re: Repelling Script. - Alex Magaсa - 14.06.2015

I would like to know if there are any pictures that show how this script works...

Looks good thought according to the scripting.!


Re: Repelling Script. - Prokill911 - 14.06.2015

Quote:
Originally Posted by Alex Magaсa
View Post
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.


Re: Repelling Script. - GuyYahood1 - 14.06.2015

Very nice.


Re: Repelling Script. - Alex Magaсa - 14.06.2015

Quote:
Originally Posted by Prokill911
View Post
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.
Because i dont have my gaming laptop right now to check it. I wanted to see screenshots from ingame (how this script looks like + works)!


Re: Repelling Script. - Prokill911 - 14.06.2015

It's pretty simple..

If you're in a helicopter an use /repel
It ejects you from the helicopter placing you -5.0
Then sets your animation
Then sets Rope..


Once you use the command...
You can either wait for the timer to clear your animation (when your on the floor) -
Or you can type /stoprepelling
Which will destroy the objects ( Rope ) And clear your animation.


Re: Repelling Script. - Karan007 - 15.06.2015

Nice for your first one.


Re: Repelling Script. - Threshold - 19.06.2015

So every time I repel, I get a free health refill?


Re: Repelling Script. - Prokill911 - 19.06.2015

Quote:
Originally Posted by Threshold
View Post
So every time I repel, I get a free health refill?
Meh, I forgot about floating their original HP an setting their Original HP.


I'll edit the main post to fix it XD


Re: Repelling Script. - UltraScripter - 19.06.2015

nice