Jeffry: Hallo, sobald ich sterbe wird das Login System aufgerufen...
bei OnPlayerDeath habe ich es aber nicht angegeben...
public OnPlayerSpawn(playerid)
{
TogglePlayerSpectating(playerid,0);
Jail(playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(gTeam[killerid] == TEAM_SFPD)
{
if (WantedLevel[playerid])
{
SetJail(playerid);
SetJailTime(playerid);
}
}
else
{
SpawnPlayer(playerid);
}
return 1;
}
stock Jail(playerid) //Polizei Knast Laden
{
new query[128];
GetPlayerName(playerid,query,MAX_PLAYER_NAME);
format(query,128,"SELECT `JAILED` FROM `USERS` WHERE `Name` = '%s'",query);
new DBResult:result = db_query(Database, query);
new str[5];
if(db_num_rows(result)) db_get_field(result, 0, str, sizeof(str));
Jailed[playerid] = strval(str);
printf("playerid: %d / JAILED: %d / name: %s", playerid, Jailed[playerid]);
if (Jailed[playerid] == 1)
{
new Random = random(sizeof(JailSpawns));
SetPlayerPos(playerid, JailSpawns[Random][0], JailSpawns[Random][1], JailSpawns[Random][2]);
SetPlayerFacingAngle(playerid, JailSpawns[Random][3]);
LoadJailTime(playerid);
}
else if (Jailed[playerid] == 0)
{
//TogglePlayerSpectating(playerid,0);
SetPlayerVirtualWorld(playerid,0);
SetPlayerPos(playerid,-1952.1089,112.4961,26.2813);
}
return 1;
}
stock AJail(playerid)
{
return 1;
}
stock SetJailTime(playerid) //Polizei Knast Setzen
{
new query[128];
new jailtime = (WantedLevel[playerid] * 150);
GetPlayerName(playerid,query,MAX_PLAYER_NAME);
format(query,128,"UPDATE `USERS` SET `JAILTIME` = '%d' WHERE `Name` = '%s'",jailtime, query);
db_query(Database,query);
return 1;
}
stock JailTimer(playerid) //Polizei Knast Timer
{
SetPlayerVirtualWorld(playerid,0);
SetPlayerPos(playerid,-1952.1089,112.4961,26.2813);
return 1;
}
stock UnJailed(playerid)
{
/* ===== Hier wird "Jailed" auf 0 gesetzt ===== */
format(query,128,"UPDATE `USERS` SET `JAILED` = '0' WHERE `Name` = '%s'", query);
db_query(Database,query);
return 1;
}
stock UnJailTime(playerid)
{
/* ===== Hier wird "Jailtime" auf 0 gesetzt ===== */
format(query,128,"UPDATE `USERS` SET `JAILTIME` = '0' WHERE `Name` = '%s'", query);
db_query(Database,query);
return 1;
}
stock SetJail(playerid) //Polizei Knast Setzen
{
new query[128];
new jail[128];
GetPlayerName(playerid,query,MAX_PLAYER_NAME);
format(query,128,"UPDATE `USERS` SET `JAILTIME` = '1' WHERE `Name` = '%s'", query);
db_query(Database,query);
return 1;
}
stock LoadJailTime(playerid)
{
new query[128];
GetPlayerName(playerid,query,MAX_PLAYER_NAME);
format(query,128,"SELECT `JAILTIME` FROM `USERS` WHERE `Name` = '%s'",query);
new DBResult:result = db_query(Database, query);
new str[5];
if(db_num_rows(result)) db_get_field(result, 0, str, sizeof(str));
JailTime[playerid] = strval(str);
printf("playerid: %d / JailTime: %d / name: %s", playerid, JailTime[playerid]);
SetTimerEx("UnPrison", JailTime[playerid], false, "d", playerid);
}
//SetTimer("message", 1000, false); // Set a timer of 1000 miliseconds (1 second)
stock UnPrison(playerid)
{
UnJailTime(playerid);
UnJail(playerid);
}
if(dialogid == 1)
{
if(response)
{
format(Query, sizeof(Query), "SELECT * FROM `USERS` WHERE `NAME` = '%s' COLLATE NOCASE AND `PASSWORD` = '%s'", DB_Escape(name), DB_Escape(inputtext));
Result = db_query(Database, Query);
if(db_num_rows(Result))
{
new Field[ 20 ];
db_get_field_assoc(Result, "SCORE", Field, 30);
SetPlayerScore(playerid, strval(Field));
db_get_field_assoc(Result, "CASH", Field, 30);
GivePlayerMoney(playerid, strval(Field));
db_get_field_assoc(Result, "ADMINLEVEL", Field, 30);
Bit16_Set(g_AdminLevel, playerid, strval(Field));
Bit1_Set(g_PlayerLogged, playerid, true);
SendClientMessage(playerid, -1, "Du hast dich "COL_GREEN"Erfolgreich{FFFFFF} eingeloggt! ");
OnPlayerSpawn(playerid);
join(playerid);
}
else
{
format(Query, sizeof(Query), "{FFFFFF}Willkommen "COL_BLUE"%s(%d){FFFFFF} auf unserem Server, du bist Registriert\n\nBitte Logge dich nun mit deinem Passwort ein.", name, playerid);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFFFF}Login", Query, "Login", "Verlassen");
SendClientMessage(playerid, -1, ""COL_RED"Falsches{FFFFFF} Passwort!");
}
db_free_result(Result);
}
else return Kick(playerid);
}
if(dialogid == 0)
{
if(response)
{
if(strlen(inputtext) > 24 || strlen(inputtext) < 3)
{
format(Query, sizeof(Query), "{FFFFFF}Willkommen "COL_BLUE"%s(%d){FFFFFF} auf unserem Server, du bist "COL_RED"nicht{FFFFFF} Registriert\n\nBitte Logge dich nun mit deinem Passwort ein.", name, playerid);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "{FFFFFF}Register System", Query, "Registrieren", "Verlassen");
SendClientMessage(playerid, -1, "Dein Passwort muss mindestens 3 zeichen haben!");
}
else
{
format(Query, sizeof(Query), "INSERT INTO `USERS` (`NAME`, `PASSWORD`, `IP`, `SCORE`, `CASH`, `ADMINLEVEL`) VALUES('%s','%s','%s', '0', '500', '0')", DB_Escape(name), DB_Escape(inputtext), DB_Escape(ip));
db_query(Database, Query);
Bit1_Set(g_PlayerLogged, playerid, true);
GivePlayerMoney(playerid, 500);
SetPlayerScore(playerid, 0);
SendClientMessage(playerid, -1, "Du hast dich "COL_GREEN"Erfolgreich{FFFFFF} registriert! Du wurdest automatisch eingeloggt!");
OnPlayerSpawn(playerid);
join(playerid);
}
}
else return Kick(playerid);
}