Page 1 of 1

Ajutor plugin

Posted: 24 May 2018, 11:45
by aware's
| Afiseaza codul
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>

#define _PLUGIN         "AMXX Parachute"
#define _VERSION             "1.0"
#define _AUTHOR           "H.RED.ZONE"

#define MAX_PLAYERS    32

#define MarkUserHasParachute(%0)	g_bitHasParachute |= (1<<(%0&31))
#define ClearUserHasParachute(%0)	g_bitHasParachute &= ~(1<<(%0&31))
#define HasUserParachute(%0)		g_bitHasParachute & (1<<(%0&31))

new g_bitHasParachute 

new const fail_maps[][] =
{
	"35hp",
	"1hp",
	"knife_"
}

new g_iUserParachute[MAX_PLAYERS+1]

new Float:g_flEntityFrame[MAX_PLAYERS+1]

new g_pCvarFallSpeed

new const PARACHUTE_CLASS[] = "parachute"

enum {
	deploy,
	idle,
	detach
}

public plugin_init() {
	register_plugin(_PLUGIN, _VERSION, _AUTHOR)

	g_pCvarFallSpeed = register_cvar("parachute_fallspeed", "100")

	register_forward( FM_CmdStart, "fw_Start" )
	
	RegisterHam(Ham_Spawn, "player", "Ham_CBasePlayer_Spawn_Post", 1)
	RegisterHam(Ham_Killed, "player", "Ham_CBasePlayer_Killed_Post", 1)
}

public client_putinserver(id) {
	if( HasUserParachute(id) ) {
		new iEnt = g_iUserParachute[id]
		if( iEnt ) {
			RemoveUserParachute(id, iEnt)
		}
		ClearUserHasParachute(id)
	}
}

public client_disconnect(id) {
	if( HasUserParachute(id) ) {
		new iEnt = g_iUserParachute[id]
		if( iEnt ) {
			RemoveUserParachute(id, iEnt)
		}
		ClearUserHasParachute(id)
	}
}

public Ham_CBasePlayer_Killed_Post( id ) {
	if( HasUserParachute(id) ) {
		new iEnt = g_iUserParachute[id]
		if( iEnt ) {
			RemoveUserParachute(id, iEnt)
		}
		ClearUserHasParachute(id)
	}
}

public Ham_CBasePlayer_Spawn_Post(id) {
	if( is_user_alive(id) ) {
		if( HasUserParachute(id) ) {
			new iEnt = g_iUserParachute[id]
			if( iEnt ) {
				RemoveUserParachute(id, iEnt)
			}
		}
		MarkUserHasParachute(id)
	}
}

RemoveUserParachute(id, iEnt) {
	engfunc(EngFunc_RemoveEntity, iEnt)
	g_iUserParachute[id] = 0
}

CreateParachute(id) {
	static iszInfoTarget
	if( !iszInfoTarget ) {
		iszInfoTarget = engfunc(EngFunc_AllocString, "info_target")
	}

	new iEnt = engfunc(EngFunc_CreateNamedEntity, iszInfoTarget)
	if( iEnt > 0) {
		static iszClass = 0
		if( !iszClass ) {
			iszClass = engfunc(EngFunc_AllocString, PARACHUTE_CLASS)
		}
		set_pev_string(iEnt, pev_classname, iszClass)
		set_pev(iEnt, pev_aiment, id)
		set_pev(iEnt, pev_owner, id)
		set_pev(iEnt, pev_movetype, MOVETYPE_FOLLOW)

		set_pev(iEnt, pev_sequence, deploy)
		set_pev(iEnt, pev_gaitsequence, 1)
		set_pev(iEnt, pev_frame, 0.0)
		g_flEntityFrame[id] = 0.0
		g_iUserParachute[id] = iEnt
		MarkUserHasParachute(id)
		new Float:fVecOrigin[3]
		pev(id, pev_origin, fVecOrigin)
		
		return iEnt
	}
	return 0
}

{
	new map[128];
	get_mapname(map, charsmax(map));
	for(new i = 0; i < sizeof fail_maps; i++)
	{
		if(contain(map, fail_maps))
		{
			formatex(map, charsmax(map), "Harta %s nu suporta acest plugin!", map);
			set_fail_state(map);
			break;
		}
	}
}

