Feuersystem

Wichtiger Hinweis: Bitte ändert nicht manuell die Schriftfarbe auf schwarz sondern belasst es bei der Standardeinstellung. Somit tragt ihr dazu bei dass euer Text auch bei Verwendung unseren dunklen Forenstils noch lesbar ist!

Tipp: Ihr wollt längere Codeausschnitte oder Logfiles bereitstellen? Benutzt unseren eigenen PasteBin-Dienst Link
  • Beitrag von NixMuss ()

    Dieser Beitrag wurde gelöscht, Informationen über den Löschvorgang sind nicht verfügbar.
  • /===============================[ Feuersystem ]================================//
    #define FIRE_OBJECT_SLOT 1 // the slot used with SetPlayerAttachedObject and RemovePlayerAttachedObject
    #define MAX_FLAMES 100//100000 // 100 // maxmimal flames
    #define PISSING_WAY 2.0 // radius in which you can extinguish the flames by peeing
    #define CAR_RADIUS 8.0//10.0 // 8.0 // radius in which you can extinguish the flames by firetruck/SWAT Van
    #define ONFOOT_RADIUS 1.5 // radius in which you can extinguish the flames by foot ( Feuerlöscher )
    #define Z_DIFFERENCE 2.5 // height which is important for the accurancy of extinguishing. please do not change
    #define FLAME_ZONE 1.2//2.5 // 1.2 // radius in which you start burning if you're too close to a flame
    #define EXTINGUISH_TIME_VEHICLE 1 // time you have to spray at the fire with a firetruck (seconds)
    #define EXTINGUISH_TIME_ONFOOT 4 // time you have to spray at the fire onfoot (seconds)
    #define EXTINGUISH_TIME_PEEING 10 // time you have to pee at the fire (seconds)
    #define EXTINGUISH_TIME_PLAYER 3 // time it takes to extinguish a player (seconds)
    #define SPECIAL_ACTION_PISSING 68
    forward AddFire(Float:x, Float:y, Float:z);
    forward KillFire(id);
    forward FireOn(i);
    forward KillSmoke(id);
    forward DestroyTheSmokeFromFlame(id);
    forward OnFireUpdate();
    forward DestroyDynamicSmoke(id);
    forward FireTimer(playerid, id);
    forward SetPlayerBurn(playerid);
    forward BurningTimer(playerid);
    forward StopPlayerBurning(playerid);
    new fwfeuer;
    new brandtimer;
    /*************************************/
    new Feuers = 0;
    new FeuerCall = 999;
    new FeuerCallTime[MAX_PLAYERS];
    new Feuer = 0;
    new FeuerDuty[MAX_PLAYERS];
    new FireCallTime[MAX_PLAYERS];
    /*************************************/
    ***************************************************************
    //============================== [ Feuer System ] ==============================//
    *****************************************************************
    enum FlameInfo
    {
    Flame_id,
    Flame_Exists,
    Float:Flame_x,
    Float:Flame_y,
    Float:Flame_z,
    Float:Flame_pos[3],
    Smoke[5],
    };


    new Flame[MAX_FLAMES][FlameInfo];
    new ExtTimer[MAX_PLAYERS];
    new PlayerOnFire[MAX_PLAYERS];
    new PlayerOnFireTimer[MAX_PLAYERS];
    new PlayerOnFireTimer2[MAX_PLAYERS];
    new Float:PlayerOnFireHP[MAX_PLAYERS];
    /*******************************************************************************/
    stock GetFireID(Float:x, Float:y, Float:z, &Float:dist)
    {
    new id = -1;
    dist = 99999.99;
    for(new i; i < MAX_FLAMES; i++)
    {
    if(GetDistanceBetweenPoints(x,y,z,Flame[Flame_pos][0],Flame[i][Flame_pos][1],Flame[i][Flame_pos][2]) < dist)
    {
    dist = GetDistanceBetweenPoints(x,y,z,Flame[i][Flame_pos][0],Flame[i][Flame_pos][1],Flame[i][Flame_pos][2]);
    id = i;
    }
    }
    return id;
    }
    /*******************************************************************************/
    stock IsPlayerInWater(playerid)
    {
    new Float:X, Float:Y, Float:Z, an = GetPlayerAnimationIndex(playerid);
    GetPlayerPos(playerid, X, Y, Z);
    if((1544 >= an >= 1538 || an == 1062 || an == 1250) && (Z <= 0 || (Z <= 41.0 && IsPlayerInArea(playerid, -1387, -473, 2025, 2824))) ||
    (1544 >= an >= 1538 || an == 1062 || an == 1250) && (Z <= 2 || (Z <= 39.0 && IsPlayerInArea(playerid, -1387, -473, 2025, 2824))))
    {
    return 1;
    }
    return 0;
    }
    /*******************************************************************************/
    stock GetFlameSlot()
    {
    for(new i = 0; i < MAX_FLAMES; i++)
    {
    if(!Flame[i][Flame_Exists]) { return i; }
    }
    return -1;
    }
    /*******************************************************************************/
    stock CanPlayerBurn(playerid, val = 0)
    {
    if(!IsPlayerInWater(playerid) && GetPlayerSkin(playerid) != 277 && GetPlayerSkin(playerid) != 278 && GetPlayerSkin(playerid) != 279 && ((!val && !PlayerOnFire[playerid]) || (val && PlayerOnFire[playerid]))) { return 1; }
    return 0;
    }
    /*******************************************************************************/
    public AddFire(Float:x, Float:y, Float:z)
    {
    new slot = GetFlameSlot();
    if(slot == -1) {return slot;}
    Flame[slot][Flame_Exists] = 1;
    Flame[slot][Flame_x] = x;
    Flame[slot][Flame_y] = y;
    Flame[slot][Flame_z] = z - Z_DIFFERENCE;
    Flame[slot][Flame_id] = CreateDynamicObject(18691, Flame[slot][Flame_x], Flame[slot][Flame_y], Flame[slot][Flame_z], 0.0, 0.0, 0.0);
    return slot;
    }
    public KillFire(id)
    {
    DestroyDynamicObject(Flame[id][Flame_id]);
    Flame[id][Flame_Exists] = 0;
    Flame[id][Flame_x] = 0.0;
    Flame[id][Flame_y] = 0.0;
    Flame[id][Flame_z] = 0.0;
    DestroyDynamicSmoke(id);
    }
    /*******************************************************************************/
    // [ Feuersysem ]
    public DestroyDynamicSmoke(id)
    {
    for(new i; i < 5; i++) { DestroyDynamicObject(Flame[id][Smoke][i]); }
    }
    public FireTimer(playerid, id)
    {
    if(PlayerInfo[playerid][pMember] == 25 || PlayerInfo[playerid][pLeader] == 25)
    {
    if(id < -1 && Aiming_at_Flame(playerid) == id) { StopPlayerBurning(id+MAX_PLAYERS); }
    if(Flame[id][Flame_Exists] && ((Pressing(playerid) & KEY_FIRE && Aiming_at_Flame(playerid) == id)))
    {
    new sendername[MAX_PLAYER_NAME+26];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    KillFire(id);
    new brandgeld = 100;
    new fraktion = 24;
    FraktionsKasse[fraktion] += brandgeld;
    }
    KillTimer(ExtTimer[playerid]);
    ExtTimer[playerid] = 0;
    }
    return 1;
    }
    /*******************************************************************************/
    public SetPlayerBurn(playerid)
    {
    SetPlayerAttachedObject(playerid, FIRE_OBJECT_SLOT, 18730, 2, -1, 0, -1.9, 0, 0);
    PlayerOnFire[playerid] = 1;
    GetPlayerHealth(playerid, PlayerOnFireHP[playerid]);
    KillTimer(PlayerOnFireTimer[playerid]); KillTimer(PlayerOnFireTimer2[playerid]);
    PlayerOnFireTimer[playerid] = SetTimerEx("BurningTimer", 91, 1, "d", playerid);
    PlayerOnFireTimer2[playerid] = SetTimerEx("StopPlayerBurning", 7000, 0, "d", playerid);
    return 1;
    }
    public BurningTimer(playerid)
    {
    if(PlayerOnFire[playerid])
    {
    new Float:hp;
    GetPlayerHealth(playerid, hp);
    if(hp < PlayerOnFireHP[playerid])
    {
    PlayerOnFireHP[playerid] = hp;
    }
    SetPlayerHealth(playerid, PlayerOnFireHP[playerid]-1.0);
    PlayerOnFireHP[playerid] -= 1.0;
    }
    else { KillTimer(PlayerOnFireTimer[playerid]); KillTimer(PlayerOnFireTimer2[playerid]); }
    }
    public StopPlayerBurning(playerid)
    {
    KillTimer(PlayerOnFireTimer[playerid]);
    PlayerOnFire[playerid] = 0;
    RemovePlayerAttachedObject(playerid, FIRE_OBJECT_SLOT);
    }
    /*******************************************************************************/
    Function IsAFeuer(playerid)
    {
    if(IsPlayerConnected(playerid))
    {
    new leader = PlayerInfo[playerid][pLeader];
    new member = PlayerInfo[playerid][pMember];
    if(member==25)
    {
    return 1;
    }
    else if(leader==25)
    {
    return 1;
    }
    }
    return 0;
    }
    /*******************************************************************************/
    //Alles was mit feuer zu tun hat^^
    public OnFireUpdate()
    {
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
    if(PlayerInfo[playerid][pLeader] == 25 || PlayerInfo[playerid][pMember] == 25)
    {
    if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid)) { continue; }
    if(PlayerOnFire[playerid] && !CanPlayerBurn(playerid, 1))
    { StopPlayerBurning(playerid); }
    if(Aiming_at_Flame(playerid) != -1)
    {
    GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~r~~h~Loesche das Feuer!", 1500, 6);
    if(!ExtTimer[playerid] && ((Aiming_at_Flame(playerid) != -1 && Pressing(playerid) & KEY_FIRE)))
    {
    new value, time, Float:x, Float:y, Float:z;
    if(Aiming_at_Flame(playerid) != -1)
    {
    value = Aiming_at_Flame(playerid);
    if(GetPlayerWeapon(playerid) == 41)
    {
    CreateExplosion(Flame[value][Flame_x], Flame[value][Flame_y], Flame[value][Flame_z], 2, 5);
    continue;
    }
    if(IsPlayerInAnyVehicle(playerid))
    {
    time = EXTINGUISH_TIME_VEHICLE;
    }
    else
    {
    time = EXTINGUISH_TIME_ONFOOT;
    }
    }
    if(value < -1) { time = EXTINGUISH_TIME_PLAYER; }
    time *= 1000;
    if(value >= -1)
    {
    x = Flame[value][Flame_x];
    y = Flame[value][Flame_y];
    z = Flame[value][Flame_z];
    DestroyDynamicSmoke(value);
    Flame[value][Smoke][0] = CreateDynamicObject(18726, x, y, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][1] = CreateDynamicObject(18726, x+1, y, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][2] = CreateDynamicObject(18726, x-1, y, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][3] = CreateDynamicObject(18726, x, y+1, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][4] = CreateDynamicObject(18726, x, y-1, z, 0.0, 0.0, 0.0);
    SetTimerEx("DestroyDynamicSmoke", time, 0, "d", value);
    }
    ExtTimer[playerid] = SetTimerEx("FireTimer", time, 0, "dd", playerid, value);
    }
    }
    if(CanPlayerBurn(playerid) && IsAtFlame(playerid)) { SetPlayerBurn(playerid); }
    new Float:x, Float:y, Float:z;
    for(new i; i < MAX_PLAYERS; i++)
    {
    if(playerid != i && IsPlayerConnected(i) && !IsPlayerNPC(i))
    {
    if(CanPlayerBurn(i) && PlayerOnFire[playerid] && !PlayerOnFire[i])
    {
    GetPlayerPos(i, x, y, z);
    if(IsPlayerInRangeOfPoint(playerid, 1, x, y, z))
    {
    SetPlayerBurn(i);
    }
    }
    }
    }
    }
    }
    return 1;
    }
    /*******************************************************************************/
    IsInWaterCar(playerid)
    {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 407) { return 1; }
    return 0;
    }


    HasExtinguisher(playerid)
    {
    if(GetPlayerWeapon(playerid) == 42 && !IsPlayerInAnyVehicle(playerid)) { return 1; }
    return 0;
    }
    /*******************************************************************************//Alles was mit feuer zu tun hat^^
    public OnFireUpdate()
    {
    for(new playerid; playerid < MAX_PLAYERS; playerid++)
    {
    if(PlayerInfo[playerid][pLeader] == 25 || PlayerInfo[playerid][pMember] == 25)
    {
    if(!IsPlayerConnected(playerid) || IsPlayerNPC(playerid)) { continue; }
    if(PlayerOnFire[playerid] && !CanPlayerBurn(playerid, 1))
    { StopPlayerBurning(playerid); }
    if(Aiming_at_Flame(playerid) != -1)
    {
    GameTextForPlayer(playerid, " ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~n~ ~r~~h~Loesche das Feuer!", 1500, 6);
    if(!ExtTimer[playerid] && ((Aiming_at_Flame(playerid) != -1 && Pressing(playerid) & KEY_FIRE)))
    {
    new value, time, Float:x, Float:y, Float:z;
    if(Aiming_at_Flame(playerid) != -1)
    {
    value = Aiming_at_Flame(playerid);
    if(GetPlayerWeapon(playerid) == 41)
    {
    CreateExplosion(Flame[value][Flame_x], Flame[value][Flame_y], Flame[value][Flame_z], 2, 5);
    continue;
    }
    if(IsPlayerInAnyVehicle(playerid))
    {
    time = EXTINGUISH_TIME_VEHICLE;
    }
    else
    {
    time = EXTINGUISH_TIME_ONFOOT;
    }
    }
    if(value < -1) { time = EXTINGUISH_TIME_PLAYER; }
    time *= 1000;
    if(value >= -1)
    {
    x = Flame[value][Flame_x];
    y = Flame[value][Flame_y];
    z = Flame[value][Flame_z];
    DestroyDynamicSmoke(value);
    Flame[value][Smoke][0] = CreateDynamicObject(18726, x, y, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][1] = CreateDynamicObject(18726, x+1, y, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][2] = CreateDynamicObject(18726, x-1, y, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][3] = CreateDynamicObject(18726, x, y+1, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][4] = CreateDynamicObject(18726, x, y-1, z, 0.0, 0.0, 0.0);
    SetTimerEx("DestroyDynamicSmoke", time, 0, "d", value);
    }
    ExtTimer[playerid] = SetTimerEx("FireTimer", time, 0, "dd", playerid, value);
    }
    }
    if(CanPlayerBurn(playerid) && IsAtFlame(playerid)) { SetPlayerBurn(playerid); }
    new Float:x, Float:y, Float:z;
    for(new i; i < MAX_PLAYERS; i++)
    {
    if(playerid != i && IsPlayerConnected(i) && !IsPlayerNPC(i))
    {
    if(CanPlayerBurn(i) && PlayerOnFire[playerid] && !PlayerOnFire[i])
    {
    GetPlayerPos(i, x, y, z);
    if(IsPlayerInRangeOfPoint(playerid, 1, x, y, z))
    {
    SetPlayerBurn(i);
    }
    }
    }
    }
    }
    }
    return 1;
    }
    /*******************************************************************************/
    IsInWaterCar(playerid)
    {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 407) { return 1; }
    return 0;
    }


    HasExtinguisher(playerid)
    {
    if(GetPlayerWeapon(playerid) == 42 && !IsPlayerInAnyVehicle(playerid)) { return 1; }
    return 0;
    }
    /*******************************************************************************/