Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <fakemeta>
- #include <cs_player_models_api>
- #define PLUGIN "[ZP50] Addon: Parachute"
- #define VERSION "1.0"
- #define AUTHOR "H.RED.ZONE"
- #define _MarkPlayerParachute(%0) _bitPlayerParachute |= (1 << (%0 & 31))
- #define _ClearPlayerParachute(%0) _bitPlayerParachute &= ~(1 << (%0 & 31))
- #define _IsPlayerParachute(%0) _bitPlayerParachute & (1 << (%0 & 31))
- new const MODEL_PARACHUTE[] = "models/RZ/parachute.mdl"
- new _bitPlayerParachute
- new _ParachuteEntity[33]
- new _pCvarEnableParachute
- ,_pCvarFallSpeed
- public plugin_init() {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- _pCvarEnableParachute = register_cvar("zp_parachute_enabled", "1")
- _pCvarFallSpeed = register_cvar("zp_parachute_fallspeed", "50")
- register_event("ResetHUD", "newSpawn", "be")
- register_event("DeathMsg", "death_event", "a")
- register_forward(FM_CmdStart, "fw_Start")
- }
- public plugin_precache() {
- precache_model(MODEL_PARACHUTE)
- }
- public client_disconnect(id) {
- _ClearPlayerParachute(id)
- parachute_reset(id)
- }
- public fw_PlayerKilled(plr, attacker, shouldgib) {
- if(is_user_connected(plr)) {
- parachute_reset(plr)
- }
- }
- public newSpawn(id) {
- parachute_reset(id)
- _MarkPlayerParachute(id)
- }
- public death_event() {
- new id = read_data(2)
- parachute_reset(id)
- }
- parachute_reset(id) {
- if(_ParachuteEntity[id] > 0) {
- if (pev_valid(_ParachuteEntity[id])) {
- engfunc(EngFunc_RemoveEntity, _ParachuteEntity[id])
- }
- }
- }
- public fw_Start(id) {
- if (get_pcvar_num(_pCvarEnableParachute) == 1 ) {
- if(is_user_alive(id) && _IsPlayerParachute(id)) {
- new Float:fallspeed = get_pcvar_float(_pCvarFallSpeed) * -1.0
- new Float:frame
- new button = pev(id, pev_button)
- new oldbutton = pev(id, pev_oldbuttons)
- new flags = pev(id, pev_flags)
- if (_ParachuteEntity[id] > 0 && (flags & FL_ONGROUND)) {
- if (pev(_ParachuteEntity[id],pev_sequence) != 2) {
- set_pev(_ParachuteEntity[id], pev_sequence, 2)
- set_pev(_ParachuteEntity[id], pev_gaitsequence, 1)
- set_pev(_ParachuteEntity[id], pev_frame, 0.0)
- set_pev(_ParachuteEntity[id], pev_fuser1, 0.0)
- set_pev(_ParachuteEntity[id], pev_animtime, 0.0)
- set_pev(_ParachuteEntity[id], pev_framerate, 0.0)
- return
- }
- frame = pev(_ParachuteEntity[id],pev_fuser1) + 2.0
- set_pev(_ParachuteEntity[id],pev_fuser1,frame)
- set_pev(_ParachuteEntity[id],pev_frame,frame)
- if (frame > 254.0) {
- engfunc(EngFunc_RemoveEntity, _ParachuteEntity[id])
- _ParachuteEntity[id] = 0
- }
- }
- if (button & IN_USE) {
- new Float:velocity[3]
- pev(id, pev_velocity, velocity)
- if (velocity[2] < 0.0) {
- if(_ParachuteEntity[id] <= 0) {
- _ParachuteEntity[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
- if(_ParachuteEntity[id] > 0) {
- set_pev(_ParachuteEntity[id], pev_classname,"parachute")
- set_pev(_ParachuteEntity[id], pev_aiment, id)
- set_pev(_ParachuteEntity[id], pev_owner, id)
- set_pev(_ParachuteEntity[id], pev_movetype, MOVETYPE_FOLLOW)
- set_pev(_ParachuteEntity[id], pev_sequence, 0)
- set_pev(_ParachuteEntity[id], pev_gaitsequence, 1)
- set_pev(_ParachuteEntity[id], pev_frame, 0.0)
- set_pev(_ParachuteEntity[id], pev_fuser1, 0.0)
- cs_set_player_model(_ParachuteEntity[id], MODEL_PARACHUTE)
- }
- }
- else if (_ParachuteEntity[id] > 0) {
- set_pev(id, pev_sequence, 3)
- set_pev(id, pev_gaitsequence, 1)
- set_pev(id, pev_frame, 1.0)
- set_pev(id, pev_framerate, 1.0)
- velocity[2] = (velocity[2] + 40.0 < fallspeed) ? velocity[2] + 40.0 : fallspeed
- set_pev(id, pev_velocity, velocity)
- if (set_pev(_ParachuteEntity[id],pev_sequence) == 0) {
- frame = set_pev(_ParachuteEntity[id],pev_fuser1) + 1.0
- set_pev(_ParachuteEntity[id],pev_fuser1,frame)
- set_pev(_ParachuteEntity[id],pev_frame,frame)
- }
- if (frame > 100.0) {
- set_pev(_ParachuteEntity[id], pev_animtime, 0.0)
- set_pev(_ParachuteEntity[id], pev_framerate, 0.4)
- set_pev(_ParachuteEntity[id], pev_sequence, 1)
- set_pev(_ParachuteEntity[id], pev_gaitsequence, 1)
- set_pev(_ParachuteEntity[id], pev_frame, 0.0)
- set_pev(_ParachuteEntity[id], pev_fuser1, 0.0)
- }
- }
- }
- else if (_ParachuteEntity[id] > 0) {
- engfunc(EngFunc_RemoveEntity, _ParachuteEntity[id])
- _ParachuteEntity[id] = 0
- }
- } else if ((oldbutton & IN_USE) && _ParachuteEntity[id] > 0 ) {
- engfunc(EngFunc_RemoveEntity, _ParachuteEntity[id])
- _ParachuteEntity[id] = 0
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment