Hat jemand von euch Ahnung wie man den User mit den am meisten kills abfragen kann ? bzw Nach den am meisten kills sortiert..
Zuerst steht der mit dem am meisten kills dann der zweite ect..
Definierte Variabel: Spieler[playerid][pKills]
Hat jemand von euch Ahnung wie man den User mit den am meisten kills abfragen kann ? bzw Nach den am meisten kills sortiert..
Zuerst steht der mit dem am meisten kills dann der zweite ect..
Definierte Variabel: Spieler[playerid][pKills]
Das kommt darauf an.
Willst du wissen, wer momentan am Meisten kills auf dem Server hat der online ist oder allgemein?
Wer online ist einfach so:
new id;
for(new i,old; i<MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(pInfo[i][pKills] >= old) old = pInfo[i][pKills],id=i;
}
printf("Der Spieler mit den meisten Kills ist ID: %d | Kills: %d",id,pInfo[id][pKills]);
Bei dem Allgemein, kommt es auf dein Speicherungssystem an
mfg.
Ich will nach dem am meisten mit kills hat sortiert haben .. zB: beim Gangwar kämpfen ja 2 Fraktionen gegeneinander und dann soll halt ermittelt werden wer alles am meisten kills hat. aber nur halt fraktionsweise zB Vagos Max_Mustermann hat 30 kills, Steffen_Blabla hat 12 kills .. ect und das sollte je nach fraktion zu sehen sein.
So ähnlich wie dieser Befehl:
if(strcmp(cmdtext, "/members", true)==0)
{
if(PlayerInfo[playerid][pMember] > 0)
{
SendClientMessage(playerid, COLOR_YELLOW, "===[Aus deiner Fraktion ist Online: ]===");
foreach (Player, i)
{
new mymember;
mymember = PlayerInfo[playerid][pMember];
new myleader;
myleader = PlayerInfo[playerid][pMember];
if(PlayerInfo[i][pMember] == mymember || PlayerInfo[i][pLeader] == myleader)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s [ID:%d][Rang:%d]", sendername,i,PlayerInfo[i][pRank]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
return 1;
}
if(PlayerInfo[playerid][pLeader] > 0)
{
SendClientMessage(playerid, COLOR_YELLOW, "===[Aus deiner Fraktion ist Online: ]===");
foreach (Player, i)
{
new mymember;
mymember = PlayerInfo[playerid][pLeader];
new myleader;
myleader = PlayerInfo[playerid][pLeader];
if(PlayerInfo[i][pMember] == mymember || PlayerInfo[i][pLeader] == myleader)
{
GetPlayerName(i, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s [ID:%d][Rang:%d]", sendername,i,PlayerInfo[i][pRank]);
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
return 1;
}
return 1;
}
Nur das die Member nach den besten, zweitbesten usw untereinander gelistet sind..
kannste es genauer erklären weil ich blick da nichts durch
EDIT: hab das mal so gemacht
stock GetPlayerHighestScores(array[][rankingEnum], left, right)
{
new
tempLeft = left,
tempRight = right,
pivot = array[(left + right) / 2][player_Score],
tempVar
;
while(tempLeft <= tempRight)
{
while(array[tempLeft][player_Score] > pivot) tempLeft++;
while(array[tempRight][player_Score] < pivot) tempRight--;
if(tempLeft <= tempRight)
{
tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
// format(tempVarStr, sizeof(tempVarStr), array[tempLeft][player_Name]); format(array[tempLeft][player_Name], MAX_PLAYER_NAME, array[tempRight][player_Name]); format(array[tempRight][player_Name], MAX_PLAYER_NAME, tempVarStr);
//tempVarStr = array[tempLeft][player_Name], array[tempLeft][player_Name] = array[tempRight][player_Name], array[tempRight][player_Name] = tempVarStr;
tempVar = array[tempLeft][player_Kills], array[tempLeft][player_Kills] = array[tempRight][player_Kills], array[tempRight][player_Kills] = tempVar;
tempVar = array[tempLeft][player_Deaths], array[tempLeft][player_Deaths] = array[tempRight][player_Deaths], array[tempRight][player_Deaths] = tempVar;
tempVar = array[tempLeft][player_Team], array[tempLeft][player_Team] = array[tempRight][player_Team], array[tempRight][player_Team] = tempVar;
tempLeft++, tempRight--;
}
}
if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}
Spieler[playerid][pKills] = Array
quickSort(array, 0, sizeof(array) - 1);
wäre dann:
quickSort(Spieler[playerid][pKills], 0, sizeof(Spieler[playerid][pKills]) - 1);
/edit
Die Funktion ist bereits völlig korrekt, einfach so lassen.
könntest du mal bei mir kurz per teamviewer gucken? ingame wird leider die user nicht angezeigt bzw gelistet.. wenn du zeit hast bitte pn mich
Schick mir einfach mal deine Teamviewer Daten über eine PN, ich schaue was sich da machen lässt.
Um die K/D auszurechnen habe ich halt ne kurzfassung verwendet undzwar playerScores[index][player_Acc] und habe dann diese oben so gleichgesetzt: playerScores[index][player_Acc] = Float:Spieler[i][GWTotalKills]/Float:Spieler[i][GWTotalDeaths];
Nun zeigt er mir diesen warning an: warning 213: tag mismatch
Kann wer helfen?
http://forum.sa-mp.de/index.php?form=Explain
Zitat von TrooperAlles anzeigen
Du hast eine Variable falsch angewandt, indem du beispielsweise versucht hast, einen Float (Kommazahl) in einem Integer (Grade Zahlen) zu speichern.
Wandel die Variable also rechtzeitig um.
String zu Integer -> strval
String zu Float -> floatstr
Integer zu String -> strpack/format
Integer zu Float -> float
Float zu Integer -> floatround
Float zu String -> strpack/format
Willst du die Kills der Top 5 Spieler oder willst du immer den Spieler einer gang mit den größten kills?
Wenn ja brauch ich einen code schnippsel in dem ich sehe was für variablen ein Spieler hat wen er im gangwar ist und wie ich die andere Frak herausfinden kann gegen die gekämpft wird.
Alles anzeigenkannste es genauer erklären weil ich blick da nichts durch
EDIT: hab das mal so gemacht
stock GetPlayerHighestScores(array[][rankingEnum], left, right)
{
new
tempLeft = left,
tempRight = right,
pivot = array[(left + right) / 2][player_Score],
tempVar
;
while(tempLeft <= tempRight)
{
while(array[tempLeft][player_Score] > pivot) tempLeft++;
while(array[tempRight][player_Score] < pivot) tempRight--;
if(tempLeft <= tempRight)
{
tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
// format(tempVarStr, sizeof(tempVarStr), array[tempLeft][player_Name]); format(array[tempLeft][player_Name], MAX_PLAYER_NAME, array[tempRight][player_Name]); format(array[tempRight][player_Name], MAX_PLAYER_NAME, tempVarStr);
//tempVarStr = array[tempLeft][player_Name], array[tempLeft][player_Name] = array[tempRight][player_Name], array[tempRight][player_Name] = tempVarStr;
tempVar = array[tempLeft][player_Kills], array[tempLeft][player_Kills] = array[tempRight][player_Kills], array[tempRight][player_Kills] = tempVar;
tempVar = array[tempLeft][player_Deaths], array[tempLeft][player_Deaths] = array[tempRight][player_Deaths], array[tempRight][player_Deaths] = tempVar;
tempVar = array[tempLeft][player_Team], array[tempLeft][player_Team] = array[tempRight][player_Team], array[tempRight][player_Team] = tempVar;
tempLeft++, tempRight--;
}
}
if(left < tempRight) GetPlayerHighestScores(array, left, tempRight);
if(tempLeft < right) GetPlayerHighestScores(array, tempLeft, right);
}
Alles anzeigenSpieler[playerid][pKills] = Array
quickSort(array, 0, sizeof(array) - 1);
wäre dann:
quickSort(Spieler[playerid][pKills], 0, sizeof(Spieler[playerid][pKills]) - 1);
/edit
Die Funktion ist bereits völlig korrekt, einfach so lassen.
Das empfiehlt sich so nicht, da du somit das ganze Array neu sortierst und sowas möchte man natürlich ungern mit den Userdaten machen deshalb benötigt man dafür ein extra Array
Nunja hab das mal so angepasst, aber das Problem ist die User stehen nicht drauf nach dem GW -.- Textdraw ect klappt aber kein User steht drauf..
Ich habs halt so gemacht auf der linken seite die attacker und auf der rechten die defender, von jeder fraktion sehen die User die Top Score liste nach dem besten sortiert.. Doch kein user kommt auf diese liste drauf..
Und im chat sieht man dann die Top 3 User mit den am meisten Kills (egal ob gegnerische fraktion oder eigene fraktion)
Nun frage an euch, wo hab ich ein fehler gemacht ?
Screen von der Top 5: http://fs1.directupload.net/images/150113/bu7mjwb9.png
stock ShowEndRoundTextDraw(playerid)
{
new p,
playerScores[MAX_PLAYERS][rankingEnum],
names[MAX_PLAYERS][MAX_PLAYER_NAME],
TopString[3][128],
index,
TempZone = GetPlayerFightzone(playerid),
iString[256];
iString = "~r~~h~Name\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tKills\t\t\t\t\tTode\t\t\t\t\tK/D\t\t\t\t\tDmg";
TextDrawSetString(EN_AttackerTitle, iString);
iString = "~b~~h~Name\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tKills\t\t\t\t\tTode\t\t\t\t\tK/D\t\t\t\t\tDmg";
TextDrawSetString(EN_DefenderTitle, iString);
new AttList[256],AttKills[256],AttDeaths[256],AttAcc[256],AttDamage[256],DefList[256],DefKills[256],DefDeaths[256],DefAcc[256],DefDamage[256];
for(new i = 0; i != p; ++i)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i) && GetPVarInt(i,"Eingeloggt") == 1)
{
playerScores[index][player_Team] = GetPlayerFaction(i);
playerScores[index][player_Kills] = Spieler[i][GWTotalKills];
playerScores[index][player_Deaths] = Spieler[i][GWTotalDeaths];
playerScores[index][player_Acc] = floatround(Spieler[i][GWTotalKills]/Spieler[i][GWTotalDeaths], floatround_round);
playerScores[index][player_Score] = floatround(Spieler[i][GWTotalDamage], floatround_round);
format(names[index], MAX_PLAYER_NAME, Spieler[i][pName]);
playerScores[index++][player_ID] = i;
p++;
if(playerScores[i][player_Team] == GetPlayerFaction(GangwarZones[TempZone][fsAttackFaction]))
{
format(AttList, sizeof(AttList), "%s~r~~h~%s~n~", AttList, names[i]);
format(AttKills, sizeof(AttKills), "%s~w~~h~~h~%d~n~", AttKills, playerScores[i][player_Kills]);
format(AttDeaths, sizeof(AttDeaths), "%s~w~~h~~h~%d~n~", AttDeaths, playerScores[i][player_Deaths]);
format(AttAcc, sizeof(AttAcc), "%s~w~~h~~h~%.2f~n~", AttAcc, playerScores[i][player_Acc]);
format(AttDamage, sizeof(AttDamage), "%s~w~~h~~h~%d~n~", AttDamage, playerScores[i][player_Score]);
}
else if(playerScores[i][player_Team] == GetPlayerFaction(GangwarZones[TempZone][fsOwnerFaction]))
{
format(DefList, sizeof(DefList), "%s~b~~h~%s~n~", DefList, names[i]);
format(DefKills, sizeof(DefKills), "%s~w~~h~~h~%d~n~", DefKills, playerScores[i][player_Kills]);
format(DefDeaths, sizeof(DefDeaths), "%s~w~~h~~h~%d~n~", DefDeaths, playerScores[i][player_Deaths]);
format(DefAcc, sizeof(DefAcc), "%s~w~~h~~h~%.2f~n~", DefAcc, playerScores[i][player_Acc]);
format(DefDamage, sizeof(DefDamage), "%s~w~~h~~h~%d~n~", DefDamage, playerScores[i][player_Score]);
}
if(i == 0) format(TopString[0], 128, "1st - %s ({FFFFFF}%d)", names[i], playerScores[i][player_Kills]);
else if(i == 1) format(TopString[1], 128, "2nd - %s ({FFFFFF}%d)", names[i], playerScores[i][player_Kills]);
else if(i == 2) format(TopString[2], 128, "3rd - %s ({FFFFFF}%d)", names[i], playerScores[i][player_Kills]);
}
GetPlayerHighestScores2(playerScores, names, 0, index-1);
}
SendClientMessageToAll(-1, " ");
SendClientMessageToAll(-1, " ");
SendClientMessageToAll(-1, " ");
SendClientMessageToAll(-1, " ");
SendClientMessageToAll(-1, " ");
SendClientMessageToAll(-1, " ");
SendClientMessageToAll(-1, "{FFFFFF}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
SendClientMessageToAll(-1, "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{FFFFFF}Top Players");
SendClientMessageToAll(-1, " ");
SendClientMessageToAll(-1, TopString[0]);
SendClientMessageToAll(-1, TopString[1]);
SendClientMessageToAll(-1, TopString[2]);
SendClientMessageToAll(-1, "{FFFFFF}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
TextDrawSetString(EN_AttackerList, AttList);
TextDrawSetString(EN_AttackerKills, AttKills);
TextDrawSetString(EN_AttackerDeaths, AttDeaths);
TextDrawSetString(EN_AttackerAccuracy, AttAcc);
TextDrawSetString(EN_AttackerDamage, AttDamage);
TextDrawSetString(EN_DefenderList, DefList);
TextDrawSetString(EN_DefenderKills, DefKills);
TextDrawSetString(EN_DefenderDeaths, DefDeaths);
TextDrawSetString(EN_DefenderAccuracy, DefAcc);
TextDrawSetString(EN_DefenderDamage, DefDamage);
TextDrawShowForPlayer(playerid, EN_Attacker);
TextDrawShowForPlayer(playerid, EN_Defender);
TextDrawShowForPlayer(playerid, EN_WhoWon);
TextDrawShowForPlayer(playerid, EN_AttackerTitle);
TextDrawShowForPlayer(playerid, EN_DefenderTitle);
TextDrawShowForPlayer(playerid, EN_AttackerList);
if(MatchEnded == false) TextDrawShowForPlayer(playerid, EN_AttackerKills);
else
{
TextDrawShowForPlayer(playerid, EN_TAttackerKills);
TextDrawSetString(EN_AttackerKills, "");
}
if(MatchEnded == false)TextDrawShowForPlayer(playerid, EN_AttackerDeaths);
else
{
TextDrawShowForPlayer(playerid, EN_TAttackerDeaths);
TextDrawShowForPlayer(playerid, EN_TAttackerRoundsPlayed);
TextDrawSetString(EN_AttackerDeaths, "");
}
if(MatchEnded == false)TextDrawShowForPlayer(playerid, EN_AttackerAccuracy);
else
{
TextDrawShowForPlayer(playerid, EN_TAttackerAccuracy);
TextDrawSetString(EN_AttackerAccuracy, "");
}
if(MatchEnded == false)TextDrawShowForPlayer(playerid, EN_AttackerDamage);
else
{
TextDrawShowForPlayer(playerid, EN_TAttackerDamage);
TextDrawSetString(EN_AttackerDamage, "");
}
TextDrawShowForPlayer(playerid, EN_DefenderList);
if(MatchEnded == false) TextDrawShowForPlayer(playerid, EN_DefenderKills);
else
{
TextDrawShowForPlayer(playerid, EN_TDefenderKills);
TextDrawSetString(EN_DefenderKills, "");
}
if(MatchEnded == false)TextDrawShowForPlayer(playerid, EN_DefenderDeaths);
else
{
TextDrawShowForPlayer(playerid, EN_TDefenderDeaths);
TextDrawShowForPlayer(playerid, EN_TDefenderRoundsPlayed);
TextDrawSetString(EN_DefenderDeaths, "");
}
if(MatchEnded == false)TextDrawShowForPlayer(playerid, EN_DefenderAccuracy);
else
{
TextDrawShowForPlayer(playerid, EN_TDefenderAccuracy);
TextDrawSetString(EN_DefenderAccuracy, "");
}
if(MatchEnded == false)TextDrawShowForPlayer(playerid, EN_DefenderDamage);
else
{
TextDrawShowForPlayer(playerid, EN_TDefenderDamage);
TextDrawSetString(EN_DefenderDamage, "");
}
TextDrawShowForPlayer(playerid, EN_AttackerBox);
TextDrawShowForPlayer(playerid, EN_DefenderBox);
TextDrawShowForPlayer(playerid, EN_DefenderTitleBox);
TextDrawShowForPlayer(playerid, EN_AttackerTitleBox);
TextDrawShowForPlayer(playerid, EN_WhoWonBox);
TextDrawShowForPlayer(playerid, EN_WhoWonTopBar);
TextDrawShowForPlayer(playerid, EN_WhoWonAttBar);
TextDrawShowForPlayer(playerid, EN_WhoWonDefBar);
TextDrawShowForPlayer(playerid, EN_AttackerTextBox);
TextDrawShowForPlayer(playerid, EN_DefenderTextBox);
Spieler[playerid][TextDrawOnScreen] = true;
AttList = "";
AttKills = "";
AttDeaths = "";
AttDamage = "";
AttAcc = "";
DefList = "";
DefKills = "";
DefDeaths = "";
DefDamage = "";
DefAcc = "";
}
stock GetPlayerHighestScores2(array[][rankingEnum], names[][MAX_PLAYER_NAME], left, right)
{
new
tempLeft = left,
tempRight = right,
pivot = array[(left + right) / 2][player_Score],
tempVar,
tempVarStr[MAX_PLAYER_NAME]
;
while(tempLeft <= tempRight)
{
while(array[tempLeft][player_Score] > pivot) tempLeft++;
while(array[tempRight][player_Score] < pivot) tempRight--;
if(tempLeft <= tempRight)
{
tempVar = array[tempLeft][player_Score], array[tempLeft][player_Score] = array[tempRight][player_Score], array[tempRight][player_Score] = tempVar;
tempVar = array[tempLeft][player_ID], array[tempLeft][player_ID] = array[tempRight][player_ID], array[tempRight][player_ID] = tempVar;
tempVarStr = names[tempLeft], names[tempLeft] = names[tempRight], names[tempRight] = tempVarStr;
tempVar = array[tempLeft][player_Kills], array[tempLeft][player_Kills] = array[tempRight][player_Kills], array[tempRight][player_Kills] = tempVar;
tempVar = array[tempLeft][player_Deaths], array[tempLeft][player_Deaths] = array[tempRight][player_Deaths], array[tempRight][player_Deaths] = tempVar;
tempVar = array[tempLeft][player_Team], array[tempLeft][player_Team] = array[tempRight][player_Team], array[tempRight][player_Team] = tempVar;
tempVar = array[tempLeft][player_Acc], array[tempLeft][player_Acc] = array[tempRight][player_Acc], array[tempRight][player_Acc] = tempVar;
tempLeft++, tempRight--;
}
}
if(left < tempRight) GetPlayerHighestScores2(array, names, left, tempRight);
if(tempLeft < right) GetPlayerHighestScores2(array, names, tempLeft, right);
}
Jemand der mir sagen kann wo mein fehler liegt?