Kann man ein Enum in seiner Zeile abfragen?
zB:
Ich will die dritte Stelle eines Enums abfragen und wenn ich etwas da drüber einfüge die neue dritte Stelle mit der selben Funktion abfragen.
Kann man ein Enum in seiner Zeile abfragen?
zB:
Ich will die dritte Stelle eines Enums abfragen und wenn ich etwas da drüber einfüge die neue dritte Stelle mit der selben Funktion abfragen.
Jetzt klappt alles, danke!
Ah da war der Fehler, ich danke dir!
Irgendwas failt da noch
case DIALOG_LOGIN_1: { if(!response)return CON_CLOSE; new key[128]; //new file[128]; format(file,sizeof(file),"/Accounts/%s.inc",GetName(playerid)); format(key,sizeof(key), dini_Get(file, "key")); if(key[0] != EOS && inputtext[0] != EOS && !strcmp(inputtext, key)) { /*new string[128]; format(Info[playerid][CharacterName1],sizeof(string),dini_Get(file, "CharacterName1")); format(Info[playerid][CharacterName2],MAX_PLAYER_NAME,dini_Get(file, "CharacterName2")); format(Info[playerid][CharacterName3],MAX_PLAYER_NAME,dini_Get(file, "CharacterName3")); format(string,sizeof(string),"%s\n%s\n%s",Info[playerid][CharacterName1],Info[playerid][CharacterName2],Info[playerid][CharacterName3]); print(string); print(Info[playerid][CharacterName1]); print(Info[playerid][CharacterName2]); print(Info[playerid][CharacterName3]); ShowPlayerDialog(playerid,DIALOG_LOGIN_2,DIALOG_STYLE_LIST,"Charaktere:",string,"Login","Abbrechen");*/ new ch[3][MAX_PLAYER_NAME],string[128]; format(Info[playerid][CharacterName1],MAX_PLAYER_NAME,dini_Get(file, "CharacterName1")); format(Info[playerid][CharacterName2],MAX_PLAYER_NAME,dini_Get(file, "CharacterName2")); format(Info[playerid][CharacterName3],MAX_PLAYER_NAME,dini_Get(file, "CharacterName3")); if(Info[playerid][CharacterName1][0] == EOS) ch[0] = "/"; else strcat(ch[0],Info[playerid][CharacterName1]); if(Info[playerid][CharacterName2][0] == EOS) ch[1] = "/"; else strcat(ch[1],Info[playerid][CharacterName2]); if(Info[playerid][CharacterName3][0] == EOS) ch[2] = "/"; else strcat(ch[2],Info[playerid][CharacterName3]); format(string,sizeof(string),"%s\n%s\n%s",ch[0],ch[1],ch[2]); ShowPlayerDialog(playerid,DIALOG_LOGIN_2,DIALOG_STYLE_LIST,"Charaktere:",string,"Login","Abbrechen"); print(string); print(Info[playerid][CharacterName1]); print(Info[playerid][CharacterName2]); print(Info[playerid][CharacterName3]); return 1; } }
Character free0=1
Character free1=0
Character free2=0
CharacterName1=Arnold
CharacterName2=Leer
CharacterName3=Leer
key=weeder77
Password Given=1
C:\Program Files\Grand Theft Auto San Andreas\gamemodes\ganmore.pwn(535) : warning 219: local variable "ch" shadows a variable at a preceding level
Da war das doch nur das Problem das der String leer war. Daher hab ich mir gedacht ich schreib einfach was rein. Hab ich doch so oben erklärt, sorry wenn es nicht zu erkennen war. Ich werde mal dein Code nutzen.
new ch[3][MAX_PLAYER_NAME],string[128];
format(Info[playerid][CharacterName1],MAX_PLAYER_NAME,dini_Get(file, "CharacterName1"));
format(Info[playerid][CharacterName2],MAX_PLAYER_NAME,dini_Get(file, "CharacterName2"));
format(Info[playerid][CharacterName3],MAX_PLAYER_NAME,dini_Get(file, "CharacterName3"));
if(Info[playerid][CharacterName1][0] == EOS) ch[0] = "/";
else strcat(ch[0],Info[playerid][CharacterName1]);
if(Info[playerid][CharacterName2][0] == EOS) ch[1] = "/";
else strcat(ch[1],Info[playerid][CharacterName2]);
if(Info[playerid][CharacterName3][0] == EOS) ch[2] = "/";
else strcat(ch[2],Info[playerid][CharacterName3]);
format(string,sizeof(string),"%s\n%s\n%s",ch[0],ch[1],ch[2]);
ShowPlayerDialog(playerid,DIALOG_LOGIN_2,DIALOG_STYLE_LIST,"Charaktere:",string,"Login","Abbrechen");
print(string);
print(Info[playerid][CharacterName1]);
print(Info[playerid][CharacterName2]);
print(Info[playerid][CharacterName3]);
Print:
/
/
/
<null>
<null>
<null>
if(!response)return CON_CLOSE;
new key[128];
new file[128];
format(file,sizeof(file),"/Accounts/%s.inc",GetName(playerid));
format(key,sizeof(key), dini_Get(file, "key"));
if(key[0] != EOS && inputtext[0] != EOS && !strcmp(inputtext, key))
{
new string[128];
format(Info[playerid][CharacterName1],sizeof(string),dini_Get(file, "CharacterName1"));
format(Info[playerid][CharacterName2],MAX_PLAYER_NAME,dini_Get(file, "CharacterName2"));
format(Info[playerid][CharacterName3],MAX_PLAYER_NAME,dini_Get(file, "CharacterName3"));
format(string,sizeof(string),"%s\n%s\n%s",Info[playerid][CharacterName1],Info[playerid][CharacterName2],Info[playerid][CharacterName3]);
print(string);
print(Info[playerid][CharacterName1]);
print(Info[playerid][CharacterName2]);
print(Info[playerid][CharacterName3]);
ShowPlayerDialog(playerid,DIALOG_LOGIN_2,DIALOG_STYLE_LIST,"Charaktere:",string,"Login","Abbrechen");
return 1;
}
Der Pfad stimmt, andere Dinge werden ja auch geladen wie das Passwort.
--------------------------
SA-MP Server: 0.3.7-R2
Exception At Address: 0x76DE72B2 Module: (ntdll.dll)
Registers:
EAX: 0x0000009F EBX: 0x0000000A ECX: 0x004E5998 EDX: 0x01E65F18
ESI: 0x0000009F EDI: 0x0000009B EBP: 0x0012FCE0 ESP: 0x0012FCCC
EFLAGS: 0x00010216
Stack:
+0000: 0x01E65F18 0x01E65F04 0x00000128 0xFFFFFFFE
+0010: 0x0012FD18 0x0012FD20 0x00498BB8 0x0000009B
+0020: 0x0049F510 0x0000007B 0x01E65F18 0x01E65F04
+0030: 0x0000000A 0x004AAE98 0xFFFFFFFF 0x0012FCF4
+0040: 0x0012F8D8 0x0012FE24 0x0049D208 0x004BA7F0
+0050: 0xFFFFFFFF 0x0000000A 0x004991E0 0x0000007B
+0060: 0x00404F14 0x0000007B 0x0012FD4C 0x01E65F04
+0070: 0x0000000A 0x0012FD80 0x0132FDA8 0x012444E8
+0080: 0x01E65F01 0x00472DE6 0x00405802 0x0000007B
+0090: 0x0000000A 0x00000001 0x012C0B58 0x00024A24
+00A0: 0x004057B0 0x012C0B58 0x012C0B58 0x01E3B018
+00B0: 0x00000087 0x01E414DC 0x004010B6 0x012C0B58
+00C0: 0x01E65F18 0x01E414F4 0x00402B63 0x012C0B58
+00D0: 0x00000008 0x0012FDB8 0x01E65F04 0x00515BF8
+00E0: 0x012C0B58 0x00000001 0x00000000 0x00000000
+00F0: 0x00024A24 0x00024A10 0x00024A70 0x00020A74
+0100: 0x00024A4C 0x00020A74 0x01E3B018 0x01E414F4
+0110: 0x00000000 0x01E3A7A8 0x000064DC 0x0046F679
+0120: 0x012C0B58 0x0012FE04 0xFFFFFFFF 0x01639260
+0130: 0xFFFFFFFF 0x00000001 0x00000000 0x0048E0C2
--------------------------
Loaded Modules:
samp-server.exe A: 0x00400000 - 0x00519000 (C:\Program Files\Grand Theft Auto San Andreas\samp-server.exe)
ntdll.dll A: 0x76DA0000 - 0x76EE2000 (C:\Windows\SYSTEM32\ntdll.dll)
kernel32.dll A: 0x76A40000 - 0x76B15000 (C:\Windows\system32\kernel32.dll)
KERNELBASE.dll A: 0x74EC0000 - 0x74F0B000 (C:\Windows\system32\KERNELBASE.dll)
SHELL32.dll A: 0x75560000 - 0x761AC000 (C:\Windows\system32\SHELL32.dll)
msvcrt.dll A: 0x76F40000 - 0x76FEC000 (C:\Windows\system32\msvcrt.dll)
SHLWAPI.dll A: 0x767D0000 - 0x76827000 (C:\Windows\system32\SHLWAPI.dll)
GDI32.dll A: 0x761D0000 - 0x7621E000 (C:\Windows\system32\GDI32.dll)
USER32.dll A: 0x768B0000 - 0x76979000 (C:\Windows\system32\USER32.dll)
LPK.dll A: 0x76EF0000 - 0x76EFA000 (C:\Windows\system32\LPK.dll)
USP10.dll A: 0x76980000 - 0x76A1D000 (C:\Windows\system32\USP10.dll)
WSOCK32.dll A: 0x6DCD0000 - 0x6DCD7000 (C:\Windows\system32\WSOCK32.dll)
WS2_32.dll A: 0x75080000 - 0x750B5000 (C:\Windows\system32\WS2_32.dll)
RPCRT4.dll A: 0x76230000 - 0x762D2000 (C:\Windows\system32\RPCRT4.dll)
NSI.dll A: 0x76F30000 - 0x76F36000 (C:\Windows\system32\NSI.dll)
WINMM.dll A: 0x6FCB0000 - 0x6FCE2000 (C:\Windows\system32\WINMM.dll)
IMM32.DLL A: 0x76A20000 - 0x76A3F000 (C:\Windows\system32\IMM32.DLL)
MSCTF.dll A: 0x76C70000 - 0x76D3D000 (C:\Windows\system32\MSCTF.dll)
mswsock.dll A: 0x746A0000 - 0x746DC000 (C:\Windows\system32\mswsock.dll)
wshtcpip.dll A: 0x74190000 - 0x74195000 (C:\Windows\System32\wshtcpip.dll)
NLAapi.dll A: 0x73760000 - 0x73770000 (C:\Windows\system32\NLAapi.dll)
napinsp.dll A: 0x71550000 - 0x71560000 (C:\Windows\system32\napinsp.dll)
sechost.dll A: 0x761B0000 - 0x761C9000 (C:\Windows\SYSTEM32\sechost.dll)
pnrpnsp.dll A: 0x6EC40000 - 0x6EC52000 (C:\Windows\system32\pnrpnsp.dll)
wshbth.dll A: 0x6EC30000 - 0x6EC3D000 (C:\Windows\system32\wshbth.dll)
WLIDNSP.DLL A: 0x70B70000 - 0x70B97000 (C:\Program Files\Common Files\Microsoft Shared\Windows Live\WLIDNSP.DLL)
ADVAPI32.dll A: 0x75110000 - 0x751B1000 (C:\Windows\system32\ADVAPI32.dll)
PSAPI.DLL A: 0x76220000 - 0x76225000 (C:\Windows\system32\PSAPI.DLL)
DNSAPI.dll A: 0x74560000 - 0x745A4000 (C:\Windows\system32\DNSAPI.dll)
winrnr.dll A: 0x6EBF0000 - 0x6EBF8000 (C:\Windows\System32\winrnr.dll)
IPHLPAPI.DLL A: 0x72BD0000 - 0x72BEC000 (C:\Windows\system32\IPHLPAPI.DLL)
WINNSI.DLL A: 0x72BB0000 - 0x72BB7000 (C:\Windows\system32\WINNSI.DLL)
rasadhlp.dll A: 0x70B60000 - 0x70B66000 (C:\Windows\system32\rasadhlp.dll)
Alles anzeigen
String ist einfach leer.
Ich hab überall "Leer" eingetragen und es geht trotzdem nicht mit meiner Funktion. Muss wohl woanders dran liegen. Findest du denn einen anderen Fehler in meiner Funktion?
Wird leider nichts im Dialog angezeigt. Hab ich da den Fehler oder muss ich woanders suchen?
enum Account_Daten
{
bool:PasswortVergeben,
bool:CharacterFrei[3],
CharacterName1[MAX_PLAYER_NAME],
CharacterName2[MAX_PLAYER_NAME],
CharacterName3[MAX_PLAYER_NAME],
RpPoints[MAX_PLAYERS],
pMoney[MAX_PLAYERS]
};
format(Info[playerid][CharacterName1],MAX_PLAYER_NAME,dini_Get(file, "CharacterName1"));
format(Info[playerid][CharacterName2],MAX_PLAYER_NAME,dini_Get(file, "CharacterName2"));
format(Info[playerid][CharacterName3],MAX_PLAYER_NAME,dini_Get(file, "CharacterName3"));
format(string,sizeof(string),"%s\n%s\n%s",Info[playerid][CharacterName1],Info[playerid][CharacterName2],Info[playerid][CharacterName3]);
ShowPlayerDialog(playerid,DIALOG_LOGIN_2,DIALOG_STYLE_LIST,"Charaktere:",string,"Login","Abbrechen");
CON_CLOSE ist ganz unten im Code drin. Speichern tu ich als .inc
Irgendwie werde ich immer vom Server gekickt (an dieser Stelle) obwohl ich im Ordner Accounts eine Inc Datei mit dem Namen erstellt habe den ich nutze.
public OnPlayerConnect(playerid)
{
new file[128];
GetPlayerName(playerid,p_name[playerid],MAX_PLAYER_NAME);
SpawnStep[playerid] = 0;
Spawn(playerid);
format(file,sizeof(file),"/Accounts/%s.inc",GetName(playerid));
if(dini_Exists(file))
{
//Abfrage ob Account ein Passwort hat
Info[playerid][PasswortVergeben] = dini_Bool(file,"Password Given");
if(Info[playerid][PasswortVergeben] == false)
{
ShowPlayerDialog(playerid,DIALOG_REGISTER_1,DIALOG_STYLE_INPUT,"Registration","Gib nun bitte dein Passwort ein.","Registrieren","Abbrechen");
}
else
{
ShowPlayerDialog(playerid,DIALOG_LOGIN_1,DIALOG_STYLE_INPUT,"Login","Gib nun bitte dein Passwort ein.","Einloggen","Abbrechen");
}
}
else
{
new string[128];
format(string,sizeof(string),"%s dont exist and left the server!",file);
print(string);
CON_CLOSE;
}
return 1;
}
#define CON_CLOSE SCM(playerid,rot,"Du hast den Vorgang abgebrochen"),Kick(playerid)
Der Print kommt aber keine Nachricht auf dem Server...
Wie sieht es aus wenn gar nichts in der inc steht? Wird das dann einfach weiter durchlaufen und den Wert auf 0.00 lassen/setzen?
Ach so meinst du das, ja stimmt das ergibt Sinn. Ich werde mal schauen wie lange das dauert und ob es so klappt. Danke dir.
Ach und schreibt er auch 0 rein wenn es gar nicht existiert?
"Diese Abfragen kannst du dir sparen, da du dadurch den Wert im schlechtesten Fall doppelt ausliest"
Hat sich so angehört als würde es nicht klappen. Aber wieso wird der Wert 2 mal ausgelesen?
Kannst du mir erklären wieso das nicht klappt? Laut Gescripteten Code müsste es ja funktionieren oder nicht?
Geht das irgendwie noch schneller zu speichern oder zu laden ohne das Dini Land zu verlassen? Und würde das zu lange dauern wenn man ein flüssiges Spiel liefern will?
for(new i = 0; i<100; i++)
{
if(Inventar[playerid][pCannabis][i] > 0.00){format(string,sizeof(string),"Cannabis Qualität: %d%:",i);dini_FloatSet(file,string,Inventar[playerid][pCannabis][i]);}
if(Inventar[playerid][pCrystalMeth][i] > 0.00){format(string,sizeof(string),"Crystal Qualität: %d%:",i);dini_FloatSet(file,string,Inventar[playerid][pCrystalMeth][i]);}
if(Inventar[playerid][pHeroin][i] > 0.00){format(string,sizeof(string),"Heroin Qualität: %d%:",i);dini_FloatSet(file,string,Inventar[playerid][pHeroin][i]);}
if(Inventar[playerid][pCocaine][i] > 0.00){format(string,sizeof(string),"Kokain Qualität: %d%",i);dini_FloatSet(file,string,Inventar[playerid][pCocaine][i]);}
}
for(new i = 0; i<100; i++)
{
format(string,sizeof(string),"Cannabis Qualität: %d%:",i);
if(dini_Float(file,string) > 0.00){Inventar[playerid][pCannabis][i] = dini_Float(file,string);}
format(string,sizeof(string),"Crystal Qualität: %d%:",i);
if(dini_Float(file,string) > 0.00){Inventar[playerid][pCrystalMeth][i] = dini_Float(file,string);}
format(string,sizeof(string),"Heroin Qualität: %d%:",i);
if(dini_Float(file,string) > 0.00){Inventar[playerid][pHeroin][i] = dini_Float(file,string);}
format(string,sizeof(string),"Kokain Qualität: %d%:",i);
if(dini_Float(file,string) > 0.00){Inventar[playerid][pCocaine][i] = dini_Float(file,string);}
}
Würde ja nicht dazu kommen das jemand 100 Drogen bei sich hat. Es wäre immer nur eine kleine Menge im Umlauf. Aber was genau funktioniert denn da jetzt nicht? Oder funkt es aber frisst es einfach zu viel?
Hab den Fehler jetzt auch gesehen. Ich speicher wirklich nur das i ab
Ist jetzt umgeschrieben. Und meine Frage wär halt ob das zu belastend so ist von der Perfomance her und ob es schneller geht mit Dini.
Die Droge kann 100 Qualitätsstufen haben die ich mit "i" Abfrage und wenn eine der Qualitätsstufen vorhanden ist soll diese gespeichert werden. Und bei der Speicherung speichert er doch den Wert oder nicht?
Die Speicherung egal über welchen Weg. Gedacht hätte ich an eine schnellere Abfrage?
for(new i = 0; i<100; i++)
{
if(Inventar[playerid][pCannabis][i] > 0.00){format(string,sizeof(string),"Cannabis %f %d%:",Inventar[playerid][pCannabis][i],i);dini_FloatSet(file,string,Inventar[playerid][pCannabis][i]);}
if(Inventar[playerid][pCrystalMeth][i] > 0.00){format(string,sizeof(string),"Crystal %f %d%:",Inventar[playerid][pCannabis][i],i);dini_FloatSet(file,string,Inventar[playerid][pCrystalMeth][i]);}
if(Inventar[playerid][pHeroin][i] > 0.00){format(string,sizeof(string),"Heroin %f %d%:",Inventar[playerid][pCannabis][i],i);dini_FloatSet(file,string,Inventar[playerid][pHeroin][i]);}
if(Inventar[playerid][pCocaine][i] > 0.00){format(string,sizeof(string),"Kokain %f %d%",Inventar[playerid][pCannabis][i],i);dini_FloatSet(file,string,Inventar[playerid][pCocaine][i]);}
}
Geht das auch schneller
Edit: Eine AQbfrage vergessen sorry