Guten Abend Breadfish
Ich habe mich an ein Fraktionssystem gesetzt und habe gemerkt das die Fraktion nicht in die Datenbank abgespeichert wird.
Mysql_Log:
SQL
[10/12/16 21:49:25] [INFO] changed log level from 'warning, error' to 'debug, info, warning, error'
[10/12/16 21:55:26] [DEBUG] mysql_format(1, 0xF5416730, 128, "SELECT id FROM Accounts WHERE Name = '%e'") (Nitradoscript.p:264)
[10/12/16 21:55:26] [DEBUG] CHandle::EscapeString(this=0x8b5aab0, src='Tiriago')
[10/12/16 21:55:26] [DEBUG] CConnection::EscapeString(src='Tiriago', this=0x8c4b6d0, connection=0x8ccc178)
[10/12/16 21:55:26] [DEBUG] CHandle::EscapeString - return value: true, escaped string: 'Tiriago'
[10/12/16 21:55:26] [DEBUG] mysql_format: return value: '46' (Nitradoscript.p:264)
[10/12/16 21:55:26] [DEBUG] mysql_pquery(1, "SELECT id FROM Accounts WHERE Name = 'Tiriago'", "OnUserCheck", "d") (Nitradoscript.p:265)
[10/12/16 21:55:26] [DEBUG] CCallback::Create(amx=0x8ccbd38, name='OnUserCheck', format='d', params=0xf5416718, param_offset=5)
[10/12/16 21:55:26] [DEBUG] CCallback::Create - callback index for 'OnUserCheck': 32
[10/12/16 21:55:26] [DEBUG] processing specifier 'd' with parameter index 0
[10/12/16 21:55:26] [DEBUG] retrieved and pushed value '0'
[10/12/16 21:55:26] [INFO] Callback 'OnUserCheck' set up for delayed execution.
[10/12/16 21:55:26] [DEBUG] created delayed callback with 1 parameter
[10/12/16 21:55:26] [DEBUG] CHandle::Execute(this=0x8b5aab0, type=2, query=0x8d1b020)
[10/12/16 21:55:26] [DEBUG] CConnectionPool::Queue(query=0x8d1b020, this=0x8c52490)
[10/12/16 21:55:26] [DEBUG] CConnection::Execute(query=0x8d1b020, this=0xf4aeb008, connection=0x8cf2af8)
[10/12/16 21:55:26] [DEBUG] CQuery::Execute(this=0x8d1b020, connection=0x8cf2af8)
[10/12/16 21:55:26] [DEBUG] CHandle::Execute - return value: true
[10/12/16 21:55:26] [DEBUG] mysql_pquery: return value: '1' (Nitradoscript.p:265)
[10/12/16 21:55:26] [INFO] query "SELECT id FROM Accounts WHERE Name = 'Tiriago'" successfully executed within 0.309 milliseconds
[10/12/16 21:55:26] [DEBUG] CResultSet::Create(connection=0x8cf2af8, query_str='SELECT id FROM Accounts WHERE Name = 'Tiriago'')
[10/12/16 21:55:26] [DEBUG] created new resultset '0xf4100688'
[10/12/16 21:55:26] [DEBUG] fetched MySQL result '0xf41008e0'
[10/12/16 21:55:26] [DEBUG] allocated 20 bytes for PAWN result
[10/12/16 21:55:26] [DEBUG] CCallback::Execute(amx=0x8ccbd38, index=32, num_params=1)
[10/12/16 21:55:26] [INFO] Executing callback 'OnUserCheck' with 1 parameter...
[10/12/16 21:55:26] [DEBUG] processing internal specifier 'c'
[10/12/16 21:55:26] [DEBUG] pushed value '0' onto AMX stack
[10/12/16 21:55:26] [DEBUG] executing AMX callback with index '32'
[10/12/16 21:55:26] [DEBUG] cache_get_row_count(0xF5416930) (Nitradoscript.p:290)
[10/12/16 21:55:26] [DEBUG] cache_get_row_count: return value: '1' (Nitradoscript.p:290)
[10/12/16 21:55:26] [DEBUG] AMX callback executed with error '0'
[10/12/16 21:55:26] [INFO] Callback successfully executed.
[10/12/16 21:55:31] [DEBUG] mysql_format(1, 0xF5416524, 256, "SELECT * FROM Accounts WHERE Name = '%s' AND password = MD5('%s')") (Nitradoscript.p:1063)
[10/12/16 21:55:31] [DEBUG] mysql_format: return value: '74' (Nitradoscript.p:1063)
[10/12/16 21:55:31] [DEBUG] mysql_pquery(1, "SELECT * FROM Accounts WHERE Name = 'Tiriago' AND password = MD5('jaguar')", "OnUserLogin", "d") (Nitradoscript.p:1065)
[10/12/16 21:55:31] [DEBUG] CCallback::Create(amx=0x8ccbd38, name='OnUserLogin', format='d', params=0xf541650c, param_offset=5)
[10/12/16 21:55:31] [DEBUG] CCallback::Create - callback index for 'OnUserLogin': 33
[10/12/16 21:55:31] [DEBUG] processing specifier 'd' with parameter index 0
[10/12/16 21:55:31] [DEBUG] retrieved and pushed value '0'
[10/12/16 21:55:31] [INFO] Callback 'OnUserLogin' set up for delayed execution.
[10/12/16 21:55:31] [DEBUG] created delayed callback with 1 parameter
[10/12/16 21:55:31] [DEBUG] CHandle::Execute(this=0x8b5aab0, type=2, query=0x8d1b3f0)
[10/12/16 21:55:31] [DEBUG] CConnectionPool::Queue(query=0x8d1b3f0, this=0x8c52490)
[10/12/16 21:55:31] [DEBUG] CHandle::Execute - return value: true
[10/12/16 21:55:31] [DEBUG] mysql_pquery: return value: '1' (Nitradoscript.p:1065)
[10/12/16 21:55:31] [DEBUG] CConnection::Execute(query=0x8d1b3f0, this=0xf4269008, connection=0x8cf9148)
[10/12/16 21:55:31] [DEBUG] CQuery::Execute(this=0x8d1b3f0, connection=0x8cf9148)
[10/12/16 21:55:31] [INFO] query "SELECT * FROM Accounts WHERE Name = 'Tiriago' AND password = MD5('jaguar')" successfully executed within 0.563 milliseconds
[10/12/16 21:55:31] [DEBUG] CResultSet::Create(connection=0x8cf9148, query_str='SELECT * FROM Accounts WHERE Name = 'Tiriago' AND password = MD5('jaguar')')
[10/12/16 21:55:31] [DEBUG] created new resultset '0xf37004f0'
[10/12/16 21:55:31] [DEBUG] fetched MySQL result '0xf37007a8'
[10/12/16 21:55:31] [DEBUG] allocated 100 bytes for PAWN result
[10/12/16 21:55:31] [DEBUG] CCallback::Execute(amx=0x8ccbd38, index=33, num_params=1)
[10/12/16 21:55:31] [INFO] Executing callback 'OnUserLogin' with 1 parameter...
[10/12/16 21:55:31] [DEBUG] processing internal specifier 'c'
[10/12/16 21:55:31] [DEBUG] pushed value '0' onto AMX stack
[10/12/16 21:55:31] [DEBUG] executing AMX callback with index '33'
[10/12/16 21:55:31] [DEBUG] cache_get_row_count(0xF5416930) (Nitradoscript.p:1115)
[10/12/16 21:55:31] [DEBUG] cache_get_row_count: return value: '1' (Nitradoscript.p:1115)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int(0, "db_id", 0xF54015A4) (Nitradoscript.p:1125)
[10/12/16 21:55:31] [ERROR] cache_get_value_name_int: field 'db_id' not found (Nitradoscript.p:1125)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int(0, "Adminlevel", 0xF540160C) (Nitradoscript.p:1126)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: assigned value: '7' (Nitradoscript.p:1126)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: return value: '1' (Nitradoscript.p:1126)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int(0, "Level", 0xF5401610) (Nitradoscript.p:1127)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: assigned value: '2' (Nitradoscript.p:1127)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: return value: '1' (Nitradoscript.p:1127)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int(0, "Money", 0xF5401614) (Nitradoscript.p:1128)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: assigned value: '0' (Nitradoscript.p:1128)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: return value: '1' (Nitradoscript.p:1128)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int(0, "Fraktion", 0xF5401618) (Nitradoscript.p:1129)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: assigned value: '0' (Nitradoscript.p:1129)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: return value: '1' (Nitradoscript.p:1129)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int(0, "Rang", 0xF540161C) (Nitradoscript.p:1130)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: assigned value: '0' (Nitradoscript.p:1130)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: return value: '1' (Nitradoscript.p:1130)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int(0, "Spawn", 0xF5401620) (Nitradoscript.p:1131)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: assigned value: '0' (Nitradoscript.p:1131)
[10/12/16 21:55:31] [DEBUG] cache_get_value_name_int: return value: '1' (Nitradoscript.p:1131)
[10/12/16 21:55:31] [DEBUG] AMX callback executed with error '0'
[10/12/16 21:55:31] [INFO] Callback successfully executed.
Alles anzeigen
So sieht mein System aus:
Spielernenum:
Code
enum playerInfo{
db_id,
bool:eingeloggt,
Name[MAX_PLAYER_NAME],
Adminlevel,
Level,
Money,
Fraktion,
Rang,
Spawn
}
new sInfo[MAX_PLAYER_NAME][playerInfo];
Alles anzeigen
frakteEnum:
Code
enum frakteEnum{
f_name[300],
Float:f_x,
Float:f_y,
Float:f_z,
Float:f_r,
f_inter,
f_world,
f_color
}
Alles anzeigen
fInfo:
Code
new fInfo[][frakteEnum] ={
{"Zivilist",329.0244,-1513.3033,36.0391,225.8344,0,0,weiß},//Zivilist 0
{"SAPD",213.4162,162.7460,1003.0234,274.4569,3,1,blau},//SAPD 1
{"SWAT",2731.5903,-2450.0164,17.5937,272.4424,0,0,helblau},//SWAT2
{"FBI",2286.9651,2431.6011,10.8203,176.4887,0,0,duneklhelblau},//FBI3
{"ARMY",214.2768,1822.5925,6.4141,265.0869,0,0,hellgrün},//ARMY4
{"Medic/Feuerwehr",302.9467,-1505.8025,24.6007,231.6743,0,0,rot},//MEDIC5
{"Fahrschule",2124.3032,-2273.0491,20.6719,221.7338,0,0,orange},//Fahrschule6
{"Aztecas",2788.4141,-1944.7075,13.5469,87.2128,0,0,türkis},//AZTECAS7
{"Vagos",204.6566,39.7421,2.5781,260.2514,0,0,gelb},//Vagos8
{"Ballas",1084.8976,-1226.7927,15.8203,269.7700,0,0,pink},//Ballas9
{"Yakuza",-2188.6282,-2265.0452,30.6250,71.4091,0,0,grau}//Yakuza10
};
Alles anzeigen
OnPlayerRequestClass:
Code
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1686.2013,-2315.4673,13.3828);
SetPlayerCameraPos(playerid, 1686.2013,-2315.4673,13.3828);
SetPlayerCameraLookAt(playerid, 1686.2013,-2315.4673,13.3828);
SetPlayerFacingAngle(playerid,179.8357);
//Wenn der Spieler die Class-Selection betritt prüfe,ob er bereits eingeloggt ist
if(!sInfo[playerid][eingeloggt])
{
//Wenn nicht,dann prüfe ob der Spieler ein Konto hat
new query[128];
mysql_format(handle,query,sizeof(query),"SELECT id FROM Accounts WHERE Name = '%e'",sInfo[playerid][Name]);
mysql_pquery(handle,query,"OnUserCheck","d",playerid);
}
r
Alles anzeigen
OnPlayerConnect und OnUserCheck:
Code
public OnPlayerConnect(playerid)
{
sInfo[playerid][db_id] =0;
sInfo[playerid][eingeloggt] =false;
sInfo[playerid][Adminlevel] =0;
sInfo[playerid][Level] = 0;
sInfo[playerid][Money] = 0;
sInfo[playerid][Fraktion] = 0;
sInfo[playerid][Rang] = 0;
sInfo[playerid][Spawn] = 0;
GetPlayerName(playerid,sInfo[playerid][Name],MAX_PLAYER_NAME);
SetPlayerColor(playerid,weiß);
sInfo[playerid][Level]=1;
SetPlayerScore(playerid,sInfo[playerid][Level]);
return 1;
}
public OnUserCheck(playerid)
{
//Query wurde ausgeführt und das Ergebnis im Cache gespeichert
new rows;
cache_get_row_count(rows);
if(rows == 0)
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_PASSWORD,"Account erstellen","Bitte Registriere dich:","Registrieren","Abbrechen");
}
else
{
//Es existiert ein Ergebnis,das heißt der Spieler ist registriert und muss sich einloggen
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Einloggen","Bitte loggte dich ein:","Einloggen","Abbrechen");
}
return 1;
}
resetPlayer(playerid)
{
for(new i=0; i<sizeof(sInfo[]); i++)
{
sInfo[playerid][playerInfo:i]=0;
}
return 1;
}
Alles anzeigen
OnPlayerSpawn:
Code
public OnPlayerSpawn(playerid)
{
if(!isPlayerInFrakt(playerid,0))
{
if(sInfo[playerid][Spawn]==1)
{
new fID;
fID= sInfo[playerid][Fraktion];
SetPlayerPos(playerid,fInfo[fID][f_x],fInfo[fID][f_y],fInfo[fID][f_z]);
SetPlayerFacingAngle(playerid,fInfo[fID][f_r]);
SetPlayerInterior(playerid,fInfo[fID][f_inter]);
SetPlayerVirtualWorld(playerid,fInfo[fID][f_world]);
SetPlayerColor(playerid,fInfo[fID][f_color]);
}
}
SendClientMessage(playerid,rot,"/hilfe um die Befehle zu sehen!");
return 1;
}
Alles anzeigen
Abfrage wegen Fraktion:
OnUserLogin:
Code
public OnUserLogin(playerid)
{
new rows;
cache_get_row_count(rows);
if(rows == 0)
{
//Der Spieler hat ein falsches Passwort eingegeben
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Einloggen","Bitte logge dich ein:\n{0xFF0000FF}Falsches Passwort!","Einloggen","Abbrechen");
}
else
{
//Es existiert ein Ergebnis,das heißt der Spieler hat das richtige Passwort eingegeben
//Wir lesen nun die erste Zeile des Caches aus (id 0)
cache_get_value_name_int(0,"db_id",sInfo[playerid][db_id]);
cache_get_value_name_int(0,"Adminlevel",sInfo[playerid][Adminlevel]);
cache_get_value_name_int(0,"Level",sInfo[playerid][Level]);
cache_get_value_name_int(0,"Money",sInfo[playerid][Money]);
cache_get_value_name_int(0,"Fraktion",sInfo[playerid][Fraktion]);
cache_get_value_name_int(0,"Rang",sInfo[playerid][Rang]);
cache_get_value_name_int(0,"Spawn",sInfo[playerid][Spawn]);
}
return 1;
}
Alles anzeigen
SaveUserStats:
Code
stock SaveUserStats(playerid)
{
//Wen der Spieler nicht eingeloggt ist, dann speichere seine Statistiken nicht
if(!sInfo[playerid][eingeloggt])return 1;
//Ansonsten speichere Sie ab
new query[600];
mysql_format(handle,query,sizeof(query),"UPDATE Accounts Set Name = '%s',Adminlevel = '%d',Level = '%d',Money = '%d',Fraktion = '%d',Rang = '%d',Spawn = '%d' WHERE id = '%d' ",
sInfo[playerid][Name],sInfo[playerid][Adminlevel],sInfo[playerid][Level],sInfo[playerid][Money],sInfo[playerid][Fraktion],sInfo[playerid][Rang],sInfo[playerid][Spawn],sInfo[playerid][db_id]);
//Das Query wird abgesendet
mysql_pquery(handle,query);
return 1;
}
Alles anzeigen