Playername in Zwischenspeicher.

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
  • Ich möchte gerne bei einem Befehl, das der Name in einer Zwischenablage gespeichert wird, und das ich ihn dann wieder abrufen kann:
    z.B


    Aktueller Name: VitaminZ
    Ich ändere: [ADMIN]VitaminZ oder VitaminX
    danach wieder auf VitaminZ wenn ich den Befehl eingebe.



    Wie geht das am besten?
    Bei mir crasht immer der Server, ich hoffe ihr könnt mir helfen!


    Greetz.

  • Magst du es mir i.wie erklären?


    z.B ein Code, da ich das garnicht kann:s


    new PlayerName[MAX_PLAYERS][MAX_PLAYER_NAME];
    //Onplayerconnect
    GetPlayerName(playerid, PlayerName[playerid], MAX_PLAYER_NAME);


    //benutzung
    format(string, sizeof string, "Mein Name ist %s", PlayerName[playerid]);


    //Wichtig
    Bei Changename musst du PlayerName auch ändern..!

  • new PlayerTrueName[MAX_PLAYERS][MAX_PLAYER_NAME];
    if(strcmp(cmd, "/swatduty", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    GetPlayerName(playerid, sendername, sizeof(sendername));
    if (PlayerInfo[playerid][pMember] == 22 || PlayerInfo[playerid][pLeader] == 22)
    {
    if (IsPlayerInRangeOfPoint(playerid,3.0,254.2361,76.9261,1003.6406) ||IsPlayerInRangeOfPoint(playerid,3.0, 217.5230,184.4352,1003.0313)
    || PlayerInfo[playerid][pLocal] != 255)
    {
    if(OnDuty[playerid]==0)
    {
    SetPlayerSkin(playerid,285);
    OnDuty[playerid] = 1;
    new DerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,DerName,sizeof(DerName));
    PlayerTrueName[playerid] = DerName;


    new rand = random(19);
    if(rand == 0)return SetPlayerName(playerid,"Alpha");
    else if(rand == 1)return SetPlayerName(playerid,"Beta");
    else if(rand == 2)return SetPlayerName(playerid,"Gamma");
    else if(rand == 3)return SetPlayerName(playerid,"Omega");
    else if(rand == 4)return SetPlayerName(playerid,"Delta");
    else if(rand == 5)return SetPlayerName(playerid,"Epsilon");
    else if(rand == 6)return SetPlayerName(playerid,"Zeta");
    else if(rand == 7)return SetPlayerName(playerid,"Eta");
    else if(rand == 8)return SetPlayerName(playerid,"Theta");
    else if(rand == 9)return SetPlayerName(playerid,"Iota");
    else if(rand == 10)return SetPlayerName(playerid,"Kappa");
    else if(rand == 11)return SetPlayerName(playerid,"Lambda");
    else if(rand == 12)return SetPlayerName(playerid,"Omikron");
    else if(rand == 13)return SetPlayerName(playerid,"Rho");
    else if(rand == 14)return SetPlayerName(playerid,"Sigma");
    else if(rand == 15)return SetPlayerName(playerid,"Tau");
    else if(rand == 16)return SetPlayerName(playerid,"Ypsilon");
    else if(rand == 17)return SetPlayerName(playerid,"Psi");
    else if(rand == 18)return SetPlayerName(playerid,"Omega")
    }
    else if(OnDuty[playerid]==1)
    {
    SetPlayerName(playerid,PlayerTrueName[playerid]);
    SetPlayerSkin(playerid,280);
    ResetPlayerWeapons(giveplayerid);
    PlayerInfo[giveplayerid][pGun1] = 0; PlayerInfo[giveplayerid][pAmmo1] = 0;
    PlayerInfo[giveplayerid][pGun2] = 0; PlayerInfo[giveplayerid][pAmmo2] = 0;
    PlayerInfo[giveplayerid][pGun3] = 0; PlayerInfo[giveplayerid][pAmmo3] = 0;
    PlayerInfo[giveplayerid][pGun4] = 0; PlayerInfo[giveplayerid][pAmmo4] = 0;
    SetPlayerColor(playerid,COLOR_WHITE); // white
    OnDuty[playerid] = 0;
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD2, "Du bist in keiner Umkleide !");
    return 1;
    }
    }
    }
    return 1;
    }


    Bei den Funktionen: SetPlayerName(playerid,PlayerTrueName[playerid]);
    um den Namen wieder zu ändern.


    Wenn ich alleien drauf bin und Duty gehe klappt, es wenn jemand Joint geht der Server down!

  • versuch mal ein kleineren string also rund 19 zeichen , da samp einen namen bis zu 20 Zeichen unterstützt und
    MAX_PLAYER_NAME enthält 24 Zeichen.




    und GetPlayerName kannst du auch vereinfachen


    GetPlayerName(playerid,PlayerTrueName[playerid],19);


    weil was anderes würde mir nicht in den sinn kommen du kannst ja nochmal das
    crashdetekt plugin drüber laufen lassen. Aber grundlegend ist an SetPlayerName nix falsch



  • Error:
    if(strcmp(cmd, "/swatduty", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    GetPlayerName(playerid, sendername, sizeof(sendername));
    if (PlayerInfo[playerid][pMember] == 22 || PlayerInfo[playerid][pLeader] == 22)
    {
    if (IsPlayerInRangeOfPoint(playerid,3.0,254.2361,76.9261,1003.6406) ||IsPlayerInRangeOfPoint(playerid,3.0, 217.5230,184.4352,1003.0313)
    || PlayerInfo[playerid][pLocal] != 255)
    {
    if(OnDuty[playerid]==0)
    {
    SetPlayerSkin(playerid,285);
    OnDuty[playerid] = 1;
    new DerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,PlayerTrueName[playerid],19);
    PlayerTrueName[playerid] = DerName;


    new rand = random(19);
    if(rand == 0)return SetPlayerName(playerid,"Alpha");
    else if(rand == 1)return SetPlayerName(playerid,"Beta");
    else if(rand == 2)return SetPlayerName(playerid,"Gamma");
    else if(rand == 3)return SetPlayerName(playerid,"Omega");
    else if(rand == 4)return SetPlayerName(playerid,"Delta");
    else if(rand == 5)return SetPlayerName(playerid,"Epsilon");
    else if(rand == 6)return SetPlayerName(playerid,"Zeta");
    else if(rand == 7)return SetPlayerName(playerid,"Eta");
    else if(rand == 8)return SetPlayerName(playerid,"Theta");
    else if(rand == 9)return SetPlayerName(playerid,"Iota");
    else if(rand == 10)return SetPlayerName(playerid,"Kappa");
    else if(rand == 11)return SetPlayerName(playerid,"Lambda");
    else if(rand == 12)return SetPlayerName(playerid,"Omikron");
    else if(rand == 13)return SetPlayerName(playerid,"Rho");
    else if(rand == 14)return SetPlayerName(playerid,"Sigma");
    else if(rand == 15)return SetPlayerName(playerid,"Tau");
    else if(rand == 16)return SetPlayerName(playerid,"Ypsilon");
    else if(rand == 17)return SetPlayerName(playerid,"Psi");
    else if(rand == 18)return SetPlayerName(playerid,"Omega")
    }
    else if(OnDuty[playerid]==1)
    {
    SetPlayerName(playerid,PlayerTrueName[playerid]);
    SetPlayerSkin(playerid,280);
    ResetPlayerWeapons(giveplayerid);
    PlayerInfo[giveplayerid][pGun1] = 0; PlayerInfo[giveplayerid][pAmmo1] = 0;
    PlayerInfo[giveplayerid][pGun2] = 0; PlayerInfo[giveplayerid][pAmmo2] = 0;
    PlayerInfo[giveplayerid][pGun3] = 0; PlayerInfo[giveplayerid][pAmmo3] = 0;
    PlayerInfo[giveplayerid][pGun4] = 0; PlayerInfo[giveplayerid][pAmmo4] = 0;
    SetPlayerColor(playerid,COLOR_WHITE); // white
    OnDuty[playerid] = 0;
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD2, "Du bist in keiner Umkleide !");
    return 1;
    }
    }
    }
    return 1;
    }


    Wurde ; erwartet aber } gefunden, sagt der Error.


    Fehler:
    new rand = random(19);

  • Jetzt geht der Server direkt nach dem Befehl aus . .


    if(strcmp(cmd, "/swatduty", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    GetPlayerName(playerid, sendername, sizeof(sendername));
    if (PlayerInfo[playerid][pMember] == 22 || PlayerInfo[playerid][pLeader] == 22)
    {
    if (IsPlayerInRangeOfPoint(playerid,3.0,254.2361,76.9261,1003.6406) ||IsPlayerInRangeOfPoint(playerid,3.0, 217.5230,184.4352,1003.0313)
    || PlayerInfo[playerid][pLocal] != 255)
    {
    if(OnDuty[playerid]==0)
    {
    SetPlayerSkin(playerid,285);
    OnDuty[playerid] = 1;
    new DerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,PlayerTrueName[playerid],19);
    PlayerTrueName[playerid] = DerName;


    new rand = random(19);
    if(rand == 0)return SetPlayerName(playerid,"Alpha");
    else if(rand == 1)return SetPlayerName(playerid,"Beta");
    else if(rand == 2)return SetPlayerName(playerid,"Gamma");
    else if(rand == 3)return SetPlayerName(playerid,"Omega");
    else if(rand == 4)return SetPlayerName(playerid,"Delta");
    else if(rand == 5)return SetPlayerName(playerid,"Epsilon");
    else if(rand == 6)return SetPlayerName(playerid,"Zeta");
    else if(rand == 7)return SetPlayerName(playerid,"Eta");
    else if(rand == 8)return SetPlayerName(playerid,"Theta");
    else if(rand == 9)return SetPlayerName(playerid,"Iota");
    else if(rand == 10)return SetPlayerName(playerid,"Kappa");
    else if(rand == 11)return SetPlayerName(playerid,"Lambda");
    else if(rand == 12)return SetPlayerName(playerid,"Omikron");
    else if(rand == 13)return SetPlayerName(playerid,"Rho");
    else if(rand == 14)return SetPlayerName(playerid,"Sigma");
    else if(rand == 15)return SetPlayerName(playerid,"Tau");
    else if(rand == 16)return SetPlayerName(playerid,"Ypsilon");
    else if(rand == 17)return SetPlayerName(playerid,"Psi");
    else if(rand == 18)return SetPlayerName(playerid,"Omega");
    }
    else if(OnDuty[playerid]==1)
    {
    SetPlayerName(playerid,PlayerTrueName[playerid]);
    SetPlayerSkin(playerid,280);
    ResetPlayerWeapons(giveplayerid);
    PlayerInfo[giveplayerid][pGun1] = 0; PlayerInfo[giveplayerid][pAmmo1] = 0;
    PlayerInfo[giveplayerid][pGun2] = 0; PlayerInfo[giveplayerid][pAmmo2] = 0;
    PlayerInfo[giveplayerid][pGun3] = 0; PlayerInfo[giveplayerid][pAmmo3] = 0;
    PlayerInfo[giveplayerid][pGun4] = 0; PlayerInfo[giveplayerid][pAmmo4] = 0;
    SetPlayerColor(playerid,COLOR_WHITE); // white
    OnDuty[playerid] = 0;
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD2, "Du bist in keiner Umkleide !");
    return 1;
    }
    }
    }
    return 1;
    }

  • Wie mache ich das jetzt richtig, du schreibst i.welche Codes ohne das ich weiss wie ich diese benutze . .


    if(strcmp(cmd, "/swatduty", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    if (PlayerInfo[playerid][pMember] == 22 || PlayerInfo[playerid][pLeader] == 22)
    {
    if (IsPlayerInRangeOfPoint(playerid,3.0,254.2361,76.9261,1003.6406) ||IsPlayerInRangeOfPoint(playerid,3.0, 217.5230,184.4352,1003.0313)
    || PlayerInfo[playerid][pLocal] != 255)
    {
    if(OnDuty[playerid]==0)
    {
    SetPlayerSkin(playerid,285);
    OnDuty[playerid] = 1;
    GetPlayerName(playerid,PlayerTrueName[playerid],19);
    new rand = random(19);
    if(rand == 0)return SetPlayerName(playerid,"Alpha");
    else if(rand == 1)return SetPlayerName(playerid,"Beta");
    else if(rand == 2)return SetPlayerName(playerid,"Gamma");
    else if(rand == 3)return SetPlayerName(playerid,"Omega");
    else if(rand == 4)return SetPlayerName(playerid,"Delta");
    else if(rand == 5)return SetPlayerName(playerid,"Epsilon");
    else if(rand == 6)return SetPlayerName(playerid,"Zeta");
    else if(rand == 7)return SetPlayerName(playerid,"Eta");
    else if(rand == 8)return SetPlayerName(playerid,"Theta");
    else if(rand == 9)return SetPlayerName(playerid,"Iota");
    else if(rand == 10)return SetPlayerName(playerid,"Kappa");
    else if(rand == 11)return SetPlayerName(playerid,"Lambda");
    else if(rand == 12)return SetPlayerName(playerid,"Omikron");
    else if(rand == 13)return SetPlayerName(playerid,"Rho");
    else if(rand == 14)return SetPlayerName(playerid,"Sigma");
    else if(rand == 15)return SetPlayerName(playerid,"Tau");
    else if(rand == 16)return SetPlayerName(playerid,"Ypsilon");
    else if(rand == 17)return SetPlayerName(playerid,"Psi");
    else if(rand == 18)return SetPlayerName(playerid,"Omega");
    }
    else if(OnDuty[playerid]==1)
    {
    SetPlayerName(playerid,PlayerTrueName[playerid]);
    SetPlayerSkin(playerid,280);
    ResetPlayerWeapons(giveplayerid);
    PlayerInfo[giveplayerid][pGun1] = 0; PlayerInfo[giveplayerid][pAmmo1] = 0;
    PlayerInfo[giveplayerid][pGun2] = 0; PlayerInfo[giveplayerid][pAmmo2] = 0;
    PlayerInfo[giveplayerid][pGun3] = 0; PlayerInfo[giveplayerid][pAmmo3] = 0;
    PlayerInfo[giveplayerid][pGun4] = 0; PlayerInfo[giveplayerid][pAmmo4] = 0;
    SetPlayerColor(playerid,COLOR_WHITE); // white
    OnDuty[playerid] = 0;
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD2, "Du bist in keiner Umkleide !");
    return 1;
    }
    }
    }
    return 1;
    }


    das erste GetPlayerName war unnötig du verwendest dieses nicht mal und zum zweiten teil
    setzt du den string auf 0 DerName keine zeichen enthält daher crashed der server

  • Befehl geht eig, aber jetzt das Problem wenn ich SWAT Duty gehe und ein anderer verlieren alle ihre Waffen..


    vllt:
    for(new i = 0; i < MAX_PLAYERS; i++)


    Oder so etwas?


    also wenn der command dann nicht gegangen wäre würde ich auch nicht mehr weiter wissen da das mit dem mehr als 20 zeilen nur
    vllt in ausnahme fällen crashed das einzigste was dabei passieren können bei zu großen strings ist das sich der name verzerrt
    also sonderzeichen enthält.
    um mich oben nochmal zu korrigieren.


    zu dem setzt du die waffen von einer unbekannten id(bestimmt nicht gewollte id) auf 0
    giveplayerid
    PlayerInfo[giveplayerid][pGun4] = 0;

  • wie mache ich das anders?:D
    Also ID 0 bug fixxen?


    Und noch ein Bug ka.
    Ich will das der Spieler gekickt wird, wenn er den Namen Psi etc hat wenn er Connected:
    if(GetPlayerName[playerid] == Psi)
    {
    SendClientMessage(playerid,ROT,"Dies ist ein SWAT Name, bitte wähle einen anderen Namen.");
    Kick(playerid);
    }


    Ich weiss es ist falsch, aber ich habe schon etliches Probiert und bin dann dabei gelandet.
    Klappt auch net :)