Hey,
er speichert nur den ersten Buchstaben von pBan_admin.
Das Enum:
enum pDataEnum
{
p_id,
bool:pLoggedIn,
pName[MAX_PLAYER_NAME],
pLevel,
pMoney,
pKills,
pDeaths,
pAdmin,
pF_id,
pF_rank,
pSkin,
pBanned,
pBan_reason[255],
pBan_admin[MAX_PLAYER_NAME],
pBan_date[56],
pPremium,
pVIP
}
new PlayerInfo[MAX_PLAYERS][pDataEnum];
Der Befehl:
ocmd:ban(playerid, params[])
{
if(!isPlayerAnAdmin(playerid,2))return SCM(playerid, ERROR_FARBE, ERROR_ADMIN);
new pID,grund[255],string[1028], query[256], datum[56], Hour, Minute, Second, Year, Month, Day;
if(sscanf(params,"us",pID,grund))return SCM(playerid, ERROR_FARBE, "Tippe: /ban [spieler] [grund]");
getdate(Year, Month, Day);
gettime(Hour, Minute, Second);
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[pID][pAdmin])return SCM(playerid, ERROR_FARBE, ERROR_ADMIN_BAN);
format(datum, sizeof(datum), "%02d.%02d.%d - %02d:%02d:%02d", Year, Month, Day, Hour, Minute, Second);
format(query, sizeof(query), "INSERT INTO Userakte (User, Typ, Date, Reason, Name_From) VALUES ('%s', '%s', '%02d.%02d.%d - %02d:%02d:%02d','%s','%s')", PlayerInfo[pID][pName], TYP_PERM_BAN, Day, Month, Year, Hour, Minute, Second, grund, PlayerInfo[playerid][pName]);
mysql_tquery(handle, query);
format(string, sizeof(string), "%s wurde von %s vom Server gebannt. Grund: %s", PlayerInfo[pID][pName],PlayerInfo[playerid][pName],grund);
SCMA(ERROR_FARBE, string);
format(string, sizeof(string), "Du wurdest von %s vom Server gebannt. Grund: %s", PlayerInfo[playerid][pName], grund);
SCM(pID, ERROR_FARBE, string);
PlayerInfo[playerid][pBanned] = 1;
PlayerInfo[playerid][pBan_reason] = grund;
PlayerInfo[playerid][pBan_admin] = NamePlayer(playerid);
PlayerInfo[playerid][pBan_date] = datum;
SetTimerEx("DelayedKick", 500, false, "i", pID);
return 1;
}
NamePlayer:
stock NamePlayer(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}
Wo es angewand wird:
forward OnUserLogin(playerid);
public OnUserLogin(playerid)
{
//Query wurde ausgeführt und das Ergebnis im Cache gespeichert
new rows, string[128];
cache_get_row_count(rows);
if(rows == 0)
{
//Der Spieler hat ein falsches Passwort eingegeben
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, SERVER_NAME"("SERVER_VERSION")", "Herzlich Willkommen zurück,\nbitte logge Dich nun ein:\n{FF0000}Falsches Passwort!", "Ok", "Abbrechen");
}
else
{
cache_get_value_name_int(0, "id", PlayerInfo[playerid][p_id]);
cache_get_value_name_int(0, "level", PlayerInfo[playerid][pLevel]);
cache_get_value_name_int(0, "money", PlayerInfo[playerid][pMoney]);
cache_get_value_name_int(0, "kills", PlayerInfo[playerid][pKills]);
cache_get_value_name_int(0, "deaths", PlayerInfo[playerid][pDeaths]);
cache_get_value_name_int(0, "admin", PlayerInfo[playerid][pAdmin]);
cache_get_value_name_int(0, "f_id", PlayerInfo[playerid][pF_id]);
cache_get_value_name_int(0, "f_rank", PlayerInfo[playerid][pF_rank]);
cache_get_value_name_int(0, "skin", PlayerInfo[playerid][pSkin]);
cache_get_value_name_int(0, "banned", PlayerInfo[playerid][pBanned]);
cache_get_value_name(0, "ban_reason", PlayerInfo[playerid][pBan_reason], 255);
cache_get_value_name(0, "ban_admin", PlayerInfo[playerid][pBan_admin], 20);
cache_get_value_name(0, "ban_date", PlayerInfo[playerid][pBan_date], 56);
cache_get_value_name_int(0, "premium", PlayerInfo[playerid][pPremium]);
cache_get_value_name_int(0, "vip", PlayerInfo[playerid][pVIP]);
PlayerInfo[playerid][pLoggedIn] = true;
if(PlayerInfo[playerid][pBanned] == 1)
{
new header[256], mid[512], Year, Month, Day, Hour, Minute, Second;
getdate(Year, Month, Day);
gettime(Hour, Minute, Second);
format(header,sizeof(header), "Account(%s) Permanent Gesperrt", PlayerInfo[playerid][pName]);
format(mid,sizeof(mid), "Guten Tag,\ndieser Account wurde gesperrt und kann nicht mehr verwendet werden.\nAusführender Admin: %s\nBandatum: %s\nGrund: %s", PlayerInfo[playerid][pBan_admin], PlayerInfo[playerid][pBan_date], PlayerInfo[playerid][pBan_reason]);
SPD(playerid, DIALOG_BAN_MESSAGEBOX, DIALOG_STYLE_MSGBOX, header, mid,"Bestätigen","");
SetTimerEx("Banned", 500, false, "i", playerid);
return 1;
}
if(PlayerInfo[playerid][pPremium] == 1) { SCM(playerid, ORANGE, "Du besitzt Premium(Permanent)"); }
else if(PlayerInfo[playerid][pPremium] == 1 && PlayerInfo[playerid][pVIP] == 1) { SCM(playerid, ORANGE, "Du besitzt V.I.P.(Permanent)"); }
format(string, sizeof(string), "Willkommen %s", NamePlayer(playerid));
SCM(playerid, 0x00FF00FF, string);
GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
SpawnPlayer(playerid);
}
return 1;
}