[Feuerwehrsystem] Mein Fuerwehrsystem ist verbuggt.

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
  • Hallo Leute...
    Ich habe ein Problem mit meinen Feuerwehrsystem, es ist verbuggt. Wenn ich in das Feuer gehe, dann passiert mir nur manchmal was, also manchmal fange ich an zu brennen, wenn ich das Feuer löschen möchte, gleich ob im Fahrzeug oder per Löscher, es funktioniert gar nicht, ich habe das Feuersystem genommen, das die meisten verwenden, die meisten GF Server, also ich habe es ähnlich gescriptet, doch weil ich es bin klappt es natürlich wieder nicht,
    das kenne ich ja schon. Naja, vllt hat ja auch so einer son Problem, hier der Code und die Bilder.


    enum FlameInfo
    {
    Flame_id,
    Flame_Exists,
    Float:Flame_x,
    Float:Flame_y,
    Float:Flame_z,
    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];


    OnGameModeInit{SetTimer("Timer1",1039,true);}


    forward Timer1();
    public Timer1()
    {
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(!IsPlayerConnected(i) || IsPlayerNPC(i)) { continue; }
    if(PlayerOnFire[i] && !CanPlayerBurn(i, 1))
    { StopPlayerBurning(i); }
    if(Pissing_at_Flame(i) != -1 || Aiming_at_Flame(i) != -1)
    {
    if(IsPlayerInFrakt(i,18))
    {
    GameTextForPlayer(i,"~n~~n~~n~~n~~n~~n~~r~Feuer ~w~in Sicht",5500, 5);
    }
    if(!ExtTimer[i] && ((Aiming_at_Flame(i) != -1 && Pressing(i) & KEY_FIRE) || Pissing_at_Flame(i) != -1))
    {
    new value, time, Float:x, Float:y, Float:z;
    if(Pissing_at_Flame(i) != -1)
    {
    value = Pissing_at_Flame(i);
    time = EXTINGUISH_TIME_PEEING;
    }
    else if(Aiming_at_Flame(i) != -1)
    {
    value = Aiming_at_Flame(i);
    if(GetPlayerWeapon(i) == 41)
    {
    CreateExplosion(Flame[value][Flame_x], Flame[value][Flame_y], Flame[value][Flame_z], 2, 5);
    continue;
    }
    if(IsPlayerInAnyVehicle(i))
    {
    time = EXTINGUISH_TIME_VEHICLE;
    }
    else
    {
    time = EXTINGUISH_TIME_ONFOOT;
    }
    }
    if(value < -1) { time = EXTINGUISH_TIME_PLAYER;
    time *= 700;
    if(value >= -1)
    {
    x = Flame[value][Flame_x];
    y = Flame[value][Flame_y];
    z = Flame[value][Flame_z];
    DestroySmoke(value);
    Flame[value][Smoke][0] = CreateDynamicObject(18727, x, y, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][1] = CreateDynamicObject(18727, x+1, y, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][2] = CreateDynamicObject(18727, x-1, y, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][3] = CreateDynamicObject(18727, x, y+1, z, 0.0, 0.0, 0.0);
    Flame[value][Smoke][4] = CreateDynamicObject(18727, x, y-1, z, 0.0, 0.0, 0.0);
    SetTimerEx("DestroySmoke", time, 0, "d", value);
    }
    ExtTimer[i] = SetTimerEx("FireTimer", time, 0, "dd", i, value);
    }
    }
    if(CanPlayerBurn(i) && IsAtFlame(i)) { SetPlayerBurn(i); }
    new Float:x, Float:y, Float:z;
    if(i != i && IsPlayerConnected(i) && !IsPlayerNPC(i))
    {
    if(CanPlayerBurn(i) && PlayerOnFire[i] && !PlayerOnFire[i])
    {
    GetPlayerPos(i, x, y, z);
    if(IsPlayerInRangeOfPoint(i, 1, x, y, z))
    {
    SetPlayerBurn(i);
    }
    }
    }
    }
    }
    return 1;
    }


    stock GetFireID(Float:x, Float:y, Float:z, &Float:dista)
    {
    new id = -1;
    dista = 99999.99;
    for(new i; i < MAX_FLAMES; i++)
    {
    if(GetDistanceBetweenPoints(x,y,z,Flame[i][Flame_x],Flame[i][Flame_y],Flame[i][Flame_z]) < dist)
    {
    dista = GetDistanceBetweenPoints(x,y,z,Flame[i][Flame_x],Flame[i][Flame_y],Flame[i][Flame_z]);
    id = i;
    }
    }
    return id;
    }


    CanPlayerBurn(playerid, val = 0)
    {
    if(CallRemoteFunction("CanBurn", "d", playerid) >= 0 && GetPlayerSkin(playerid) != 277 && GetPlayerSkin(playerid) != 278 && GetPlayerSkin(playerid) != 279 && ((!val && !PlayerOnFire[playerid]) || (val && PlayerOnFire[playerid]))) { return 1; }
    return 1;
    }


    stock IsPlayerInWater(playerid)
    {
    new Float:MV_wpos[3];
    GetPlayerPos(playerid,MV_wpos[0],MV_wpos[1],MV_wpos[2]);
    if((MV_wpos[2] > 0.00) || IsPlayerInZonee(playerid,1808.2019,1424.5392,-2230.5024,-2347.7979)) { return 0; }
    else if((MV_wpos[2] < 0.00) && (MV_wpos[2] > -1.00)) { return 1; }
    else if(MV_wpos[2] < -1.00) { return 2; }
    return 0;
    }


    GetFlameSlot()
    {
    for(new i = 0; i < MAX_FLAMES; i++)
    {
    if(!Flame[i][Flame_Exists]) { return i; }
    }
    return -1;
    }


    IsAtFlame(playerid)
    {
    for(new i = 0; i < MAX_FLAMES; i++)
    {
    if(Flame[i][Flame_Exists])
    {
    if(!IsPlayerInAnyVehicle(playerid) && (IsPlayerInRangeOfPoint(playerid, FLAME_ZONE, Flame[i][Flame_x], Flame[i][Flame_y], Flame[i][Flame_z]+Z_DIFFERENCE) ||
    IsPlayerInRangeOfPoint(playerid, FLAME_ZONE, Flame[i][Flame_x], Flame[i][Flame_y], Flame[i][Flame_z]+Z_DIFFERENCE-1)))
    {
    return 1;
    }
    }
    }
    return 0;
    }


    stock Aiming_at_Flame(playerid)
    {
    new id = -1;
    new Float:dis = 99999.99;
    new Float:dis2;
    new Float:Zx, Float:Zy, Float:Zz;


    new Float:cx,Float:cy,Float:cz,Float:fsx,Float:fsy,Float:fsz;
    GetPlayerCameraPos(playerid, cx, cy, cz);
    GetPlayerCameraFrontVector(playerid, fsx, fsy, fsz);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i) && PlayerOnFire[i] && (IsInWaterCar(playerid) || HasExtinguisher(playerid) || GetPlayerWeapon(playerid) == 41) && PlayerOnFire[i])
    {
    GetPlayerPos(i, Zx, Zy, Zz);
    dis2 = DistanceCameraTargetToLocation(cx, cy, cz, Zx, Zy, Zz, fsx, fsy, fsz);
    if(dis2 < dis)
    {
    dis = dis2;
    id = i;
    }
    }
    }
    if(id != -1) { return id-MAX_PLAYERS; }
    for(new i; i < MAX_FLAMES; i++)
    {
    if(Flame[i][Flame_Exists])
    {
    if(IsInWaterCar(playerid) || HasExtinguisher(playerid) || GetPlayerWeapon(playerid) == 41)
    {
    dis2 = DistanceCameraTargetToLocation(cx, cy, cz, Flame[i][Flame_x], Flame[i][Flame_y], Flame[i][Flame_z]+Z_DIFFERENCE, fsx, fsy, fsz);
    if(IsPlayerInAnyVehicle(playerid) && dis2 < CAR_RADIUS && dis2 < dis)
    {
    dis = dis2;
    id = i;
    }
    else if(!IsPlayerInAnyVehicle(playerid) && dis2 < ONFOOT_RADIUS && dis2 < dis)
    {
    dis = dis2;
    id = i;
    }
    }
    }
    }
    if(id != -1)
    {
    if
    (
    (
    IsPlayerInAnyVehicle(playerid) && !IsPlayerInRangeOfPoint(playerid, 50, Flame[id][Flame_x], Flame[id][Flame_y], Flame[id][Flame_z])
    )
    ||
    (
    !IsPlayerInAnyVehicle(playerid) && !IsPlayerInRangeOfPoint(playerid, 5, Flame[id][Flame_x], Flame[id][Flame_y], Flame[id][Flame_z])
    )
    )
    { id = -1; }
    }
    return id;
    }


    Pissing_at_Flame(playerid)
    {
    new id = -1;
    new Float:dis = 99999.99, Float:dis2;
    new Float:x,Float:y,Float:z,Float:x1,Float:y1,Float:z1,Float:a;
    GetXYInFrontOfPlayer(playerid, x, y, z, a, 1);
    z -= Z_DIFFERENCE;
    if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_PISSING)
    {
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i) && PlayerOnFire[i] && PlayerOnFire[i])
    {
    GetPlayerPos(i, x1, y1, z1);
    if(IsPlayerInRangeOfPoint(playerid, ONFOOT_RADIUS, x1, y1, z1))
    {
    id = i;
    }
    }
    }
    if(id != -1) { return id-MAX_PLAYERS; }
    for(new i; i < MAX_FLAMES; i++)
    {
    if(Flame[i][Flame_Exists])
    {
    if(!IsPlayerInAnyVehicle(playerid))
    {
    dis2 = GetDistanceBetweenPoints(x,y,z,Flame[i][Flame_x],Flame[i][Flame_y],Flame[i][Flame_z]);
    if(dis2 < PISSING_WAY && dis2 < dis)
    {
    id = i;
    dis = dis2;
    }
    }
    }
    }
    }
    return id;
    }


    IsInWaterCar(playerid)
    {
    if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 407 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 601) { return 1; }
    return 0;
    }


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


    Pressing(playerid)
    {
    new keys, updown, leftright;
    GetPlayerKeys(playerid, keys, updown, leftright);
    return keys;
    }


    forward FireTimer(playerid, id);
    public FireTimer(playerid, id)
    {
    if(id < -1 && Aiming_at_Flame(playerid) == id) { StopPlayerBurning(id+MAX_PLAYERS); }
    else if(id < -1 && Pissing_at_Flame(playerid) == id) { StopPlayerBurning(id+MAX_PLAYERS); }
    else if(Flame[id][Flame_Exists] && ((Pressing(playerid) & KEY_FIRE && Aiming_at_Flame(playerid) == id) || (Pissing_at_Flame(playerid) == id)))
    {
    if(Pissing_at_Flame(playerid) == id)
    {
    if(IsPlayerInFrakt(playerid,18))
    {
    GibGeld(playerid,2);
    }
    }
    else if(Aiming_at_Flame(playerid) == id)
    {
    if(IsPlayerInFrakt(playerid,18))
    {
    GibGeld(playerid,3);
    }
    }
    KillFire(id);
    }
    KillTimer(ExtTimer[playerid]);
    ExtTimer[playerid] = 0;
    }


    forward DestroySmoke(id);
    public DestroySmoke(id)
    {
    for(new i; i < 5; i++)
    {
    DestroyDynamicObject(Flame[id][Smoke][i]);
    }
    return 1;
    }


    forward StopPlayerBurning(playerid);
    public StopPlayerBurning(playerid)
    {
    KillTimer(PlayerOnFireTimer[playerid]);
    PlayerOnFire[playerid] = 0;
    RemovePlayerAttachedObject(playerid, FIRE_OBJECT_SLOT);
    }


    forward SetPlayerBurn(playerid);
    public SetPlayerBurn(playerid)
    {
    SetPlayerAttachedObject(playerid, FIRE_OBJECT_SLOT, 18690, 2, -1, 0, -1.9, 0, 0);
    PlayerOnFire[playerid] = 1;
    GetPlayerHealth(playerid, PlayerOnFireHP[playerid]);
    KillTimer(PlayerOnFireTimer[playerid]); KillTimer(PlayerOnFireTimer2[playerid]);
    PlayerOnFireTimer[playerid] = SetTimerEx("BurningTimer", 101, 1, "d", playerid);
    PlayerOnFireTimer2[playerid] = SetTimerEx("StopPlayerBurning", 7177, 0, "d", playerid);
    return 1;
    }


    forward BurningTimer(playerid);
    public BurningTimer(playerid)
    {
    if(PlayerOnFire[playerid])
    {
    new Float:hsp;
    GetPlayerHealth(playerid, hsp);
    if(hsp < PlayerOnFireHP[playerid])
    {
    PlayerOnFireHP[playerid] = hsp;
    }
    SetPlayerHealth(playerid, PlayerOnFireHP[playerid]-1.0);
    PlayerOnFireHP[playerid] -= 1.0;
    }
    else
    {
    KillTimer(PlayerOnFireTimer[playerid]); KillTimer(PlayerOnFireTimer2[playerid]);
    }
    }


    Die definierungen habe ich alle, es sind keine Errors vorhanden, und keine Warnings, doch es Buggt wie sau.
    Hier die Bilder noch im Anhang zu sehen, der Beweiß, dass ich auch darauf geaimt habe auf die Flammen, doch es brachte nichts.
    Das Feuer lodert noch immer, was soll ich nur tun, vllt kann man mir auch über TV helfen, dann könnte man evt auch über eine Belohung reden.
    Weil ich sehr dankbar sein würde. Ich glaube aber nicht das der Code irgendwas gebracht hat. Ich glaube auch nicht, dass ich eine Antwort bekomme, weil immer wenn ich so ein langes Theme poste denke ich da wird nichts kommen, aber was nicht ist kann ja noch werden. Die Hoffnung stirbt zuletzt. Vielleicht könnt ihr ja helfen bis meine Hoffnung ganz ausgestorben ist. Ich habe nun zum oftmals versucht es immer wieder umzuscripten, aber heys, ein Schritt weiter bin ich schonmal. Beim Compiler stürzt nicht mehr ab :D