Blitzer will uns nicht blitzen.

In 10 Minuten startet der nächtliche Backupvorgang! Es kann währenddessen (ca. 10 Minuten) zu Einschränkungen bei der Nutzung des Forums kommen
Weitere Infos findet ihr im Thema Backup des Forums
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
  • Wir haben das Include für Blitzer: [ FILTERSCRIPT ] [INCLUDE] Blitzer - System


    Nun wollen wir es in unser Script einbauen. Derzeit sieht es so aus:


    if(strcmp(cmd, "/blitzer", true) == 0)
    {
    if(SpielerInfo[playerid][Member] == 1 || SpielerInfo[playerid][Leader] == 1)
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, COLOR_GOLD, "___________________________|Blitzer|___________________________");
    SendClientMessage(playerid, COLOR_WHITE, "Benutzung: /blitzer [Funktion]");
    SendClientMessage(playerid, COLOR_WHITE, "Verfügbare Funktionen: neu, weg, alleweg [Rang 4], anzeigen");
    SendClientMessage(playerid, COLOR_GOLD, "_____________________________________________________________");
    return 1;
    }
    if(strcmp(tmp,"neu",true) == 0)
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, COLOR_WHITE, "Benutzung: /blitzer neu [Geschwindigkeit] [Strafe].");
    return 1;
    }
    new b_speed;
    b_speed = strval(tmp);
    if(b_speed < 20 || b_speed > 180)
    {
    SendClientMessage(playerid, COLOR_WHITE, "Hinweis: Die Geschwindigkeit muss zwischen 20 und 180 km/h liegen.");
    return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, COLOR_WHITE, "Benutzung: /blitzer neu [Geschwindigkeit] [Strafe].");
    return 1;
    }
    new b_strafe;
    b_strafe = strval(tmp);
    if(b_strafe < 5 || b_strafe > 500)
    {
    SendClientMessage(playerid, COLOR_WHITE, "Hinweis: Die Strafe muss zwischen 5$ / KMH und 500$ / KMH liegen.");
    return 1;
    }
    if(IsPlayerInAnyVehicle(playerid))
    {
    AddBlitzer(playerid,b_speed,b_strafe);
    new player[MAX_PLAYER_NAME];
    GetPlayerName(playerid, player, sizeof(player));
    format(string, sizeof(string), "%s hat einen Blitzer aufgestellt.", player);
    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    format(string, sizeof(string), "Blitzer aufgestellt, Max. Geschwindigkeit: %d, Strafe: %d.", b_speed, b_strafe);
    SendClientMessage(playerid, COLOR_GREEN, string);
    BlitzerErstellt[playerid] = 1;
    TogglePlayerControllable(playerid,0);
    return 1;
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD1, "Du musst in einem Auto sein!");
    }
    }
    else if(strcmp(tmp,"weg",true) == 0)
    {
    RemoveBlitzer(playerid);
    new player[MAX_PLAYER_NAME];
    GetPlayerName(playerid, player, sizeof(player));
    format(string, sizeof(string), "%s hat seinen Blitzer abgebaut.", player);
    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    BlitzerErstellt[playerid] = 0;
    TogglePlayerControllable(playerid,1);
    return 1;
    }
    else if(strcmp(tmp,"alleweg",true) == 0)
    {
    if(SpielerInfo[playerid][Rang] <= 4)
    {
    SendClientMessage(playerid, COLOR_WHITE, "Mindestens Rang 4 benötigt!");
    return 1;
    }
    RemoveAllBlitzer();
    SendClientMessage(playerid, COLOR_GREEN, "Alle Blitzer abgebaut.");
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(SpielerInfo[i][Member] == 1 || SpielerInfo[i][Leader] == 1)
    {
    RemoveBlitzer(i);
    TogglePlayerControllable(i,1);
    new player[MAX_PLAYER_NAME];
    GetPlayerName(playerid, player, sizeof(player));
    format(string, sizeof(string), "*Alle Blitzer wurden von %s abgebaut.", player);
    SendClientMessage(i, COLOR_LIGHTBLUE, string);
    }
    }
    return 1;
    }
    else if(strcmp(tmp, "anzeigen", true) == 0)
    {
    if(GesammtBlitzer != 0)
    {
    SendClientMessage(playerid, COLOR_GOLD, "______________| Aktive Blitzer |_______________");
    format(string, sizeof(string), "%d / 15 Blitzer derzeit aktiv.", GesammtBlitzer);
    SendClientMessage(playerid, COLOR_WHITE, string);
    SendClientMessage(playerid, COLOR_GOLD, "_____________________________________________");
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD1, "Keine Blitzer aktiv.");
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_WHITE, "___________________________|Fehler|__________________________");
    SendClientMessage(playerid, COLOR_WHITE, "Benutzung: /blitzer [Funktion].");
    SendClientMessage(playerid, COLOR_WHITE, "Verfügbare Funktionen: neu, weg, alleweg [Rang 4], anzeigen.");
    SendClientMessage(playerid, COLOR_WHITE, "_____________________________________________________________");
    return 1;
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD1, "Du bist kein Polizist!");
    }
    return 1;
    }


    Es will aber nicht, wieso? Blitzer usw. wird aufgestellt, blitzt aber nicht.

  • public Blitzer_Timer()
    {
    new save, strafe, speeds;
    for (new playerid = 0; playerid < MAX_PLAYERS; playerid++)
    {
    save = GetPVarInt(playerid, "BlitzPause");
    if(save > 0)
    {
    save--;
    SetPVarInt(playerid, "BlitzPause", save);
    continue;
    }
    if(!IsPlayerInAnyVehicle(playerid) || IsPlayerNPC(playerid)) continue;
    for(new i = 0; i < sizeof(Blitzer); i++)
    {
    if(Blitzer[i][Erstellt] == 1)
    {
    if(IsPlayerInRangeOfPoint(playerid, Blitzer[i][Radius], Blitzer[i][BlitzerX], Blitzer[i][BlitzerY], Blitzer[i][BlitzerZ]))
    {
    new Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,final_speed_int;
    new veh = GetPlayerVehicleID(playerid);
    GetVehicleVelocity(veh, speed_x, speed_y, speed_z);
    final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*3.6; // 136.666667 = kmph // 85.4166672= mph
    final_speed_int = floatround(final_speed,floatround_round);
    speeds = final_speed_int;
    if(speeds > Blitzer[i][Geschwindigkeit1] && SpielerInfo[playerid][Fraktion] == 1 && GetPlayerState(playerid) == 2)
    {
    new string[128];
    // Einstellen des Momentes, in dem der Spieler kein weiteres mal geblitzt werden kann
    SetPVarInt(playerid, "BlitzPause", (BLITZER_TIMER_INTERVALL * BLITZER_PAUSE * 60) / 1000);
    // Strafe für Spieler
    strafe = Blitzer[i][Strafe] * (speeds-Blitzer[i][Geschwindigkeit1]);
    PlayerPlaySound(playerid, 1132, 0.0, 0.0, 0.0);
    FraktionsKasse[0] += strafe;
    GivePlayerMoney(playerid, -strafe);
    // Text für Spieler
    format(string,sizeof(string), "[BLITZER]Du bist %d KM/H gefahren, erlaubt waren %d KM/H, du musst $%d Bußgeld bezahlen.", speeds, Blitzer[i][Geschwindigkeit1], strafe);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    // Für Oamt
    for(new o = 0; o < MAX_PLAYERS; o++)
    {
    if(SpielerInfo[i][Member] == 1 || SpielerInfo[i][Leader] == 1)
    {
    if(IsPlayerInRangeOfPoint(o, Blitzer[i][Radius], Blitzer[i][BlitzerX], Blitzer[i][BlitzerY], Blitzer[i][BlitzerZ]))
    {
    new giveplayer[MAX_PLAYER_NAME];
    GetPlayerName(o, giveplayer, sizeof(giveplayer));
    format(string, sizeof(string), "%s ist %d KM/H gefahren und hat %d$ Bußgeld gezahlt.", giveplayer, speeds, strafe);
    SendClientMessage(o, COLOR_YELLOW, string);
    }
    }
    }
    // Ende für Cops
    }
    }
    }
    }
    }
    return 1;
    }


    //====== BLITZER FUNKTIONEN =======//
    stock AddBlitzer(playerid,speeds,strafe) {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid,x,y,z);
    for(new i = 0; i < sizeof(Blitzer); i++) {
    if(Blitzer[i][Erstellt] == 0) {
    Blitzer[i][BlitzerX] = x + 1.0;
    Blitzer[i][BlitzerY] = y + 1.0;
    Blitzer[i][BlitzerZ] = z;
    Blitzer[i][Geschwindigkeit1] = speeds;
    Blitzer[i][Radius] = 50;
    Blitzer[i][Strafe] = strafe;
    Blitzer[i][Erstellt] = 1;
    Blitzer[i][ID] += 1;
    GesammtBlitzer++;
    return 1;
    }
    }
    return 0;
    }
    stock RemoveBlitzer(playerid) {
    for(new i = 0; i < sizeof(Blitzer); i++) {
    if(Blitzer[i][Erstellt] == 1) {
    if(IsPlayerInRangeOfPoint(playerid, Blitzer[i][Radius], Blitzer[i][BlitzerX], Blitzer[i][BlitzerY], Blitzer[i][BlitzerZ])) {
    Blitzer[i][Erstellt] = 0;
    Blitzer[i][BlitzerX] = 0.0;
    Blitzer[i][BlitzerY] = 0.0;
    Blitzer[i][BlitzerZ] = 0.0;
    GesammtBlitzer--;
    return 1;
    }
    }
    }
    return 0;
    }
    stock RemoveAllBlitzer() {
    for(new i = 0; i < sizeof(Blitzer); i++) {
    if(Blitzer[i][Erstellt] == 1) {
    Blitzer[i][Erstellt] = 0;
    Blitzer[i][BlitzerX] = 0.0;
    Blitzer[i][BlitzerY] = 0.0;
    Blitzer[i][BlitzerZ] = 0.0;
    DestroyObject(Blitzer[i][ID]);
    GesammtBlitzer = 0;
    }
    }
    return 0;
    }
    stock CountBlitzer() {
    new anzahl = 0;
    for(new i = 0; i < sizeof(Blitzer); i++) {
    if(Blitzer[i][Erstellt] == 1) anzahl++;
    }
    return anzahl;
    }
    stock ErmittleGeschwindigkeit(playerid,bool:kmhb) {
    new Float:x,Float:y,Float:z,Float:rtn;
    if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z); else GetPlayerVelocity(playerid,x,y,z);
    rtn = floatsqroot(x*x+y*y+z*z);
    return kmhb?floatround(rtn * 55 * 1.61):floatround(rtn * 100);
    }



    Und SetTimer("Blitzer_Timer", BLITZER_TIMER_INTERVALL, 1); unter OnGamemOdeINit