//==========[INCLUDES]==========//
#include <a_samp>
#include <a_mysql>
//==========[Farben]==========//
#define WEIß 0xFFFFFFFF
#define BLAU
#define ROT
#define HELLGRUEN 0x00CD00FF
//==========[Dialoge]==========//
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_RADIO 3
//==========[News]==========//
new vermysql;
//==========[Forwards]==========//
forward UserCheck(playerid);
forward UserRegister(playerid);
forward UserLogin(playerid);
forward ServerNachricht();
//==========[Enums]==========//
enum Spieler
{
p_id,
pLoggedIn,
pName[MAX_PLAYER_NAME],
pLevel,
pGeld,
pKills,
pDeaths
}
new SpielerInfo[MAX_PLAYERS][Spieler];
//==========[MYSQL]==========//
#define db_host "89.163.220.7"
#define db_user "gtaadmin"
#define db_pass "ZaB92GUB"
#define db_db "sampgta"
//==========[Einstellungen]==========//
main()
{
print("\n----------------------------------");
print("************************************");
print("HSP4F-Reallife wurde gestartet...");
print("************************************");
print("Mit dem Betrieb dieses Scripts akzeptieren");
print("Sie die Lizenz. Missachten Sie diese");
print("machen Sie sich strafbar!");
print("----------------------------------\n");
}
public OnGameModeInit()
{
SetGameModeText("HSP4F v0.0.1");
SetTimer("ServerNachricht",600000,1);
EnableStuntBonusForAll(0);
UsePlayerPedAnims();
MySQL_SetupConnection();
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
return 1;
}
public OnGameModeExit()
{
mysql_close(vermysql);
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(!SpielerInfo[playerid][pLoggedIn])
{
new query[128];
mysql_format(vermysql, query, sizeof(query), "SELECT id FROM users WHERE name = '%e'", SpielerInfo[playerid][pName]);
mysql_pquery(vermysql, query, "OnUserCheck", "id", playerid);
}
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}
public OnPlayerConnect(playerid)
{
new query[128], ip[16];
GetPlayerIp(playerid,ip,16);
format(query,128, "INSERT INTO `logRL`(`IP`, `Spielername`) VALUES('%s', '%s')", ip, SpielerName(playerid));
printf("[>logRL<] Zeitstempel: %i | Spielername: %s | IP: %s", gettime(), SpielerName(playerid), ip);
mysql_function_query(vermysql, query, false, "", "");
SpielerInfo[playerid][p_id] = 0;
SpielerInfo[playerid][pLoggedIn] = false;
SpielerInfo[playerid][pLevel] = 0;
SpielerInfo[playerid][pGeld] = 0;
SpielerInfo[playerid][pKills] = 0;
SpielerInfo[playerid][pDeaths] = 0;
GetPlayerName(playerid,SpielerInfo[playerid][pName], MAX_PLAYER_NAME);
PlayAudioStreamForPlayer(playerid, "http://thewareofgerman.s4y-web.de/music/FCLogin.mp3");
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SpielerSpeichern(playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
SpielerInfo[killerid][pKills]++;
GivePlayerMoney(killerid, 10);
SpielerInfo[killerid][pGeld] += 10;
if(SpielerInfo[killerid][pKills] > 3)
{
SpielerInfo[killerid][pLevel] = 1;
}
}
SpielerInfo[playerid][pDeaths]++;
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
new SGT[128];
format(SGT,sizeof(SGT),"%s sagt: %s",SpielerName(playerid),text);
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && !IsPlayerNPC(i))
{
if(IsPlayerInRangeOfPoint(i,30.0,x,y,z))
{
SendClientMessage(i,WEIß,SGT);
}
}
}
return 0;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}
public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}
public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}
public OnPlayerUpdate(playerid)
{
return 1;
}
public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}
public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}
public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}
public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER)
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 3) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration", "Bitte registriere Dich:\n{FF0000}Mindestens 3 Zeichen!", "Ok", "Abbrechen");
new query[256];
mysql_format(vermysql, query, sizeof(query), "INSERT INTO users (name, password) VALUES ('%e', MD5('%e'))", SpielerInfo[playerid][pName], inputtext);
mysql_pquery(vermysql, query, "OnUserRegister", "d", playerid);
return 1;
}
if(dialogid == DIALOG_LOGIN)
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 3) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Anmeldung", "Bitte logge Dich ein:\n{FF0000}Mindestens 3 Zeichen!", "Ok", "Abbrechen");
new query[256];
mysql_format(vermysql, query, sizeof(query), "SELECT * FROM users WHERE name = '%e' AND password = MD5('%e')", SpielerInfo[playerid][pName], inputtext);
mysql_pquery(vermysql, query, "OnUserLogin", "d", playerid);
return 1;
}
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public ServerNachricht()
{
SendClientMessageToAll(HELLGRUEN,"=============================Informationen=============================");
SendClientMessageToAll(WEIß,"Dieser Server ist wie man es sieht ein Dorf Reallife Server");
SendClientMessageToAll(WEIß,"Ihr müsst euch hier euer eigenes Leben im Dorf aufbauen.");
SendClientMessageToAll(WEIß,"wir hoffen das es euch hier gefälltbei Fragen /report [Text]");
SendClientMessageToAll(HELLGRUEN,"====================TS³:====================Forum:====================");
return 1;
}
public UserCheck(playerid)
{
if(cache_get_row_count() == 0)
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration", "Bitte registriere Dich:", "Ok", "Abbrechen");
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Anmeldung", "Bitte logge Dich ein:", "Ok", "Abbrechen");
}
return 1;
}
public UserRegister(playerid)
{
SpielerInfo[playerid][p_id] = cache_insert_id();
SendClientMessage(playerid, 0x00FF00FF, "[Konto] Registration erfolgreich.");
return 1;
}
public UserLogin(playerid)
{
if(cache_get_row_count() == 0)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Anmeldung", "Bitte logge Dich ein:\n{FF0000}Falsches Passwort!", "Ok", "Abbrechen");
}
else
{
SpielerInfo[playerid][p_id] = cache_get_field_content_int(0, "id", vermysql);
SpielerInfo[playerid][pLevel] = cache_get_field_content_int(0, "level", vermysql);
SpielerInfo[playerid][pGeld] = cache_get_field_content_int(0, "geld", vermysql);
SpielerInfo[playerid][pKills] = cache_get_field_content_int(0, "kills", vermysql);
SpielerInfo[playerid][pDeaths] = cache_get_field_content_int(0, "deaths", vermysql);
SpielerInfo[playerid][pLoggedIn] = true;
SendClientMessage(playerid, 0x00FF00FF, "[Konto] Eingeloggt.");
GivePlayerMoney(playerid, SpielerInfo[playerid][pGeld]);
}
return 1;
}
stock SpielerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
return name;
}
stock MySQL_SetupConnection(ttl = 3)
{
print("[MySQL] Verbindungsaufbau...");
vermysql = mysql_connect(db_host,db_user,db_db,db_pass);
if(mysql_errno(vermysql) != 0)
{
if(ttl > 1)
{
print("[MySQL] Es konnte keine Verbindung zur Datenbank hergestellt werden.");
printf("[MySQL] Starte neuen Verbindungsversuch (TTL: %d).", ttl-1);
return MySQL_SetupConnection(ttl-1);
}
else
{
print("[MySQL] Es konnte keine Verbindung zur Datenbank hergestellt werden.");
print("[MySQL] Bitte prüfen Sie die Verbindungsdaten.");
print("[MySQL] Der Server wird heruntergefahren.");
return SendRconCommand("exit");
}
}
printf("[MySQL] Die Verbindung zur Datenbank wurde erfolgreich hergestellt! Handle: %d", vermysql);
return 1;
}
stock SpielerSpeichern(playerid)
{
if(!SpielerInfo[playerid][pLoggedIn]) return 1;
new query[256];
mysql_format(vermysql, query, sizeof(query), "UPDATE users SET level = '%d', money = '%d', kills = '%d', deaths = '%d' WHERE id = '%d'",
SpielerInfo[playerid][pLevel], SpielerInfo[playerid][pGeld], SpielerInfo[playerid][pKills], SpielerInfo[playerid][pDeaths], SpielerInfo[playerid][p_id]);
mysql_pquery(vermysql, query);
return 1;
}