Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*==============================================================================
- ----------------------------De4dpOol's rappelling System------------------------
- ==============================================================================*/
- //Include(s)
- #include <a_samp>
- #include <zcmd>
- #include <line>
- //Forward(s)//
- forward FallingChecker(playerid);
- forward DeActivateRappel(playerid);
- //New(s)//
- new Float:LastZ[MAX_PLAYERS];
- new Rope[MAX_PLAYERS];
- new IsRappelling[MAX_PLAYERS];
- new LandingChecker[MAX_PLAYERS];
- new Rappel[MAX_PLAYERS];
- new Float:PlayerHealth[MAX_PLAYERS];
- //Function(s)//
- GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
- {
- new Float:a;
- GetPlayerPos(playerid, x, y, a);
- GetPlayerFacingAngle(playerid, a);
- if (GetPlayerVehicleID(playerid))
- {
- GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
- }
- x += (distance * floatsin(-a, degrees));
- y += (distance * floatcos(-a, degrees));
- }
- RappelPlayer(playerid)
- {
- new Float: Px, Float: Py, Float: Pz;
- GetPlayerPos(playerid, Px, Py, Pz);
- GetXYInFrontOfPlayer(playerid, Px, Py, 0.2);
- SetPlayerVelocity(playerid, 0.0, 0.0, -0.2);
- Rope[playerid] = CreateLineSegment(19087, 2.46, Px, Py, Pz, Px, Py, Pz - 1000.0, .RotX = 90.0, .objlengthoffset = -(2.46/2), .worldid = -1, .interiorid = -1, .playerid = -1, .maxlength = 1000.0);
- ApplyAnimation(playerid,"ped","abseil",4.0,0,0,0,1,0);
- return 1;
- }
- NotFalling(playerid)
- {
- DestroyLineSegment(Rope[playerid]);
- ClearAnimations(playerid);
- IsRappelling[playerid] = 0;
- KillTimer(LandingChecker[playerid]);
- SetPlayerHealth(playerid, PlayerHealth[playerid]);
- return 1;
- }
- //Public(s)
- public OnPlayerUpdate(playerid)
- {
- if(Rappel[playerid] == 0) return 1;
- if(GetPlayerAnimationIndex(playerid) && (IsRappelling[playerid] == 0))
- {
- new animlib[32];
- new animname[32];
- GetAnimationName(GetPlayerAnimationIndex(playerid),animlib,32,animname,32);
- if((!strcmp(animlib, "PED", true, 3)) && (!strcmp(animname, "FALL_fall", true, 9)))
- {
- RappelPlayer(playerid);
- IsRappelling[playerid] = 1;
- GetPlayerHealth(playerid, PlayerHealth[playerid]);
- SetPlayerHealth(playerid, 999999.0);
- LandingChecker[playerid] = SetTimerEx("FallingChecker",500,1,"i",playerid);
- }
- }
- return 1;
- }
- public FallingChecker(playerid)
- {
- new Float:z;
- GetPlayerPos(playerid,z,z,z);
- if(LastZ[playerid] == z)
- {
- NotFalling(playerid);
- }
- LastZ[playerid] = z;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- if(IsValidLineSegment(Rope[playerid])) DestroyLineSegment(Rope[playerid]);
- Rappel[playerid] = 0;
- IsRappelling[playerid] = 0;
- KillTimer(LandingChecker[playerid]);
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if((newkeys & KEY_JUMP) && (Rappel[playerid] == 0))
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- if((GetVehicleModel(GetPlayerVehicleID(playerid)) == 487) && (GetPlayerVehicleSeat(playerid) != 0))//If its a Marverick and player is a passenger.
- {
- RemovePlayerFromVehicle(playerid);
- }
- }
- Rappel[playerid] = 1;
- SetTimerEx("DeActivateRappel", 5000, 0, "i", playerid);
- }
- return 1;
- }
- public DeActivateRappel(playerid)
- {
- Rappel[playerid] = 0;
- return 1;
- }
- //Cmd(s)//
- CMD:test2(playerid, params[])//To activate Rappelling, press jump to start rappelling.
- {
- SetPlayerPos(playerid, 0.0, 0.0, 200.0);
- return 1;
- }
- /*==============================================================================
- ---------------------------------End of Script----------------------------------
- ==============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement