Problem oko teargas


Započeo Agent 47, Septembar 12, 2020, 14:52:26 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Problem(error/warning): Nasao sam na netu fs kada se baci teargas(dimna bomba) da se u rangu od 10 igracu pokrene animacija da kaslje kao da se gusi. Ja bacim bombu pridjem radi i posle kada opet drugi put bacim bombu i pridjem ne radi  ::)
Deo skripte:
//==========================[Information]=============================
/*
	@title Teargas - V.2
	@author Carlton
	[member=11464]COPYRIGHT[/member] (c) 2010

	@information
		The old Teargas system, i've made in March was clearly bugged,
		I had some freetime on my shoulders and decided to remake it.

		The old Teargas bugs included:
		    - Only the first teargas thrown will work.
		    - Teargas Objects wouldn't disappear.
		    - (Not really a bug) You would do a crack animation.

		I decided to use the object instead of the usless functions I did
		in the past version.

		This version was building for accuracy, unlike the old version, when
		the objects would float into the air, thanks to Kye and his Map Andreas
		plugin, this is no longer in effect (http://forum.sa-mp.com/index.php?topic=145196.0)
		Now when you're near the teargases, any of them, you will cough.

	www.epic-missions.co.cc
*/
//==========================[End]=============================
//==========================[Includes]=============================
#include <a_samp> // www.sa-mp.com
#include <mapandreas> // http://forum.sa-mp.com/index.php?topic=145196.0
//==========================[Configuration]=============================
#define TOTAL_ALLOWED_TEARGAS 50 // The max amount of teargas allowed to be used.
//#define HOLD_GAS_ENABLED // This feature is bugged, it's not suggested to enable this.
//#define DEBUG_MODE // If enabled, this FS's debug mode will be enabled.
//=========================[OnPlayerKeyStateChange defines]===============================
#define PRESSED(%0) \
	(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define HOLDING(%0) \
	((newkeys & (%0)) == (%0))
//==========================[Enums & Variables]=============================
enum TGData {
	Float:Pos[3],
}
new
	TearGasData[TOTAL_ALLOWED_TEARGAS][TGData],
	GasUsed,
	TearGasTimer,
	bool:TimerStarted,
	Float:pPos[3];
//==========================[Functions]=============================
stock 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));
}
//==========================[Timer functions]=============================
forward StopTheEffect(gasid);
public StopTheEffect(gasid) {
    GasUsed --;
	return 1;
}
forward EffectOfGas();
public EffectOfGas() {
	if(GasUsed == 0) {
	    KillTimer(TearGasTimer);
	}
	for(new i = 0; i < MAX_PLAYERS; i ++ ) {
	    if(IsPlayerConnected(i)) {
	        for(new g = 0; g < GasUsed; g ++ ){
	            if(IsPlayerInRangeOfPoint(i, 10.0, TearGasData[g][Pos][0], TearGasData[g][Pos][1], TearGasData[g][Pos][2])) {
		            if(GetPVarInt(i, "InAnim") == 0) {
	              		ApplyAnimation(i,"ped","gas_cwr",4.1,0,1,1,0,0);
			            SetPVarInt(i, "InAnim", 1);
			            #if defined DEBUG_MODE
	              			printf("Yes: %d|%d", GetPVarInt(i, "InAnim"), g);
						#endif
					}
					else {
					    ApplyAnimation(i,"ped","gas_cwr",4.1,0,1,1,0,0);
					}
				}
	            else {
	                if(GetPVarInt(i, "InAnim") == 1) {
		                SetPVarInt(i, "InAnim", 0);
		                #if defined DEBUG_MODE
	              			printf("No: %d|%d", GetPVarInt(i, "InAnim"), g);
						#endif
					}
	            }
	        }
	    }
	}
	return 1;
}
//==========================[Public functions]=============================
public OnFilterScriptInit() {
    MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
    GasUsed = 0;
    return 1;
}
public OnPlayerConnect(playerid) {
    ApplyAnimation(playerid,"ped","null",0.0,0,0,0,0,0);
    SetPVarInt(playerid, "InAnim", 0);
    #if defined HOLD_GAS_ENABLED
   		SetPVarInt(playerid, "Holding", 0);
	#endif
	return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
	if (PRESSED(KEY_FIRE)) {
        if(GetPlayerWeapon(playerid) == 17) {
            GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
            GetXYInFrontOfPlayer(playerid, pPos[0], pPos[1], 10.0);
            MapAndreas_FindZ_For2DCoord(pPos[0]+5, pPos[1]+5, pPos[2]);
           	TearGasData[GasUsed][Pos][0] = pPos[0];
           	TearGasData[GasUsed][Pos][1] = pPos[1];
           	TearGasData[GasUsed][Pos][2] = pPos[2];
           	SetTimerEx("StopTheEffect", 20000, 0, "d", GasUsed);
            GasUsed ++;
            if(TimerStarted == false) {
                TearGasTimer = SetTimer("EffectOfGas", 100, 1);
                TimerStarted = true;
            }
        }
	}
	#if defined HOLD_GAS_ENABLED
		if(HOLDING(KEY_FIRE)) {
	 		  if(GetPlayerWeapon(playerid) == 17) {
		        SetPVarInt(playerid, "Holding", 1);
		        GasUsed --;
	            GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
	            GetXYInFrontOfPlayer(playerid, pPos[0], pPos[1], 36.0);
	            MapAndreas_FindZ_For2DCoord(pPos[0], pPos[1], pPos[2]);
	           	TearGasData[GasUsed][Pos][0] = pPos[0];
	           	TearGasData[GasUsed][Pos][1] = pPos[1];
				#if defined DEBUG_MODE
		           	CreatePickup(1248, 1, pPos[0], pPos[1], pPos[2]+5); // Debug
		           	SetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]); // Debug
				#endif
	           	TearGasData[GasUsed][Pos][2] = pPos[2];
	           	SetTimerEx("StopTheEffect", 20000, 0, "d", GasUsed);
	            GasUsed ++;
	            if(TimerStarted == false) {
	                TearGasTimer = SetTimer("EffectOfGas", 100, 1);
	                TimerStarted = true;
	            }
	        }
		}
	#endif
	return 1;
}
//==========================[End]=============================

Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log): //
Es ist nicht alles Gold, was glänzt

/*
 
                        ===================================
                                     Tear-Gas system
                                     By Carlton.
                        ===================================
 
*/
 
 
new TearGas[MAX_PLAYERS], TearGasTimer[MAX_PLAYERS], TearObject[MAX_PLAYERS], TearGasObject[MAX_PLAYERS];
 
TearGas_OnPlayerConnect(playerid) {
    TearGas[playerid] = 0;
}
 
GivePlayerTearGas(playerid, amount) {
    TearGas[playerid] += amount;
}
 
SetPlayerTearGas(playerid, amount) {
    TearGas[playerid] = amount;
}
 
GetPlayerTearGas(playerid) return TearGas[playerid];
 
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));
}
 
TearGasOnPlayerKeyStateChange(playerid, newkeys)
{
    if (newkeys & KEY_FIRE) {
        if(GetPlayerTearGas(playerid) >= 1) {
        ApplyAnimation(playerid,"GRENADE","WEAPON_throwu",4.1,0,1,1,1,1);
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        GetXYInFrontOfPlayer(playerid, x, y, 10.0);
        TearObject[playerid] = CreateObject(343, x, y, z, 0, 0, 96);
        TearGasTimer[playerid] = SetTimer("TearGasEfft", 1000, 1);
        SetTimerEx("StopTheEffect", 15000, 0, "d", playerid);
        MoveObject(TearObject[playerid], x, y, z-2, 1.00);
        new Float:tx, Float:ty, Float:tz;
        GetObjectPos(TearObject[playerid], tx, ty, tz);
        TearGasObject[playerid] = CreateObject(2780, tx, ty, tz-2, 0, 0, 96);
        GivePlayerTearGas(playerid, -1);
        }
    }
}
 
