Problem oko teargas

Započeo statham.3
12. Sep. 2020.
508
pregleda
3
postova
Lazar Milojevic
5
Kingpin
12. Sep. 2020.
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:
//=======================================================
/*
@title Teargas - V.2
@author Carlton
@COPYRIGHT (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
*/
//=======================================================
//=======================================================
#include // www.sa-mp.com
#include // http://forum.sa-mp.com/index.php?topic=145196.0
//=======================================================
#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,
}
new
TearGasData,
GasUsed,
TearGasTimer,
bool:TimerStarted,
Float:pPos;
//=======================================================
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, TearGasData, TearGasData)) {
            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, pPos, pPos);
            GetXYInFrontOfPlayer(playerid, pPos, pPos, 10.0);
            MapAndreas_FindZ_For2DCoord(pPos+5, pPos+5, pPos);
          TearGasData = pPos;
          TearGasData = pPos;
          TearGasData = pPos;
          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, pPos, pPos);
            GetXYInFrontOfPlayer(playerid, pPos, pPos, 36.0);
            MapAndreas_FindZ_For2DCoord(pPos, pPos, pPos);
          TearGasData = pPos;
          TearGasData = pPos;
#if defined DEBUG_MODE
          CreatePickup(1248, 1, pPos, pPos, pPos+5); // Debug
          SetPlayerPos(playerid, pPos, pPos, pPos); // Debug
#endif
          TearGasData = pPos;
          SetTimerEx("StopTheEffect", 20000, 0, "d", GasUsed);
            GasUsed ++;
            if(TimerStarted == false) {
                TearGasTimer = SetTimer("EffectOfGas", 100, 1);
                TimerStarted = true;
            }
        }
}
#endif
return 1;
}
//=======================================================

Debug iz server_log(ukoliko je u pitanju crashanje servera - crashdetect log): //
naithanwav
4
Shot Caller
12. Sep. 2020.

/*

                        ===================================
                                    Tear-Gas system
                                    By Carlton.
                        ===================================

*/


new TearGas, TearGasTimer, TearObject, TearGasObject;

TearGas_OnPlayerConnect(playerid) {
    TearGas = 0;
}

GivePlayerTearGas(playerid, amount) {
    TearGas += amount;
}

SetPlayerTearGas(playerid, amount) {
    TearGas = amount;
}

GetPlayerTearGas(playerid) return TearGas;

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 = CreateObject(343, x, y, z, 0, 0, 96);
        TearGasTimer = SetTimer("TearGasEfft", 1000, 1);
        SetTimerEx("StopTheEffect", 15000, 0, "d", playerid);
        MoveObject(TearObject, x, y, z-2, 1.00);
        new Float:tx, Float:ty, Float:tz;
        GetObjectPos(TearObject, tx, ty, tz);
        TearGasObject = 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, 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);
    DestroyObject(TearObject);
    DestroyObject(TearGasObject);
}


V2 se nije pokazao nesto , koristi ovo...  😎
Lazar Milojevic
5
Kingpin
13. Sep. 2020.
naithanwav wrote on September 12, 2020, 2:28 pm:

/*

                        ===================================
                                    Tear-Gas system
                                    By Carlton.
                        ===================================

*/


new TearGas, TearGasTimer, TearObject, TearGasObject;

TearGas_OnPlayerConnect(playerid) {
    TearGas = 0;
}

GivePlayerTearGas(playerid, amount) {
    TearGas += amount;
}

SetPlayerTearGas(playerid, amount) {
    TearGas = amount;
}

GetPlayerTearGas(playerid) return TearGas;

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 = CreateObject(343, x, y, z, 0, 0, 96);
        TearGasTimer = SetTimer("TearGasEfft", 1000, 1);
        SetTimerEx("StopTheEffect", 15000, 0, "d", playerid);
        MoveObject(TearObject, x, y, z-2, 1.00);
        new Float:tx, Float:ty, Float:tz;
        GetObjectPos(TearObject, tx, ty, tz);
        TearGasObject = 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, 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);
    DestroyObject(TearObject);
    DestroyObject(TearGasObject);
}


V2 se nije pokazao nesto , koristi ovo...  😎

Hvala brate

Morate biti prijavljeni da biste odgovorili na ovu temu.

Prijava

© 2026 SmartShark. All rights reserved.

Powered by Momentum|v2026.3.001 Alpha