public fw_Start(id) {
	if( ~HasUserParachute(id) || !is_user_alive(id) ) {
		return
	}

	new Float:flFrame
	new iEnt = g_iUserParachute[id]

	if(iEnt > 0 && pev(id, pev_flags) & FL_ONGROUND) {

		if( pev(iEnt, pev_sequence) != detach ) {
			set_pev(iEnt, pev_sequence, detach)
			set_pev(iEnt, pev_gaitsequence, 1)
			set_pev(iEnt, pev_frame, 0.0)
			g_flEntityFrame[id] = 0.0
			set_pev(iEnt, pev_animtime, 0.0)
			set_pev(iEnt, pev_framerate, 0.0)
			return
		}

		pev(iEnt, pev_frame, flFrame)
		if( flFrame > 252.0 ) {
			RemoveUserParachute(id, iEnt)
			return
		}

		flFrame += 2.0

		g_flEntityFrame[id] = flFrame
		set_pev(iEnt, pev_frame, flFrame)

		return
	}

	if( pev(id, pev_button) & IN_USE ) {
		new Float:fVecVelocity[3], Float:fVelocity_z
		pev(id, pev_velocity, fVecVelocity)
		fVelocity_z = fVecVelocity[2]

		if( fVelocity_z < 0.0 ) {
			if(iEnt <= 0) {
				iEnt = CreateParachute(id)
			}

			fVelocity_z = floatmin(fVelocity_z + 15.0, -get_pcvar_float(g_pCvarFallSpeed))
			fVecVelocity[2] = fVelocity_z
			set_pev(id, pev_velocity, fVecVelocity)

			if( pev(iEnt, pev_sequence) == deploy ) {
				flFrame = g_flEntityFrame[id]++

				if( flFrame > 100.0 ) {
					set_pev(iEnt, pev_animtime, 0.0)
					set_pev(iEnt, pev_framerate, 0.4)
					set_pev(iEnt, pev_sequence, idle)
					set_pev(iEnt, pev_gaitsequence, 1)
					set_pev(iEnt, pev_frame, 0.0)
					g_flEntityFrame[id] = 0.0
				}
				else {
					set_pev(iEnt, pev_frame, flFrame)
				}
			}
		}
		else if(iEnt > 0) {
			RemoveUserParachute(id, iEnt)
		}
	}
	else if( iEnt > 0 && pev(id, pev_oldbuttons) & IN_USE ) {
		RemoveUserParachute(id, iEnt)
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang10266\\ f0\\ fs16 \n\\ par }
*/


Vreau să fac parasuta să nu meargă pe unele hărți, insă am o problemă cu script'ul și anume:

Image

Re: Ajutor plugin

Posted: 24 May 2018, 17:45
by LondoN eXtream
| Afiseaza codul
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>

#define _PLUGIN         "AMXX Parachute"
#define _VERSION             "1.0"
#define _AUTHOR           "H.RED.ZONE"

#define MAX_PLAYERS    32

#define MarkUserHasParachute(%0)	g_bitHasParachute |= (1<<(%0&31))
#define ClearUserHasParachute(%0)	g_bitHasParachute &= ~(1<<(%0&31))
#define HasUserParachute(%0)		g_bitHasParachute & (1<<(%0&31))

new g_bitHasParachute 

new const fail_maps[][] =
{
	"35hp",
	"1hp",
	"knife_"
}

new g_iUserParachute[MAX_PLAYERS+1]

new Float:g_flEntityFrame[MAX_PLAYERS+1]

new g_pCvarFallSpeed

new const PARACHUTE_CLASS[] = "parachute"

enum {
	deploy,
	idle,
	detach
}

public plugin_init() {
	new mapname[32];
	get_mapname(mapname, charsmax(mapname));
	for(new i = 0; i < sizeof(fail_maps); i++)
	{
		if(containi(mapname, fail_maps) != -1)
		{
			set_fail_state("error");
			continue;
		}
	}

	register_plugin(_PLUGIN, _VERSION, _AUTHOR)

	g_pCvarFallSpeed = register_cvar("parachute_fallspeed", "100")

	register_forward( FM_CmdStart, "fw_Start" )
	
	RegisterHam(Ham_Spawn, "player", "Ham_CBasePlayer_Spawn_Post", 1)
	RegisterHam(Ham_Killed, "player", "Ham_CBasePlayer_Killed_Post", 1)
}

public client_putinserver(id) {
	if( HasUserParachute(id) ) {
		new iEnt = g_iUserParachute[id]
		if( iEnt ) {
			RemoveUserParachute(id, iEnt)
		}
		ClearUserHasParachute(id)
	}
}

public client_disconnect(id) {
	if( HasUserParachute(id) ) {
		new iEnt = g_iUserParachute[id]
		if( iEnt ) {
			RemoveUserParachute(id, iEnt)
		}
		ClearUserHasParachute(id)
	}
}

public Ham_CBasePlayer_Killed_Post( id ) {
	if( HasUserParachute(id) ) {
		new iEnt = g_iUserParachute[id]
		if( iEnt ) {
			RemoveUserParachute(id, iEnt)
		}
		ClearUserHasParachute(id)
	}
}

public Ham_CBasePlayer_Spawn_Post(id) {
	if( is_user_alive(id) ) {
		if( HasUserParachute(id) ) {
			new iEnt = g_iUserParachute[id]
			if( iEnt ) {
				RemoveUserParachute(id, iEnt)
			}
		}
		MarkUserHasParachute(id)
	}
}

RemoveUserParachute(id, iEnt) {
	engfunc(EngFunc_RemoveEntity, iEnt)
	g_iUserParachute[id] = 0
}

CreateParachute(id) {
	static iszInfoTarget
	if( !iszInfoTarget ) {
		iszInfoTarget = engfunc(EngFunc_AllocString, "info_target")
	}

	new iEnt = engfunc(EngFunc_CreateNamedEntity, iszInfoTarget)
	if( iEnt > 0) {
		static iszClass = 0
		if( !iszClass ) {
			iszClass = engfunc(EngFunc_AllocString, PARACHUTE_CLASS)
		}
		set_pev_string(iEnt, pev_classname, iszClass)
		set_pev(iEnt, pev_aiment, id)
		set_pev(iEnt, pev_owner, id)
		set_pev(iEnt, pev_movetype, MOVETYPE_FOLLOW)

		set_pev(iEnt, pev_sequence, deploy)
		set_pev(iEnt, pev_gaitsequence, 1)
		set_pev(iEnt, pev_frame, 0.0)
		g_flEntityFrame[id] = 0.0
		g_iUserParachute[id] = iEnt
		MarkUserHasParachute(id)
		new Float:fVecOrigin[3]
		pev(id, pev_origin, fVecOrigin)
		
		return iEnt
	}
	return 0
}

public fw_Start(id) {
	if( ~HasUserParachute(id) || !is_user_alive(id) ) {
		return
	}

	new Float:flFrame
	new iEnt = g_iUserParachute[id]

	if(iEnt > 0 && pev(id, pev_flags) & FL_ONGROUND) {

		if( pev(iEnt, pev_sequence) != detach ) {
			set_pev(iEnt, pev_sequence, detach)
			set_pev(iEnt, pev_gaitsequence, 1)
			set_pev(iEnt, pev_frame, 0.0)
			g_flEntityFrame[id] = 0.0
			set_pev(iEnt, pev_animtime, 0.0)
			set_pev(iEnt, pev_framerate, 0.0)
			return
		}

		pev(iEnt, pev_frame, flFrame)
		if( flFrame > 252.0 ) {
			RemoveUserParachute(id, iEnt)
			return
		}

		flFrame += 2.0

		g_flEntityFrame[id] = flFrame
		set_pev(iEnt, pev_frame, flFrame)

		return
	}

	if( pev(id, pev_button) & IN_USE ) {
		new Float:fVecVelocity[3], Float:fVelocity_z
		pev(id, pev_velocity, fVecVelocity)
		fVelocity_z = fVecVelocity[2]

		if( fVelocity_z < 0.0 ) {
			if(iEnt <= 0) {
				iEnt = CreateParachute(id)
			}

			fVelocity_z = floatmin(fVelocity_z + 15.0, -get_pcvar_float(g_pCvarFallSpeed))
			fVecVelocity[2] = fVelocity_z
			set_pev(id, pev_velocity, fVecVelocity)

			if( pev(iEnt, pev_sequence) == deploy ) {
				flFrame = g_flEntityFrame[id]++

				if( flFrame > 100.0 ) {
					set_pev(iEnt, pev_animtime, 0.0)
					set_pev(iEnt, pev_framerate, 0.4)
					set_pev(iEnt, pev_sequence, idle)
					set_pev(iEnt, pev_gaitsequence, 1)
					set_pev(iEnt, pev_frame, 0.0)
					g_flEntityFrame[id] = 0.0
				}
				else {
					set_pev(iEnt, pev_frame, flFrame)
				}
			}
		}
		else if(iEnt > 0) {
			RemoveUserParachute(id, iEnt)
		}
	}
	else if( iEnt > 0 && pev(id, pev_oldbuttons) & IN_USE ) {
		RemoveUserParachute(id, iEnt)
	}
}

Re: Ajutor plugin

Posted: 24 May 2018, 22:31
by aware's
Functioneaza man, mersi fain! Ar mai fi o eroare la compliare si anume client disconnect, amxmodx 1.8.3

Re: Ajutor plugin

Posted: 24 May 2018, 23:32
by aware's
Image

amxmodx 5154 - 1.8.3

Re: Ajutor plugin

Posted: 30 May 2018, 15:39
by kobra3
aware's wrote:Image

amxmodx 5154 - 1.8.3
Iti spune acolo linia si ce trebuie sa faci ( sa inlocuiesti client_disconnect cu client_disconnected )

Re: Ajutor plugin

Posted: 30 May 2018, 18:03
by aware's
Odata schimbat apar alte erori :) nu mai am nevoie, mersi.