Blunt
Ich möchte die Waffen auslesen und als PlayerInfo definieren.
GetPlayerWeaponData(playerid, slot, weapons, ammo)
GetPlayerWeaponData(playerid, slot2, weapons2, ammo2)
GetPlayerWeaponData(playerid, slot3, weapons3, ammo3)
Das wäre ja schonmal das auslesen, wäre die Schleife so richtig?
Ok und wie definiere ich die Waffe und Ammo nun?
Einfach beim Acc eintragen unter dem Enum und als PlayerInfo[playerid][weapons] und PlayerInfo[playerid][ammo]
speichern und laden? Ich denke schon nur bevor ich das mit allen 13 Slots mache wollte ich mir noch Gewissheit verschaffen.
Alles anzeigen
Danke ja das weiß ich. Aber dir auch nochmal (nicht unhöfflich gemeint, aber man will ja auf das Ziel kommen) ich möchte es ganz simpel und einfach damit jeder es versteht und bei sich einarbeiten kann. Dies gibt es zu diesem Thema noch nicht also poste ich ganz am Ende nochmal die Lösung, damit ein solcher Thread nicht nochmal geschrieben werden muss. Meine Frage war ob das so richtig ist wie ich das gemacht habe?
Blunt
Ich möchte die Waffen auslesen und als PlayerInfo definieren.
GetPlayerWeaponData(playerid, slot, weapons, ammo)
GetPlayerWeaponData(playerid, slot2, weapons2, ammo2)
GetPlayerWeaponData(playerid, slot3, weapons3, ammo3)
Das wäre ja schonmal das auslesen, wäre die Schleife so richtig?
Ok und wie definiere ich die Waffe und Ammo nun?
Einfach beim Acc eintragen unter dem Enum und als PlayerInfo[playerid][weapons] und PlayerInfo[playerid][ammo]
speichern und laden? Ich denke schon nur bevor ich das mit allen 13 Slots mache wollte ich mir noch Gewissheit verschaffen.
Alles anzeigen
Danke ja das weiß ich. Aber dir auch nochmal (nicht unhöfflich gemeint, aber man will ja auf das Ziel kommen) ich möchte es ganz simpel und einfach damit jeder es versteht und bei sich einarbeiten kann. Dies gibt es zu diesem Thema noch nicht also poste ich ganz am Ende nochmal die Lösung, damit ein solcher Thread nicht nochmal geschrieben werden muss. Meine Frage war ob das so richtig ist wie ich das gemacht habe?
//edit___________________________________________________________________________________________________________
Hier einmal meine jetzige Arbeit die aus eurer Hilfe ausging (leider noch Fehler drinne)
new Weapons[MAX_PLAYERS][11], Ammo[MAX_PLAYERS][11];
enum pInfo
{
weapons,
ammo,
weapons2,
ammo2,
weapons3,
ammo3,
weapons4,
ammo4,
weapons5,
ammo5,
weapons6,
ammo6,
weapons7,
ammo7,
weapons8,
ammo8,
weapons9,
ammo9,
weapons10,
ammo10,
weapons11,
ammo11,
}
Function OnPlayerConnect(playerid)//Bin da
{
PlayerInfo[playerid][weapons] = 0;
PlayerInfo[playerid][ammo] = 0;
PlayerInfo[playerid][weapons2] = 0;
PlayerInfo[playerid][ammo2] = 0;
PlayerInfo[playerid][weapons3] = 0;
PlayerInfo[playerid][ammo3] = 0;
PlayerInfo[playerid][weapons4] = 0;
PlayerInfo[playerid][ammo4] = 0;
PlayerInfo[playerid][weapons5] = 0;
PlayerInfo[playerid][ammo5] = 0;
PlayerInfo[playerid][weapons6] = 0;
PlayerInfo[playerid][ammo6] = 0;
PlayerInfo[playerid][weapons7] = 0;
PlayerInfo[playerid][ammo7] = 0;
PlayerInfo[playerid][weapons8] = 0;
PlayerInfo[playerid][ammo8] = 0;
PlayerInfo[playerid][weapons9] = 0;
PlayerInfo[playerid][ammo9] = 0;
PlayerInfo[playerid][weapons10] = 0;
PlayerInfo[playerid][ammo10] = 0;
PlayerInfo[playerid][weapons11] = 0;
PlayerInfo[playerid][ammo11] = 0;
}
Function OnPlayerDisconnect(playerid, reason)
{
GetPlayerWeaponData(playerid, slot, weapons, ammo)
GetPlayerWeaponData(playerid, slot2, weapons2, ammo2)
GetPlayerWeaponData(playerid, slot3, weapons3, ammo3)
GetPlayerWeaponData(playerid, slot4, weapons4, ammo4)
GetPlayerWeaponData(playerid, slot5, weapons5, ammo5)
GetPlayerWeaponData(playerid, slot6, weapons6, ammo6)
GetPlayerWeaponData(playerid, slot7, weapons7, ammo7)
GetPlayerWeaponData(playerid, slot8, weapons8, ammo8)
GetPlayerWeaponData(playerid, slot9, weapons9, ammo9)
GetPlayerWeaponData(playerid, slot10, weapons10, ammo10)
GetPlayerWeaponData(playerid, slot11, weapons11, ammo11)
}
Function OnPlayerRegister(playerid, password[])
{
if(IsPlayerConnected(playerid))
{
new string3[64];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "/Accounts/%s.ini", playername3);
new File: hFile = fopen(string3, io_write); if (hFile)
{
format(var, 32, "Waffe1=%d\n",PlayerInfo[playerid][weapons]);fwrite(hFile, var);
format(var, 32, "Ammu1=%d\n",PlayerInfo[playerid][ammo]);fwrite(hFile, var);
format(var, 32, "Waffe2=%d\n",PlayerInfo[playerid][weapons2]);fwrite(hFile, var);
format(var, 32, "Ammu2=%d\n",PlayerInfo[playerid][ammo2]);fwrite(hFile, var);
format(var, 32, "Waffe3=%d\n",PlayerInfo[playerid][weapons3]);fwrite(hFile, var);
format(var, 32, "Ammu3=%d\n",PlayerInfo[playerid][ammo3]);fwrite(hFile, var);
format(var, 32, "Waffe4=%d\n",PlayerInfo[playerid][weapons4]);fwrite(hFile, var);
format(var, 32, "Ammu4=%d\n",PlayerInfo[playerid][ammo4]);fwrite(hFile, var);
format(var, 32, "Waffe5=%d\n",PlayerInfo[playerid][weapons5]);fwrite(hFile, var);
format(var, 32, "Ammu5=%d\n",PlayerInfo[playerid][ammo5]);fwrite(hFile, var);
format(var, 32, "Waffe6=%d\n",PlayerInfo[playerid][weapons6]);fwrite(hFile, var);
format(var, 32, "Ammu6=%d\n",PlayerInfo[playerid][ammo6]);fwrite(hFile, var);
format(var, 32, "Waffe7=%d\n",PlayerInfo[playerid][weapons7]);fwrite(hFile, var);
format(var, 32, "Ammu7=%d\n",PlayerInfo[playerid][ammo7]);fwrite(hFile, var);
format(var, 32, "Waffe8=%d\n",PlayerInfo[playerid][weapons8]);fwrite(hFile, var);
format(var, 32, "Ammu8=%d\n",PlayerInfo[playerid][ammo8]);fwrite(hFile, var);
format(var, 32, "Waffe9=%d\n",PlayerInfo[playerid][weapons9]);fwrite(hFile, var);
format(var, 32, "Ammu9=%d\n",PlayerInfo[playerid][ammo9]);fwrite(hFile, var);
format(var, 32, "Waffe10=%d\n",PlayerInfo[playerid][weapons10]);fwrite(hFile, var);
format(var, 32, "Ammu10=%d\n",PlayerInfo[playerid][ammo10]);fwrite(hFile, var);
format(var, 32, "Waffe11=%d\n",PlayerInfo[playerid][weapons11]);fwrite(hFile, var);
format(var, 32, "Ammu11=%d\n",PlayerInfo[playerid][ammo11]);fwrite(hFile, var);
}
}
}
Function PlayerUpdate(playerid)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid])
{
M_OnPlayerUpdate(playerid);
new string3[64];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "/Accounts/%s.ini", playername3);
new File: hFile = fopen(string3, io_write);
if (hFile)
{
format(var, 32, "Waffe1=%d\n",PlayerInfo[playerid][weapons]);fwrite(hFile, var);
format(var, 32, "Ammu1=%d\n",PlayerInfo[playerid][ammo]);fwrite(hFile, var);
format(var, 32, "Waffe2=%d\n",PlayerInfo[playerid][weapons2]);fwrite(hFile, var);
format(var, 32, "Ammu2=%d\n",PlayerInfo[playerid][ammo2]);fwrite(hFile, var);
format(var, 32, "Waffe3=%d\n",PlayerInfo[playerid][weapons3]);fwrite(hFile, var);
format(var, 32, "Ammu3=%d\n",PlayerInfo[playerid][ammo3]);fwrite(hFile, var);
format(var, 32, "Waffe4=%d\n",PlayerInfo[playerid][weapons4]);fwrite(hFile, var);
format(var, 32, "Ammu4=%d\n",PlayerInfo[playerid][ammo4]);fwrite(hFile, var);
format(var, 32, "Waffe5=%d\n",PlayerInfo[playerid][weapons5]);fwrite(hFile, var);
format(var, 32, "Ammu5=%d\n",PlayerInfo[playerid][ammo5]);fwrite(hFile, var);
format(var, 32, "Waffe6=%d\n",PlayerInfo[playerid][weapons6]);fwrite(hFile, var);
format(var, 32, "Ammu6=%d\n",PlayerInfo[playerid][ammo6]);fwrite(hFile, var);
format(var, 32, "Waffe7=%d\n",PlayerInfo[playerid][weapons7]);fwrite(hFile, var);
format(var, 32, "Ammu7=%d\n",PlayerInfo[playerid][ammo7]);fwrite(hFile, var);
format(var, 32, "Waffe8=%d\n",PlayerInfo[playerid][weapons8]);fwrite(hFile, var);
format(var, 32, "Ammu8=%d\n",PlayerInfo[playerid][ammo8]);fwrite(hFile, var);
format(var, 32, "Waffe9=%d\n",PlayerInfo[playerid][weapons9]);fwrite(hFile, var);
format(var, 32, "Ammu9=%d\n",PlayerInfo[playerid][ammo9]);fwrite(hFile, var);
format(var, 32, "Waffe10=%d\n",PlayerInfo[playerid][weapons10]);fwrite(hFile, var);
format(var, 32, "Ammu10=%d\n",PlayerInfo[playerid][ammo10]);fwrite(hFile, var);
format(var, 32, "Waffe11=%d\n",PlayerInfo[playerid][weapons11]);fwrite(hFile, var);
format(var, 32, "Ammu11=%d\n",PlayerInfo[playerid][ammo11]);fwrite(hFile, var);
}
}
}
}
Function OnPlayerLogin(playerid,password[])
{
new tmp2[256];
new string2[128];
new playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
format(string2, sizeof(string2), "/Accounts/%s.ini", playername2);
new File: UserFile = fopen(string2, io_read);
if ( UserFile )
{
new PassData[256];
new keytmp[256], valtmp[256];
fread( UserFile , PassData , sizeof( PassData ) );
keytmp = ini_GetKey( PassData );
if( strcmp( keytmp , "Key" , true ) == 0 )
{
valtmp = ini_GetValue( PassData );
strmid(PlayerInfo[playerid][pKey], valtmp, 0, strlen(valtmp)-1, 255);
}
if(strcmp(PlayerInfo[playerid][pKey],password, true ) == 0 )
{
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( UserFile , Data , sizeof( Data ) ) )
{
if( strcmp( key , "Waffe1" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons] = strval( val ); }
if( strcmp( key , "Ammu1" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo] = strval( val ); }
if( strcmp( key , "Waffe2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons2] = strval( val ); }
if( strcmp( key , "Ammu2" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo2] = strval( val ); }
if( strcmp( key , "Waffe3" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons3] = strval( val ); }
if( strcmp( key , "Ammu3" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo3] = strval( val ); }
if( strcmp( key , "Waffe4" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons4] = strval( val ); }
if( strcmp( key , "Ammu4" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo4] = strval( val ); }
if( strcmp( key , "Waffe5" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons5] = strval( val ); }
if( strcmp( key , "Ammu5" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo5] = strval( val ); }
if( strcmp( key , "Waffe6" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons6] = strval( val ); }
if( strcmp( key , "Ammu6" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo6] = strval( val ); }
if( strcmp( key , "Waffe7" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons7] = strval( val ); }
if( strcmp( key , "Ammu7" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo7] = strval( val ); }
if( strcmp( key , "Waffe8" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons8] = strval( val ); }
if( strcmp( key , "Ammu8" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo8] = strval( val ); }
if( strcmp( key , "Waffe9" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons9] = strval( val ); }
if( strcmp( key , "Ammu9" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo9] = strval( val ); }
if( strcmp( key , "Waffe10" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons10] = strval( val ); }
if( strcmp( key , "Ammu10" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo10] = strval( val ); }
if( strcmp( key , "Waffe11" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][weapons11] = strval( val ); }
if( strcmp( key , "Ammu11" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][ammo11] = strval( val ); }
}
}
}
}
}
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5663) : error 017: undefined symbol "slot"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5664) : error 017: undefined symbol "slot2"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5665) : error 017: undefined symbol "slot3"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5666) : error 017: undefined symbol "slot4"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5667) : error 017: undefined symbol "slot5"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5668) : error 017: undefined symbol "slot6"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5669) : error 017: undefined symbol "slot7"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5670) : error 017: undefined symbol "slot8"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5671) : error 017: undefined symbol "slot9"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5672) : error 017: undefined symbol "slot10"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5673) : error 017: undefined symbol "slot11"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(5674) : error 001: expected token: ";", but found "if"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(21243) : warning 219: local variable "ammo" shadows a variable at a preceding level
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(21261) : error 028: invalid subscript (not an array or too many subscripts): "ammo"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(21261) : warning 215: expression has no effect
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(21261) : error 001: expected token: ";", but found "]"
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(21261) : error 029: invalid expression, assumed zero
C:\Dokumente und Einstellungen\jan\Eigene Dateien\GTA San Andreas User Files\gamemodes\G AN MORE Roleplay\gamemodes\GSRR.pwn(21261) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
16 Errors.