Text Returnen?

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 mal ne Frage:


    Wenn ich ne "if" Abfrage in nem Public starte, will ich einen Text "RETURNEN".
    Mein Code sieht so aus:
    if(frak == 0){ return "-"; }
    Allerdings will mein Compiler dann nicht so ganz... Jemand ne lösung?




    MfG Firer

  • public GetPlayerRank(playerid)
    {
    new frak = GetPVarInt(playerid,"team");
    new rank = GetPVarInt(playerid,"rank");
    if(frak == 0){ return "-"; }
    if(frak == 1)
    {
    if(rank == 1){ return "Auszubildener"; }
    }
    return 1;
    }

    Ist halt erstmal um zu schauen, ob ich es irgendwie hinkriege^^


    //EDIT:
    Durch Maddins hilfe hab ichs mal mit nem String versucht:
    public GetPlayerRank(playerid)
    {
    new frak = GetPVarInt(playerid,"team");
    new rank = GetPVarInt(playerid,"rank");
    new string[50];
    if(frak == 0){ format(string,sizeof(string),"-"); return string; }
    if(frak == 1)
    {
    if(rank == 1){format(string,sizeof(string),"Auszubildener"); return string; }
    }
    return 1;
    }

    Allerdings bekomme ich Errors:
    C:\Dokumente und Einstellungen\Alex\Desktop\SOUL-GTA\gamemodes\sf.pwn(1612) : error 090: public functions may not return arrays (symbol "GetPlayerRank")
    C:\Dokumente und Einstellungen\Alex\Desktop\SOUL-GTA\gamemodes\sf.pwn(1615) : error 090: public functions may not return arrays (symbol "GetPlayerRank")
    C:\Dokumente und Einstellungen\Alex\Desktop\SOUL-GTA\gamemodes\sf.pwn(1617) : error 079: inconsistent return types (array & non-array)


    //EDIT2: Hahahahaha - Ich brauch nen Stock und kein Public - Das ist zu Failed^^
    /CLOSE/

    Einmal editiert, zuletzt von Firerfan ()

  • Gute Idee, schau mal obs so funzt:

    stock GetPlayerRank(playerid)
    {
    new frak = GetPVarInt(playerid,"team");
    new rank = GetPVarInt(playerid,"rank");
    new string[50];
    if(frak == 0){ string = "-"; }
    if(frak == 1)
    {
    if(rank == 1) { string = "Auszubildener"); }
    }
    return string;
    }

    //Edit mkay wenne es hast...