/stats befehl

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
  • Huhu Brotfische



    Ich habe da einen /stats befehl, den aber nur Admins ausführen können:


    else if(strcmp("/stats", cmd, true) == 0)
    {
    if (!hasPermission(playerid, PER_FREEZE)) return 1;
    if(strcount(cmdtext, ' ') < 2) return SendClientMessage(playerid, COLOR_GREY,"USAGE: /stats [playername/id]");
    tmp = strtok(cmdtext, idx);
    new giveplayer = ReturnUser(tmp, playerid);
    if (IsPlayerConnected(giveplayer))
    {


    new Float:hp,Float:armour,Float:vhp;
    new ip[20];
    new ping = GetPlayerPing(giveplayer);
    new skin = GetPlayerSkin(giveplayer);
    new bullets[12];
    new weapons[12];
    new weapname[12][50];
    new handweapname[50];
    new pstate[50];
    new flag[20];
    new gender[10];
    new State = GetPlayerState(giveplayer);
    if (State == 1) pstate = "On Foot";
    else if (State == 2) pstate = "Driver";
    else if (State == 3) pstate = "Passenger";
    else if (State == 9) pstate = "Spectating";
    else pstate = "Not Available";
    if (PlayerInfo[giveplayer][pFlag] == 1) flag = "Yes";
    else if (PlayerInfo[giveplayer][pFlag] == 2) flag = "Yes-Kicked";
    else flag = "No";
    if (PlayerExtraInfo[playerid][pxSex] == 0) gender = "Male";
    else if (PlayerExtraInfo[playerid][pxSex] == 1) gender = "Female";
    format(string,sizeof(string),"----------------------------_____[%i]%s_____----------------------------",giveplayer,PlayerInfo[giveplayer][pName]);
    SendClientMessage(playerid,COLOR_YELLOW,string);
    SendClientMessage(playerid, COLOR_RED,"--?Stats");
    GetPlayerHealth(giveplayer,hp);
    GetPlayerArmour(giveplayer,armour);
    GetWeaponName(GetPlayerWeapon(giveplayer),handweapname,50);
    if (IsPlayerInAnyVehicle(giveplayer)) GetVehicleHealth(GetPlayerVehicleID(giveplayer),vhp);
    GetPlayerIp(giveplayer,ip,sizeof(ip));
    format(string,sizeof(string),"Health: %.2f | Armour: %.2f | Money: $%.2f($%.2f) | Bank Money: $%.2f",hp,armour,FloatMoney(PlayerInfo[giveplayer][pCash]),FloatMoney(GetPlayerMoney(giveplayer)),FloatMoney(PlayerExtraInfo[giveplayer][pxBank]));
    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    format(string,sizeof(string),"Hand Weapon: %s(%d) | IP: %s | Ping: %d | Skin: %d | Warns: %d",handweapname,GetPlayerAmmo(giveplayer),ip,ping,skin,PlayerExtraInfo[giveplayer][pxWarns]);
    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    if (IsPlayerInAnyVehicle(giveplayer)) format(string,sizeof(string),"Vehicle: %s | Vehicle Health: %.0f | State: %s | Faction: %s(%d) | Faction Rank: %d | Flag: %s",GetVehicleName(GetPlayerVehicleID(giveplayer)),vhp,pstate,FactionInfo[PlayerInfo[giveplayer][pFaction]][fName],PlayerInfo[giveplayer][pFaction], PlayerInfo[giveplayer][pFRank],flag);
    else format(string,sizeof(string),"Vehicle: X | Vehicle Health: X | State: %s | Faction: %s(%d) | Faction Rank: %d | Flag: %s",pstate,FactionInfo[PlayerInfo[giveplayer][pFaction]][fName],PlayerInfo[giveplayer][pFaction], PlayerInfo[giveplayer][pFRank],flag);
    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    format(string,sizeof(string),"Job: %s | Job ID: %d | Job Rank: %s | Job Rank ID: %d | Gender: %s",FactionInfo[PlayerInfo[giveplayer][pJobId]][fName],PlayerInfo[giveplayer][pJobId],FactionRanks[PlayerInfo[giveplayer][pJobId]][PlayerInfo[giveplayer][pJRank]][rName],PlayerInfo[giveplayer][pJRank],gender);
    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    GetPlayerWeaponData(giveplayer,1,weapons[0],bullets[0]);
    GetPlayerWeaponData(giveplayer,2,weapons[1],bullets[1]);
    GetPlayerWeaponData(giveplayer,3,weapons[2],bullets[2]);
    GetPlayerWeaponData(giveplayer,4,weapons[3],bullets[3]);
    GetPlayerWeaponData(giveplayer,5,weapons[4],bullets[4]);
    GetPlayerWeaponData(giveplayer,6,weapons[5],bullets[5]);
    GetPlayerWeaponData(giveplayer,7,weapons[6],bullets[6]);
    GetPlayerWeaponData(giveplayer,8,weapons[7],bullets[7]);
    GetPlayerWeaponData(giveplayer,9,weapons[8],bullets[8]);
    GetPlayerWeaponData(giveplayer,10,weapons[9],bullets[9]);
    GetPlayerWeaponData(giveplayer,11,weapons[10],bullets[10]);
    GetPlayerWeaponData(giveplayer,12,weapons[11],bullets[11]);
    GetWeaponName(weapons[0],weapname[0],50);
    GetWeaponName(weapons[1],weapname[1],50);
    GetWeaponName(weapons[2],weapname[2],50);
    GetWeaponName(weapons[3],weapname[3],50);
    GetWeaponName(weapons[4],weapname[4],50);
    GetWeaponName(weapons[5],weapname[5],50);
    GetWeaponName(weapons[6],weapname[6],50);
    GetWeaponName(weapons[7],weapname[7],50);
    GetWeaponName(weapons[8],weapname[8],50);
    GetWeaponName(weapons[9],weapname[9],50);
    GetWeaponName(weapons[10],weapname[10],50);
    GetWeaponName(weapons[11],weapname[11],50);
    for(new b = 0; b < 12; b++) if (bullets[b] == 65535) bullets[b] = 0;
    SendClientMessage(playerid, COLOR_RED,"--?Weapons");
    format(string,sizeof(string),"%s(0) - %s(%d) - %s(%d) - %s(%d) - %s(%d) - %s(%d)",weapname[0],weapname[1],bullets[1],weapname[2],bullets[2],weapname[3],bullets[3],weapname[4],bullets[4],weapname[5],bullets[5]);
    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    format(string,sizeof(string),"%s(%d) - %s(%d) - %s(%d) - %s(0) - %s(0) - %s(0)",weapname[6],bullets[6],weapname[7],bullets[7],weapname[8],bullets[8],weapname[9],weapname[10],weapname[11]);
    SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
    SendClientMessage(playerid, COLOR_RED,"--?Items");
    new itemcount;
    for(new i = 0; i < MAX_ITEMSLOTS; i++)
    {
    if(PlayerItemsInfo[giveplayer][i][piSQLId] != INVALID_SQL_ID)
    {
    itemcount++;
    format(string, sizeof(string), "%s", BaseProductInfo[PlayerItemsInfo[giveplayer][i][piBaseProductId]][bpName]);
    SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
    }
    }
    }
    return 1;
    }


    Nun möchte ich es so haben, das wenn ein Spieler /stats macht, nur seine eigenen stats kommt


    Ich weiß leider nicht was ich da ändern soll -.-


    Danke im vorraus

  • Hmm eigentlich ist in deinem Script garnichts davon, das es nur Admins nutzen können aber vieleicht habe ich mich verguckt ich probier dir mal zu helfen.


    Ins forward schreibst du:



    forward ShowStats(playerid,targetid);


    Guck mal ob du public showstats bei dir hast. Oder nur stats sollte das Fehlen schreib mir nochma ne Pn kann hier nicht mehr als 10.000 Zeichen machen und deshalb nicht mit einfügen :(



    Dann erstellst du den Befehl:
    if (strcmp(cmd, "/stats", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    if (gPlayerLogged[playerid] != 0)
    {
    ShowStats(playerid,playerid);
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD1, "Du bist nicht eingeloggt!");
    }
    }
    return 1;



    Und wenn du noch den AdminBefehl haben willst um andere SPieler zu checken:


    if (strcmp(cmd, "/check", true) == 0)
    {
    if(IsPlayerConnected(playerid))
    {
    if (PlayerInfo[playerid][pAdmin] >= 1)
    {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
    SendClientMessage(playerid, COLOR_GRAD1, "Verwendung: /check [spielerid/teildesnamens]");
    return 1;
    }
    //giveplayerid = strval(tmp);
    giveplayerid = ReturnUser(tmp);
    if(IsPlayerConnected(giveplayerid))
    {
    if(giveplayerid != INVALID_PLAYER_ID)
    {
    ShowStats(playerid,giveplayerid);
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD1, "Diesen Spieler gibt es nicht!");
    }
    }
    else
    {
    SendClientMessage(playerid, COLOR_GRAD1, "Du bist kein Admin!");
    }
    }
    return 1;


    Ich hoffe ich konnte helfen =)