Da es hier im Forum erst ein Tutorial gibt zum Wantedspeichern und dieses Fehlerhaft ist und bei den Meisten nicht funktioniert habe ich ein Neues gemacht
Als erstes suchen wir nach :
enum pInfo
und fügen dort über
pCrimes,
Wantedlvl,
ein dann sollte alles so aussehen
enum pInfo
{
pKey[128],
pLevel,
pAdmin,
pDonateRank,
gPupgrade,
pConnectTime,
pReg,
pSex,
pAge,
pOrigin,
pCK,
pMuted,
pExp,
pCash,
pAccount,
Wantedlvl,//<<<<<<<<<<<<<<<<<<<<
pCrimes,
pKills,
pDeaths,
pArrested,
pWantedDeaths,
pPhoneBook,
pLottoNr,
pFishes,
pBiggestFish,
pJob,
pPayCheck,
pHeadValue,
pJailed,
.........
DAnn unter
public OnPlayerConnect(playerid)
...............
PlayerInfo[playerid][pAge] = 0;
PlayerInfo[playerid][pOrigin] = 0;
PlayerInfo[playerid][pExp] = 0;
PlayerInfo[playerid][pAccount] = 0;
PlayerInfo[playerid][Wantedlvl] = 0;//<<<<<<<<<<<<<<<<< einfügen über pCrimes
PlayerInfo[playerid][pCrimes] = 0;
PlayerInfo[playerid][pDeaths] = 0;
PlayerInfo[playerid][pArrested] = 0;
PlayerInfo[playerid][pWantedDeaths] = 0;
...................
Unter:
public OnPlayerRegister
.....................
format(var, 32, "Muted=%d\n",PlayerInfo[playerid][pMuted]);fwrite(hFile, var);
format(var, 32, "Respect=%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var);
format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
format(var, 32, "Bank=%d\n",PlayerInfo[playerid][pAccount]);fwrite(hFile, var);
format(var, 32, "Wanteds=%d\n",PlayerInfo[playerid][Wantedlvl]);fwrite(hFile, var);//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
format(var, 32, "Crimes=%d\n",PlayerInfo[playerid][pCrimes]);fwrite(hFile, var);
format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
..................
unter:
public OnPlayerUpdate
...............
format(var, 32, "Respect=%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var);
format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
format(var, 32, "Bank=%d\n",PlayerInfo[playerid][pAccount]);fwrite(hFile, var);
format(var, 32, "Wanteds=%d\n",PlayerInfo[playerid][Wantedlvl]);fwrite(hFile, var);//<<<<<<<<<<<<<<<<<<<
format(var, 32, "Crimes=%d\n",PlayerInfo[playerid][pCrimes]);fwrite(hFile, var);
format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
format(var, 32, "Arrested=%d\n",PlayerInfo[playerid][pArrested]);fwrite(hFile, var);
..............
Unter:
public OnPlayerLogin
if( strcmp( key , "Respect" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pExp] = strval( val ); }
if( strcmp( key , "Money" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCash] = strval( val ); }
if( strcmp( key , "Bank" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pAccount] = strval( val ); }
if( strcmp( key , "Wanteds" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][Wantedlvl] = strval( val ); }//<<<<<<<<<<<<<<<<<<<<<<
SetPlayerWantedLevel(playerid,PlayerInfo[playerid][Wantedlvl]);//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
if( strcmp( key , "Crimes" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCrimes] = strval( val ); }
if( strcmp( key , "Kills" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pKills] = strval( val ); }
if( strcmp( key , "Deaths" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pDeaths] = strval( val ); }
Das wars mit dem Speichern kommen wir nun zu dem /wanted und /Su Befehl
/suspect (Erfordert DCMD und Sscanf Grundkenntnisse)
dcmd_su(playerid,params[]) {
new
sGrund[128],
pID;
if(sscanf(params, "us",pID,sGrund)) {
return SendClientMessage(playerid,COLOR_RED,"Benutzung: /su [playerid] [grund]");
}
if(!IsPlayerConnected(pID)) {
return SendClientMessage(playerid,COLOR_RED,"Kein Spieler mit angegebener ID Online");
}
if(!IsACop (playerid))
{
return SendClientMessage(playerid,COLOR_RED,"Du bist kein COP");
}
if(IsACop (pID))
{
// return SendClientMessage(playerid,COLOR_RED,"Du kannst keine Cops anzeigen");
}
new
ThePlayer[MAX_PLAYER_NAME],
admin[MAX_PLAYER_NAME],
sumsg1[128],
sumsg2[128];
GetPlayerName(playerid,admin,sizeof(admin));
GetPlayerName(pID,ThePlayer,sizeof(ThePlayer));
SetPlayerWantedLevel(pID,GetPlayerWantedLevel(pID)+1);
format(sumsg1,sizeof(sumsg1),"%s wurde von %s wegen %s angezeigt.",ThePlayer,admin,sGrund);
format(sumsg2,sizeof(sumsg2),"%s hat dich wegen %s angezeigt",admin,sGrund);
SendClientMessage(pID,COLOR_RED,sumsg2);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsACop (i))
{
SendClientMessage(i,COLOR_YELLOW,sumsg1); // Sendet SUmsg1 an alle die unter IsACop definiert wurden
}
}
if(PlayerInfo[pID][Wantedlvl] == 0)
{
PlayerInfo[pID][Wantedlvl] = 1; //setzt das Wantedlvl aus dem Enum oben auf 1 wenn man davor 0 hatte Also 1 Wantedlvl beim Wiedereinloggen das ist sehr wichtig fürs speichern
}
else if(PlayerInfo[pID][Wantedlvl] == 1)
{
PlayerInfo[pID][Wantedlvl] = 2;
}
else if(PlayerInfo[pID][Wantedlvl] == 2)
{
PlayerInfo[pID][Wantedlvl] = 3;
}
else if(PlayerInfo[pID][Wantedlvl] == 3)
{
PlayerInfo[pID][Wantedlvl] = 4;
}
else if(PlayerInfo[pID][Wantedlvl] == 4)
{
PlayerInfo[pID][Wantedlvl] = 5;
}
else if(PlayerInfo[pID][Wantedlvl] == 5)
{
PlayerInfo[pID][Wantedlvl] = 6;
}
else if(PlayerInfo[pID][Wantedlvl] == 6)
{
PlayerInfo[pID][Wantedlvl] = 6;
}
return 1;
}
/wanted
if(strcmp(cmd, "/wanted", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gTeam[playerid] == 2 || IsACop(playerid))
{
new x;
SendClientMessage(playerid, COLOR_GREEN, "Momentan Gesuchte:");
for(new i=0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i))
{
if(GetPlayerWantedLevel(i) >= 1)
{
GetPlayerName(i, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "%s%s: %d Wanteds", string,giveplayer,GetPlayerWantedLevel(i));
x++;
if(x > 3) {
SendClientMessage(playerid, COLOR_YELLOW, string);
x = 0;
format(string, sizeof(string), "");
} else {
format(string, sizeof(string), "%s, ", string);
}
}
}
}
if(x <= 3 && x > 0) {
string[strlen(string)-2] = '.';
SendClientMessage(playerid, COLOR_YELLOW, string);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You're not a Cop / FBI / National Guard !");
}
}//not connected
return 1;
}