Jede Fraktion kann /gov (Gescriptet) - Bug

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.


    Ich habe gescriptet das alle leader einer Fraktion /gov machen können doch beim Compailen stürtz der Compailer ab wegen Probleme oder so



    if(strcmp(cmd, "/government", true) == 0 || strcmp(cmd, "/gov", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    if(IsPlayerInFrac(playerid, 1)&& IsPlayerInFrac(playerid, 2)&& IsPlayerInFrac(playerid, 3)&& !IsPlayerInFrac(playerid, 4)&& !IsPlayerInFrac(playerid, 5)&& !IsPlayerInFrac(playerid, 6)&& !IsPlayerInFrac(playerid, 7)&& !IsPlayerInFrac(playerid, 8)&& !IsPlayerInFrac(playerid, 9)&& !IsPlayerInFrac(playerid, 10)&& !IsPlayerInFrac(playerid, 11)&& !IsPlayerInFrac(playerid, 12)&& !IsPlayerInFrac(playerid, 13)&& !IsPlayerInFrac(playerid, 14)&& !IsPlayerInFrac(playerid, 14)&& !IsPlayerInFrac(playerid, 15)&& !IsPlayerInFrac(playerid, 16)&& !IsPlayerInFrac(playerid, 17)&& !IsPlayerInFrac(playerid, 18)&& !IsPlayerInFrac(playerid, 19)&& !IsPlayerInFrac(playerid, 20)&& !IsPlayerInFrac(playerid, 21)&& !IsPlayerInFrac(playerid, 23)&& !IsPlayerInFrac(playerid, 24)&&
    {
    SendClientMessage(playerid, COLOR_GREY, " Du bist kein Leader einer Fraktion !");
    return 1;
    }
    if(PlayerInfo[playerid][pRank] < 5)
    {
    SendClientMessage(playerid, COLOR_GREY, " Du brauchst Rang 5 !");
    return 1;
    }
    GetPlayerName(playerid, sendername, sizeof(sendername));
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' '))
    {
    idx++;
    }
    new offset = idx;
    new result[64];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
    result[idx - offset] = cmdtext[idx];
    idx++;
    }
    result[idx - offset] = EOS;
    if(!strlen(result))
    {
    SendClientMessage(playerid, COLOR_GRAD2, "Benutze: (/gov)ernment [text]");
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Los Santos Police Department ___________|");
    if(PlayerInfo[playerid][pLeader] == 1)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Federal Bureau of Investigation ___________|");
    if(PlayerInfo[playerid][pLeader] == 2)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ United States of Army ___________|");
    if(PlayerInfo[playerid][pLeader] == 3)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Notdienst ___________|");
    if(PlayerInfo[playerid][pLeader] == 4)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ La Cosa Nostra ___________|");
    if(PlayerInfo[playerid][pLeader] == 5)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Yakuza ___________|");
    if(PlayerInfo[playerid][pLeader] == 6)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Regierung ___________|");
    if(PlayerInfo[playerid][pLeader] == 7)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Hitman Agency ___________|");
    if(PlayerInfo[playerid][pLeader] == 8)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Center News Network ___________|");
    if(PlayerInfo[playerid][pLeader] == 9)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Taxi Company ___________|");
    if(PlayerInfo[playerid][pLeader] == 10)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Fahrschule ___________|");
    if(PlayerInfo[playerid][pLeader] == 11)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Triaden ___________|");
    if(PlayerInfo[playerid][pLeader] == 12)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Grove Street Family ___________|");
    if(PlayerInfo[playerid][pLeader] == 13)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Front Yard Ballas ___________|");
    if(PlayerInfo[playerid][pLeader] == 14)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Biker Club ___________|");
    if(PlayerInfo[playerid][pLeader] == 15)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Vagos ___________|");
    if(PlayerInfo[playerid][pLeader] == 16)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Atzecas ___________|");
    if(PlayerInfo[playerid][pLeader] == 17)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Rifas ___________|");
    if(PlayerInfo[playerid][pLeader] == 18)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Red Soldiers ___________|");
    if(PlayerInfo[playerid][pLeader] == 19)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Terrorist ___________|");
    if(PlayerInfo[playerid][pLeader] == 1)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Wheelman Agency ___________|");
    if(PlayerInfo[playerid][pLeader] == 21)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Brigada ___________|");
    if(PlayerInfo[playerid][pLeader] == 23)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }
    SendClientMessageToAll(COLOR_WHITE, "|___________ Ordnungsamt ___________|");
    if(PlayerInfo[playerid][pLeader] == 24)
    {
    format(string, sizeof(string), "Bundespräsident %s: %s", sendername, result);
    }
    return 1;
    }


    Mein Gov System [ Die Namen wollte ich noch ändern also diese Bundespräsident; wollte ich Editieren

  • Es ist ja kein Wunder, dass der Compiler abstürzt.
    Die erste if-Abfrage endet mit einem &&, die Klammersetzung ist wirr und irgendwie.. seltsam.
    Würde dir raten dein System etwas abzuändern, warum den Leaderrank auf die Fraktion beziehen? Sag doch lieber "PlayerInfo[playerid][pLeader] = 1/0".
    Andernfalls kann jemand Leader der Fraktion 1 sein, gleichzeitig aber in Fraktion 2 sein.
    Ebenfalls würde ich die Ranknamen extern, einem Enum oder via Datenbank auslesen, abspeichern, genau wie die Fraktionsnamen, dann könntest du das schnell so schreiben:

    Code
    if(PlayerInfo[playerid][pFaction] == 0) return Fehlermeldung;
    else if(PlayerInfo[playerid][pRank] < 5 || PlayerInfo[playerid][pLeader] == 0) return Fehlermeldung;
    else {
    format(string, sizeof(string), "|____ %s ____|", GetPlayerFactionName(playerid));
    SendClientMessageToAll(farbe, string);
    format(string, sizeof(string), "%s %s: %s", GetPlayerRankName(playerid), sendername, result);
    SendClientMessageToAll(farbe, string);
    }


    Das war jetzt ganz schnell zusammengeschrieben, dürfte aber an der Stelle kein Problem mehr für dich sein den Rest zusammenzubauen.
    Wenn doch würde ich dir raten deine PAWNO-Grundlagen aufzufrischen :)

    • Offizieller Beitrag

    Ich habe dein Befehl mal ein wenig gekürzt und angepasst, müsste so funktionieren (Ungetestet)

    if(strcmp(cmd, "/government", true) == 0 || strcmp(cmd, "/gov", true) == 0)
    {
    if(!IsPlayerConnected(playerid))return 1;
    if(IsPlayerInFrac(playerid, 0)return SendClientMessage(playerid, COLOR_GREY, " Du bist kein Leader einer Fraktion !");
    if(PlayerInfo[playerid][pRank] < 5)return SendClientMessage(playerid, COLOR_GREY, " Du brauchst Rang 5 !");
    GetPlayerName(playerid, sendername, sizeof(sendername));
    new length = strlen(cmdtext);
    while ((idx < length) && (cmdtext[idx] <= ' '))
    {
    idx++;
    }
    new offset = idx;
    new result[64];
    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
    {
    result[idx - offset] = cmdtext[idx];
    idx++;
    }
    result[idx - offset] = EOS;
    if(!strlen(result))return SendClientMessage(playerid, COLOR_GRAD2, "Benutze: (/gov)ernment [Text]");
    new string[256];
    format(string, sizeof(string), "|___________ %s ___________|", GetFracName(playerid));
    SendClientMessageToAll(COLOR_WHITE, string);
    format(string, sizeof(string), "%s: %s", sendername, result);
    SendClientMessageToAll(COLOR_WHITE, string)
    return 1;
    }


    stock GetFracName(playerid)
    {
    new fname[32];
    switch(PlayerInfo[playerid][pFraction])
    {
    case 0:{fname="Zivilist";}
    case 1:{fname="Los Santos Police Department";}
    case 2:{fname="Federal Bureau of Investigation";}
    case 3:{fname="United States of Army";}
    case 4:{fname="Notdienst";}
    case 5:{fname="La Cosa Nostra";}
    case 6:{fname="Yakuza";}
    case 7:{fname="Regierung";}
    case 8:{fname="Hitman Agency";}
    case 9:{fname="Center News Network";}
    case 10:{fname="Taxi Company";}
    case 11:{fname="Fahrschule";}
    case 12:{fname="Triaden";}
    case 13:{fname="Grove Street Family";}
    case 14:{fname="Front Yard Ballas";}
    case 15:{fname="Biker Club";}
    case 16:{fname="Vagos";}
    case 17:{fname="Atzecas";}
    case 18:{fname="Rifas";}
    case 19:{fname="Red Soldiers";}
    case 20:{fname="Terrorist";}
    case 21:{fname="Wheelman Agency";}
    case 22:{fname="Brigada";}
    case 23:{fname="Ordnungsamt";}
    }
    return fname;
    }

  • @Whice.



    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23345) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23346) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23347) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23348) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23349) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23350) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23352) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23353) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23354) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23356) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23357) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23358) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23371) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23391) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23411) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23416) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23421) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23426) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23431) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23435) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23441) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23446) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23451) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23456) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23461) : error 079: inconsistent return types (array & non-array)
    C:\Users\korha\Desktop\German-Elite-Reallife\gamemodes\German-Elite-Reallife.pwn(23466) : error 079: inconsistent return types (array & non-array)


    Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase



    26 Errors.