forward TearGasEfft();
public TearGasEfft()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        new Float:tx, Float:ty, Float:tz;
        GetObjectPos(TearGasObject[i], tx, ty, tz);
        if(IsPlayerInRangeOfPoint(i, 10.0, tx, ty, tz))
        {
            ApplyAnimation(i,"CRACK","crckdeth4",4.1,0,1,1,1,1);
        }
    }
}
 
forward StopTheEffect(playerid);
public StopTheEffect(playerid)
{
    KillTimer(TearGasTimer[playerid]);
    DestroyObject(TearObject[playerid]);
    DestroyObject(TearGasObject[playerid]);
}


V2 se nije pokazao nesto , koristi ovo...  8)
Citat: Galardo poslato Januar 01, 1970, 01:00:00 PRE PODNE
Ako mislis da radis mod od 0 i da uzimas tudje radove i samo krhnuti u mod i ocekivati da radi?
Ako mislis da ne mrdnes kurcem i da pravis "mod" od "0" sa tudjim radovima,molim te,pomozi nama i sebi,radi nesto drugo.
Tebi ovaj forum dodje kao "Ispuni mi zelju" pa da ti za svaki jebeni error/warning neko pomaze i da se jebe oko tebe,a kada ti nesto zatrazi ti mu neces biti u stanju poslati jer ne znas o cemu taj isti prica iako je to nesto osnovno sto bi trebao da znas. Hvala i dovidjenja

Citat: naithanwav poslato Septembar 12, 2020, 16:28:07 POSLE PODNE
/*
 
                        ===================================
                                     Tear-Gas system
                                     By Carlton.
                        ===================================
 
*/
 
 
new TearGas[MAX_PLAYERS], TearGasTimer[MAX_PLAYERS], TearObject[MAX_PLAYERS], TearGasObject[MAX_PLAYERS];
 
TearGas_OnPlayerConnect(playerid) {
    TearGas[playerid] = 0;
}
 
GivePlayerTearGas(playerid, amount) {
    TearGas[playerid] += amount;
}
 
SetPlayerTearGas(playerid, amount) {
    TearGas[playerid] = amount;
}
 
GetPlayerTearGas(playerid) return TearGas[playerid];
 
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));
}
 
TearGasOnPlayerKeyStateChange(playerid, newkeys)
{
    if (newkeys & KEY_FIRE) {
        if(GetPlayerTearGas(playerid) >= 1) {
        ApplyAnimation(playerid,"GRENADE","WEAPON_throwu",4.1,0,1,1,1,1);
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        GetXYInFrontOfPlayer(playerid, x, y, 10.0);
        TearObject[playerid] = CreateObject(343, x, y, z, 0, 0, 96);
        TearGasTimer[playerid] = SetTimer("TearGasEfft", 1000, 1);
        SetTimerEx("StopTheEffect", 15000, 0, "d", playerid);
        MoveObject(TearObject[playerid], x, y, z-2, 1.00);
        new Float:tx, Float:ty, Float:tz;
        GetObjectPos(TearObject[playerid], tx, ty, tz);
        TearGasObject[playerid] = CreateObject(2780, tx, ty, tz-2, 0, 0, 96);
        GivePlayerTearGas(playerid, -1);
        }
    }
}
 
forward TearGasEfft();
public TearGasEfft()
{
    for(new i=0; i < MAX_PLAYERS; i++)
    {
        new Float:tx, Float:ty, Float:tz;
        GetObjectPos(TearGasObject[i], tx, ty, tz);
        if(IsPlayerInRangeOfPoint(i, 10.0, tx, ty, tz))
        {
            ApplyAnimation(i,"CRACK","crckdeth4",4.1,0,1,1,1,1);
        }
    }
}
 
forward StopTheEffect(playerid);
public StopTheEffect(playerid)
{
    KillTimer(TearGasTimer[playerid]);
    DestroyObject(TearObject[playerid]);
    DestroyObject(TearGasObject[playerid]);
}


V2 se nije pokazao nesto , koristi ovo...  8)
Hvala brate
Es ist nicht alles Gold, was glänzt