Guten Tag Community,
mein MYSQL server speichert. Ich habe das Tutorial von Maddin. Hier die Codes:
stock SavePlayer(playerid)
{
if(IsPlayerConnected(playerid) && !IsPlayerNPC(playerid))
{
if(GetPVarInt(playerid,"Eingeloggt") == 1)
{
new Float:Health;
mysql_SetInt("accounts", "Level", SpielerInfo[playerid][pLevel], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Geld",GetPlayerMoney(playerid) , "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Admin", SpielerInfo[playerid][pAdmin], "Name", SpielerInfo[playerid][pSName]);
mysql_SetFloat("accounts", "Health", GetPlayerHealth(playerid,Health), "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Ban", SpielerInfo[playerid][pBanned], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Geschlecht", SpielerInfo[playerid][pGeschlecht], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Tot", SpielerInfo[playerid][pTot], "Name", SpielerInfo[playerid][pSName]);
mysql_SetFloat("accounts", "pTX", SpielerInfo[playerid][pTX], "Name", SpielerInfo[playerid][pSName]);
mysql_SetFloat("accounts", "pTY", SpielerInfo[playerid][pTY], "Name", SpielerInfo[playerid][pSName]);
mysql_SetFloat("accounts", "pTZ", SpielerInfo[playerid][pTZ], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Fraktion", SpielerInfo[playerid][pFraktion], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Skin", GetPlayerSkin(playerid), "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Warn", SpielerInfo[playerid][pWarn], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "TBan", SpielerInfo[playerid][pTBan], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Bootschein", SpielerInfo[playerid][pBootschein], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Flugschein", SpielerInfo[playerid][pFlugschein], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Autoschein", SpielerInfo[playerid][pAutoschein], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Bikeschein", SpielerInfo[playerid][pBikeschein], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Respektpunkte", SpielerInfo[playerid][Respektpunkte], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "PaydayTime", SpielerInfo[playerid][PaydayTime], "Name", SpielerInfo[playerid][pSName]);
mysql_SetInt("accounts", "Friedhofzeit", SpielerInfo[playerid][pFriedhofzeit], "Name", SpielerInfo[playerid][pSName]);
new query[356];
format(query,sizeof(query), "UPDATE `accounts` SET `level` = '%d', `Geld` = '%d',`Admin` = '%d' , `Ban` = '%d' ,`Geschlecht` = '%d',`Tot` = '%d',`Fraktion` = 'd',`Skin` = '%d', WHERE `Name` = '%e'", SpielerInfo[playerid][pLevel], GetPlayerMoney(playerid), SpielerInfo[playerid][pTX],SpielerInfo[playerid][pTY],SpielerInfo[playerid][pTZ], SpielerInfo[playerid][pSName]);
mysql_query(query);
}
}
return 1;
}
stock mysql_GetString(Table[], Field[], Where[], Is[])
{
new query[128], Get[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
mysql_query(query);
mysql_store_result();
mysql_fetch_row(Get);
mysql_free_result();
return Get;
}
stock mysql_GetInt(Table[], Field[], Where[], Is[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Is, Is);
format(query, 128, "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
mysql_query(query);
mysql_store_result();
new sqlint = mysql_fetch_int();
mysql_free_result();
return sqlint;
}
stock mysql_SetInt(Table[], Field[], To, Where[], Where2[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE `%s` SET `%s` = '%d' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}
stock mysql_SetString(Table[], Field[], To[], Where[], Where2[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(To, To);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE `%s` SET `%s` = '%s' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}
stock mysql_SetFloat(Table[], Field[], Float:To, Where[], Where2[])
{
new query[128];
mysql_real_escape_string(Table, Table);
mysql_real_escape_string(Field, Field);
mysql_real_escape_string(Where, Where);
mysql_real_escape_string(Where2, Where2);
format(query, 128, "UPDATE `%s` SET `%s` = '%f' WHERE `%s` = '%s'", Table, Field, To, Where, Where2);
mysql_query(query);
return true;
}