Hallo,
ich schreibe an einen eigenen Haussystem wo sich Spieler in mehrere Häuser einmieten können und an jeden Payday für jedes angemietete Haus wie üblich den dazugehöhrigen Mietpreis bezahlen.
Ich habe 2 Tabellen hierzu. Einmal haus und das andere hausmieten
Strukturen (Tabelle Haus ist in Auszug)
Tabelle haus
id | Besitzer | X | Y | Z | Mietpreis etc.
id | Player | DB
Server-Log
SA-MP Dedicated Server
----------------------
v0.3.7, (C)2005-2015 SA-MP Team
[15:47:19] Server Plugins
[15:47:19] --------------
[15:47:19] Loading plugin: streamer
[15:47:19]
[15:47:19] Loading plugin: audio
[15:47:19]
[15:47:19] Loading plugin: sscanf
[15:47:19]
[15:47:19] Loading plugin: mysql
[15:47:19]
[15:47:19] Loaded 4 plugins.
[15:47:19] Filterscripts
[15:47:19] ---------------
[15:47:19] Loading filterscript 'TextDrawEditor.amx'...
[15:47:19]
--------------------------------------
[15:47:19] Text Draw Editor 1.0RC2 by Zamaroht for SA-MP 0.3 Loaded.
[15:47:19] --------------------------------------
[15:47:19] Loaded 2 filterscripts.
[15:47:20] [connection] 127.0.0.1:60281 requests connection cookie.
[15:47:20] Starte Server...
[15:47:20] (( 1 % ))
[15:47:20] [SERVER] GameMode-Text geladen
[15:47:20] (( 2 % ))
[15:47:20] (( 3 % ))
[15:47:20] (( 4 % ))
[15:47:20] [SERVER] Text-Draw's geladen!
[15:47:20] (( 5 % ))
[15:47:20] (( 6 % ))
[15:47:20] (( 7 % ))
[15:47:20] [CAR] Neulingsfahrzeuge geladen!
[15:47:20] (( 8 % ))
[15:47:20] (( 9 % ))
[15:47:20] (( 10 % ))
[15:47:20] [MYSQL] Verbindung zur Datenbank wurde erfolgreich hergestellt!
[15:47:20] (( 11 % ))
[15:47:20] (( 12 % ))
[15:47:20] (( 13 % ))
[15:47:20] [MAP] Alle 3DTextLabels und Pickups geladen!
[15:47:20] (( 14 %))
[15:47:20] (( 15 % ))
[15:47:20] (( 16 % ))
[15:47:20] [MAP] Stadthalle geladen!
[15:47:20] [MAP] Stadthallen - Interior geladen!
[15:47:20] (( 17 % ))
[15:47:20] (( 18 % ))
[15:47:20] (( 19 % ))
[15:47:20] [MAP] Parkanlage Los Santos geladen!
[15:47:20] (( 20 % ))
[15:47:20] (( 21 % ))
[15:47:20] (( 22 % ))
[15:47:20] [MAP] LSPD geladen!
[15:47:20] (( 23 % ))
[15:47:20] (( 24 % ))
[15:47:20] (( 25 % ))
[15:47:20] [MAP] LSPD Interior geladen
[15:47:20] (( 26 % ))
[15:47:20] (( 27 % ))
[15:47:20] (( 28 % ))
[15:47:20] [MAP] Bank-Interior Modern geladen!
[15:47:20] (( 29 % ))
[15:47:20] (( 30 % ))
[15:47:20] (( 31 % ))
[15:47:20] [CAR] LSPD Fraktionsfahrzeuge geladen!
[15:47:20] (( 32 % ))
[15:47:20] (( 33 % ))
[15:47:20] (( 34 % ))
[15:47:20] (( 35 % ))
[15:47:20] [Map] Krankenhaus Exterior geladen!
[15:47:20] (( 36 % ))
[15:47:20] (( 37 % ))
[15:47:20] [CONFIG] Server Einstellungen geladen | Staatskasse: 15652955
[15:47:20] (null)
[15:47:20] (( 38 % ))
[15:47:20] (( 39 % ))
[15:47:20] (( 40 % ))
[15:47:20] [MAP] Ordnungsamt geladen!
[15:47:20] (( 41 % ))
[15:47:20] (( 42 % ))
[15:47:20] (( 43 % ))
[15:47:20] (( 44 % ))
[15:47:20] (( 45 % ))
[15:47:20] (( 46 % ))
[15:47:20] [connection] 127.0.0.1:60282 requests connection cookie.
[15:47:21] [connection] 127.0.0.1:60283 requests connection cookie.
[15:47:21] [connection] 127.0.0.1:60284 requests connection cookie.
[15:47:22] [connection] 127.0.0.1:60285 requests connection cookie.
[15:47:23] [HAUS] 79 Häuser wurden geladen!
[15:47:51] Kicking 127.0.0.1 because they didn't logon to the game.
[15:47:51] Kicking 127.0.0.1 because they didn't logon to the game.
[15:47:52] Kicking 127.0.0.1 because they didn't logon to the game.
[15:47:52] Kicking 127.0.0.1 because they didn't logon to the game.
[15:47:53] Kicking 127.0.0.1 because they didn't logon to the game.
[15:48:04] (( 47 % ))
[15:48:04] (( 48 % ))
[15:48:04] (( 49 % ))
[15:48:04] (( 50 % ))
[15:48:04]
----------------------------------
[15:48:04] LoC Roleplay Script by palwal
[15:48:04] ----------------------------------
[15:48:04] Incoming connection: 127.0.0.1:60281 id: 0
[15:48:04] NPC Connect: Bad player ID (127.0.0.1)
[15:48:04] Incoming connection: 127.0.0.1:60282 id: 1
[15:48:04] NPC Connect: Bad player ID (127.0.0.1)
[15:48:04] Incoming connection: 127.0.0.1:60283 id: 2
[15:48:04] NPC Connect: Bad player ID (127.0.0.1)
[15:48:04] Incoming connection: 127.0.0.1:60284 id: 3
[15:48:04] NPC Connect: Bad player ID (127.0.0.1)
[15:48:04] Incoming connection: 127.0.0.1:60285 id: 4
[15:48:04] NPC Connect: Bad player ID (127.0.0.1)
[15:50:22] [connection] 127.0.0.1:61225 requests connection cookie.
[15:50:23] Incoming connection: 127.0.0.1:61225 id: 0
[15:50:24] [join] Patrick has joined the server (0:127.0.0.1)
Das Lade-System
stock LoadMieter(id) {
new query[250], check, field[200];
if(HausInfo[id][hDB] == 0) return 1;
format(query, sizeof(query), "SELECT * FROM hausmieten WHERE DB = '%i'", HausInfo[id][hDB]);
mysql_query(query);
mysql_store_result();
for(new x=0;x<sizeof(HausMieten);x++) {
if(mysql_retrieve_row()) {
check++;
mysql_fetch_field_row(field,"Player");format(HausMieten[x][hmPlayer], 100, "%s", field);
HausMieten[x][hmDB] = HausInfo[id][hDB];
}
}
mysql_free_result();
return 1;
}
stock LoadHouses()
{
new query[250], query2[250], string[250],field[300],field2[20], ok[250], check, check2;
new field3[200];
format(query, sizeof(query), "SELECT * FROM haus");
mysql_query(query);
mysql_store_result();
for(new i=0;i<500;i++) {
if(mysql_retrieve_row()) {
mysql_fetch_field_row(field2,"id");HausInfo[i][hDB] = strval(field2);
mysql_fetch_field_row(field2,"Mietpreis");HausInfo[i][hMietPreis] = strval(field2);
mysql_fetch_field_row(field2,"Miete");HausInfo[i][hMiete] = strval(field2);
mysql_fetch_field_row(field2,"X");HausInfo[i][hX] = floatstr(field2);
mysql_fetch_field_row(field2,"Y");HausInfo[i][hY] = floatstr(field2);
mysql_fetch_field_row(field2,"Z");HausInfo[i][hZ] = floatstr(field2);
mysql_fetch_field_row(field2,"IX");HausInfo[i][hiX] = floatstr(field2);
mysql_fetch_field_row(field2,"IY");HausInfo[i][hiY] = floatstr(field2);
mysql_fetch_field_row(field2,"IZ");HausInfo[i][hiZ] = floatstr(field2);
mysql_fetch_field_row(field2,"Interior");HausInfo[i][hInterior] = strval(field2);
mysql_fetch_field_row(field2,"Hauskasse");HausInfo[i][hHausKasse] = strval(field2);
mysql_fetch_field_row(field2,"Preis");HausInfo[i][hPreis] = strval(field2);
mysql_fetch_field_row(field2,"Locked");HausInfo[i][hLock] = strval(field2);
mysql_fetch_field_row(field2,"Gesperrt");HausInfo[i][hALock] = strval(field2);
check++;
HausUpdate(i);
}
format(ok, sizeof(ok), "[HAUS] %i Häuser wurden geladen!", check);
print(ok);
mysql_free_result();
//Eingemeitete Häuser werden geladen
for(new x=0;x<sizeof(HausInfo);x++) {
LoadMieter(x);
}
return 1;
}
Publics
forward IsMieter(playerid, dbid);
public IsMieter(playerid, dbid) {
for(new i=0;i<sizeof(HausMieten);i++) {
if(HausMieten[i][hmDB] == 0) continue;
if(HausMieten[i][hmDB] != dbid) continue;
if(strcmp(HausMieten[i][hmPlayer], SpielerName(playerid), true)) continue;
return 1;
}
return 0;
}
forward SendMeiete(playerid, dbid);
public sendMiete(playerid, dbid) {
for(new x=0;x<sizeof(HausInfo);x++) {
if(HausInfo[x][hDB] == 0) continue;
if(HausInfo[x][hDB] != dbid) continue;
SpielerInfo[playerid][pGeld] -= HausInfo[x][hMietPreis];
HausInfo[x][hHausKasse] += HausInfo[x][hMietPreis];
return 1;
}
return 1;
}
Auszug aus dem PayDay-Timer
for(new x=0;x<sizeof(HausInfo);x++) {
if(HausInfo[x][hDB] == 0) continue;
if(IsMieter(playerid, HausInfo[x][hDB])) {
mcheck++;
if(HausInfo[x][hALock] == 1) {
format(mstr, sizeof(mstr), "[Mietwohnung %i] {FF0000}Administrativ gesperrt", mcheck);
SendClientMessage(playerid, 0xFFFA00FF, mstr);
} else {
format(mstr, sizeof(mstr), "[Mietwohnung %i] -%i", mcheck, HausInfo[x][hMietPreis]);
SendClientMessage(playerid, 0xFFFA00FF, mstr);
sendMiete(playerid, HausInfo[x][hDB]);
}
continue;
} else {
continue;
}
}
1) Warum werdn beim Servstart die NPC's wieder gekickt? Die werden aber nur gekickt wenn LoadMieter(id) ausgeführt wird.
2) Beim PayDay wird nur ein Haus ausgelesen? Bei mir war es das letzte was nur ausgelesen wurde abwohl ich mich in 3 Häuser eingemietet habe.
Beim Serverstart werden aber alle 3 existierenden Einträge der Tabelle hausmieten ausgelesen.
3) Könnte ich das System anders schreiben damit es auch so funktioniert wie ich das möchte?
4) Gerne auch Optimierungs- und resourcenschonendere Vorschläge.
Ich hoffe ihr könnt mir helfen. Ich wäre euch sehr dankbar.
Liebe Grüße
palwal