#include #include #include #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 #define COLOR_WHITE 0xFFFFFFFF #define COLOR_BLACK 0x0A0A0AFF #define COLOR_GREEN 0x05FF00FF #define COLOR_RED 0xFF0000FF #define COLOR_ORANGE 0xFFDC00FF #define COLOR_BLUE 0x0A00FFFF forward LoadHouse(number); forward UpdateHouse(number); #define MAX_HOUSES 100 new Text3D:HouseLabel[MAX_HOUSES]; #if defined FILTERSCRIPT public OnFilterScriptInit() { print("\n--------------------------------------"); print("House System by Sascha Loishandl"); print("--------------------------------------\n"); return 1; } public OnFilterScriptExit() { return 1; } #else main() { print("\n----------------------------------"); print("House System by Sascha Loishandl"); print("----------------------------------\n"); } #endif public OnGameModeInit() { SetGameModeText("House Test System"); AddPlayerClass(15, 0, 0, 0, 0, 24, 500, 29, 500, 30, 500); if(!fexist("House/Info.ini")) { dini_Create("House/Info.ini"); dini_IntSet("House/Info.ini", "Max", 0); } for(new h = 0; h < MAX_HOUSES; h++) { LoadHouse(h); } return 1; } public OnGameModeExit() { return 1; } public OnPlayerRequestClass(playerid, classid) { SetPlayerPos(playerid, 0, 0, 0); SetPlayerCameraPos(playerid, 10, 0, 0); SetPlayerCameraLookAt(playerid, 0, 0, 0); return 1; } public OnPlayerConnect(playerid) { return 1; } public OnPlayerDisconnect(playerid, reason) { return 1; } public OnPlayerSpawn(playerid) { return 1; } public OnPlayerDeath(playerid, killerid, reason) { return 1; } public OnVehicleSpawn(vehicleid) { return 1; } public OnVehicleDeath(vehicleid, killerid) { return 1; } public OnPlayerText(playerid, text[]) { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(createhouse,11,cmdtext); dcmd(buyhouse,8,cmdtext); dcmd(besichtigen, 11, cmdtext); dcmd(exit,4,cmdtext); dcmd(enter, 5, cmdtext); return 1; } /********************************************************************* ******************** Haus Betreten (enter) *************************** *********************************************************************/ dcmd_enter(playerid, params[]) { #pragma unused params new hName[100]; new Float: hx, Float: hy, Float: hz; new Float: hix, Float: hiy, Float: hiz; new in, vw, verschlossen, inbesitz; new pName[MAX_PLAYER_NAME], string[100]; GetPlayerName(playerid, pName, sizeof(pName)); for(new h = 0; h < MAX_HOUSES; h++) { format(hName, sizeof(hName), "House/Haus%d.ini", h); if(fexist(hName)) { hx = dini_Float(hName, "hx"); hy = dini_Float(hName, "hy"); hz = dini_Float(hName, "hz"); if(IsPlayerInRangeOfPoint(playerid, 3, hx, hy, hz)) { inbesitz = dini_Int(hName, "InBesitz"); if(inbesitz == 0) { SendClientMessage(playerid,COLOR_RED,"Du kannst dieses Haus nicht betreten. Versuchs mal mit /besichtigen."); } else { verschlossen = dini_Int(hName, "Verschlossen"); if(verschlossen == 0) { in = dini_Int(hName, "Interior"); vw = dini_Int(hName, "VirtualWorld"); hix = dini_Float(hName, "hix"); hiy = dini_Float(hName, "hiy"); hiz = dini_Float(hName, "hiz"); SetPlayerInterior(playerid, in); SetPlayerVirtualWorld(playerid, vw); SetPlayerPos(playerid, hix, hiy, hiz); } else { format(string, sizeof(string), "%s", dini_Get(hName, "Besitzer")); if(strcmp(pName, string, false) == 0) { in = dini_Int(hName, "Interior"); vw = dini_Int(hName, "VirtualWorld"); hix = dini_Float(hName, "hix"); hiy = dini_Float(hName, "hiy"); hiz = dini_Float(hName, "hiz"); SetPlayerInterior(playerid, in); SetPlayerVirtualWorld(playerid, vw); SetPlayerPos(playerid, hix, hiy, hiz); } else { SendClientMessage(playerid,COLOR_RED,"Dieses Haus ist leider verschlossen."); } } } } } } return 1; } /********************************************************************* ******************** Haus Verlassen (exit) *************************** *********************************************************************/ dcmd_exit(playerid, params[]) { #pragma unused params new hName[100]; new Float: hx, Float: hy, Float: hz; new Float: hix, Float: hiy, Float: hiz; new in, vw; for(new h = 0; h < MAX_HOUSES; h++) { format(hName, sizeof(hName), "House/Haus%d.ini", h); if(fexist(hName)) { hix = dini_Float(hName, "hix"); hiy = dini_Float(hName, "hiy"); hiz = dini_Float(hName, "hiz"); if(IsPlayerInRangeOfPoint(playerid, 3, hix, hiy, hiz)) { in = dini_Int(hName, "Interior"); vw = dini_Int(hName, "VirtualWorld"); if(in == GetPlayerInterior(playerid) && vw == GetPlayerVirtualWorld(playerid)) { hx = dini_Float(hName, "hx"); hy = dini_Float(hName, "hy"); hz = dini_Float(hName, "hz"); SetPlayerInterior(playerid, 0); SetPlayerVirtualWorld(playerid, 0); SetPlayerPos(playerid, hx, hy, hz); } } } } return 1; } /********************************************************************* ************************ Haus Besichtigen **************************** *********************************************************************/ dcmd_besichtigen(playerid, params[]) { #pragma unused params new hName[100]; new Float: hx, Float: hy, Float: hz; new Float: hix, Float: hiy, Float: hiz; new inbesitz; for(new h = 0; h < MAX_HOUSES; h++) { format(hName, sizeof(hName), "House/Haus%d.ini", h); if(fexist(hName)) { hx = dini_Float(hName, "hx"); hy = dini_Float(hName, "hy"); hz = dini_Float(hName, "hz"); if(IsPlayerInRangeOfPoint(playerid, 3, hx, hy, hz)) { inbesitz = dini_Int(hName, "InBesitz"); if(inbesitz == 0) { hix = dini_Float(hName, "hix"); hiy = dini_Float(hName, "hiy"); hiz = dini_Float(hName, "hiz"); SetPlayerVirtualWorld(playerid, dini_Int(hName, "VirtualWorld")); SetPlayerInterior(playerid, dini_Int(hName, "Interior")); SetPlayerPos(playerid, hix, hiy, hiz); SendClientMessage(playerid, COLOR_RED, "Tippe /exit um das Haus wieder zu verlassen."); } else { SendClientMessage(playerid, COLOR_RED, "Du kannst dieses Haus nicht besichtigen."); } } } } return 1; } /********************************************************************* ************************ Haus Kaufen ********************************* *********************************************************************/ dcmd_buyhouse(playerid, params[]) { #pragma unused params new hName[100]; new Float: hx, Float: hy, Float: hz; new inbesitz, preis; new pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); for(new h = 0; h < MAX_HOUSES; h++) { format(hName, sizeof(hName), "House/Haus%d.ini", h); if(fexist(hName)) { hx = dini_Float(hName, "hx"); hy = dini_Float(hName, "hy"); hz = dini_Float(hName, "hz"); if(IsPlayerInRangeOfPoint(playerid, 3, hx, hy, hz)) { inbesitz = dini_Int(hName, "InBesitz"); preis = dini_Int(hName, "Preis"); if(inbesitz == 0) { if(GetPlayerMoney(playerid) >= preis) { GivePlayerMoney(playerid, GetPlayerMoney(playerid) - preis); dini_IntSet(hName, "InBesitz", 2); dini_IntSet(hName, "Preis", 0); dini_Set(hName, "Besitzer", pName); //Dem Spieler wird das Haus zugeteilt usw.. UpdateHouse(h); SendClientMessage(playerid, COLOR_RED, "Du hast dieses Haus nun erfolgreich gekauft."); } else { SendClientMessage(playerid, COLOR_RED, "Du hast nicht genug Geld um dieses Haus zu kaufen."); } } else { SendClientMessage(playerid, COLOR_RED, "Dieses Haus steht nicht zum Verkauf bereit."); } } } } } /********************************************************************* ****************** Befehl zum Haus erstellen ************************* *********************************************************************/ dcmd_createhouse(playerid, params[]) { new Float:hx, Float: hy, Float:hz; new Preis; if(sscanf(params,"d",Preis)) { return SendClientMessage(playerid,COLOR_RED,"USAGE: /createhouse [Preis]"); } /*if(!IsPlayerAdmin(playerid)) //Deine Admin definition { return SendClientMessage(playerid,COLOR_RED,"Dein Admin Level reicht nicht aus."); }*/ GetPlayerPos(playerid ,hx, hy, hz); new hName[40]; dini_IntSet("House/Info.ini", "Max", dini_Int("House/Info.ini","Max") + 1); if(dini_Int("House/Info.ini", "Max") > MAX_HOUSES) { return SendClientMessage(playerid,COLOR_RED,"Die Maximale Anzahl an Häuser wurde erreicht."); } format(hName,sizeof(hName), "House/Haus%d.ini", dini_Int("House/Info.ini","Max")); dini_Create(hName); dini_FloatSet(hName, "hx", hx); dini_FloatSet(hName, "hy", hy); dini_FloatSet(hName, "hz", hz); dini_IntSet(hName, "InBesitz", 0); dini_Set(hName, "Besitzer", "Niemand"); dini_IntSet(hName, "Preis", Preis); dini_IntSet(hName, "VirtualWorld", dini_Int("House/Info.ini","Max")); dini_IntSet(hName, "Interior", 1); dini_FloatSet(hName, "hix", 244.411987); dini_FloatSet(hName, "hiy", 305.032989); dini_FloatSet(hName, "hiz", 999.148437); dini_IntSet(hName, "ID", dini_Int("House/Info.ini", "Max")); dini_IntSet(hName, "Verschlossen", 1); LoadHouse(dini_Int("House/Info.ini", "Max")); SendClientMessage(playerid, COLOR_RED, "Haus wurde erfolgreich erstellt."); return 1; } /************************************************************************* ************************* Haus Updaten *********************************** *************************************************************************/ public UpdateHouse(number) { new hName[40]; format(hName, sizeof(hName), "House/Haus%d.ini", number); if(!fexist(hName)) { return 0; } new string[200]; new besitzer[100]; format(besitzer, sizeof(besitzer), "%s", dini_Get(hName, "Besitzer")); new preis = dini_Int(hName, "Preis"); new inbesitz = dini_Int(hName, "InBesitz"); if(inbesitz == 0) { format(string,sizeof(string),"Diese Haus ist zu Verkaufen\nPreis: %d$\n/buyhouse zum kaufen\noder /besichtigen zum Ansehen", preis); } else if(inbesitz == 1) { format(string,sizeof(string),"Besitzer: %s\nMiete: %d$\nTippe: /rentroom", besitzer, preis); } else if(inbesitz == 2) { format(string,sizeof(string),"Besitzer: %s", besitzer); } Update3DTextLabelText(HouseLabel[number], COLOR_BLUE, string); return 1; } /************************************************************************ ************************* Haus Laden ************************************ ************************************************************************/ public LoadHouse(number) { new hName[40]; format(hName, sizeof(hName), "House/Haus%d.ini", number); if(!fexist(hName)) { return 0; } new Float: hx, Float: hy, Float: hz; hx = dini_Float(hName, "hx"); hy = dini_Float(hName, "hy"); hz = dini_Float(hName, "hz"); CreatePickup(1239, 1, hx, hy, hz); new string[200]; new besitzer[100]; format(besitzer, sizeof(besitzer), "%s", dini_Get(hName, "Besitzer")); new preis = dini_Int(hName, "Preis"); new inbesitz = dini_Int(hName, "InBesitz"); if(inbesitz == 0) { format(string,sizeof(string),"Diese Haus ist zu Verkaufen\nPreis: %d$\n/buyhouse zum kaufen\noder /besichtigen zum Ansehen", preis); } else if(inbesitz == 1) { format(string,sizeof(string),"Besitzer: %s\nMiete: %d$\nTippe: /rentroom", besitzer, preis); } else if(inbesitz == 2) { format(string,sizeof(string),"Besitzer: %s", besitzer); } HouseLabel[number] = Create3DTextLabel(string,COLOR_BLUE, hx, hy, hz, 20, 0, 1); return 1; }