Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dini>
- #include <bfx_imStream>
- #include <sscanf>
- #define FILTERSCRIPT
- #define MAX_HOUSE 500
- #define green 0x00AF00FF
- #define blue 0xBC1100FF
- #define error 0xC30000FF
- #define info 0x00C000FF
- #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- new file[255];
- new hausInfos[MAX_PLAYERS] = 0;
- new lastVirtualWorld = 0;
- forward loadHouse(id);
- forward saveHouse(id);
- forward unloadHouse(id);
- forward reloadHouse(id);
- forward resetInfos(playerid);
- enum houseIdConf {
- hInterior, Float:x,Float:y,Float:z
- }
- new hEnter[][houseIdConf] = {
- {3, 235.2818,1187.2037,1080.2578},
- {2, 225.756989, 1240.000000, 1082.149902},
- {1, 223.1909 ,1287.2478, 1082.1406},
- {7, 225.630997, 1022.479980, 1084.069946},
- {15, 294.6726,1473.5618,1080.2578},
- {15, 328.0414,1478.0096,1084.4375},
- {15, 385.803986, 1471.769897, 1080.209961},
- {1,2233.8032, 1712.2303, 1011.7632}
- };
- enum House {
- hPickupid,
- Text3D:hText,
- hMapID,
- hOwner[255],
- hPreis[255],
- Float:hX,
- Float:hY,
- Float:hZ,
- hLocked,
- hPickupExit,
- hEnterID,
- hVirtualWorld
- }
- new hInfo[MAX_HOUSE][House];
- public OnFilterScriptInit() {
- for (new i=1;i<=MAX_HOUSE;i++) {
- format(file,sizeof file, "House/House%d.cfg", i);
- if ( dini_Exists(file) ) { loadHouse(i); }
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- for (new i=1;i<=MAX_HOUSE;i++) {
- format(file,sizeof file, "House/House%d.cfg", i);
- if ( dini_Exists(file) ) { saveHouse(i); unloadHouse(i); }
- }
- return 1;
- }
- public resetInfos(playerid) {
- hausInfos[playerid] = 0;
- return 1;
- }
- public saveHouse(id) {
- format(file,sizeof file, "House/House%d.cfg", id);
- if ( dini_Exists(file) ) {
- dini_Set(file, "Owner", hInfo[id][hOwner]);
- }
- return 1;
- }
- public reloadHouse(id) {
- unloadHouse(id);
- loadHouse(id);
- return 1;
- }
- public unloadHouse(id) {
- if ( dini_Exists("House/") ) {
- format(file,sizeof file, "House/House%d.cfg", id);
- if ( dini_Exists(file) ) {
- bRemoveMapIcon(hInfo[id][hMapID]);
- DestroyPickup(hInfo[id][hPickupid]);
- DestroyPickup(hInfo[id][hPickupExit]);
- Delete3DTextLabel(hInfo[id][hText]);
- }
- }
- return 1;
- }
- public loadHouse(id) {
- new pID, mID, color;
- if ( dini_Exists("House/") ) {
- format(file,sizeof file, "House/House%d.cfg", id);
- if ( dini_Exists(file) ) {
- hInfo[id][hOwner] = dini_Get(file, "Owner");
- hInfo[id][hPreis] = dini_Int(file, "Preis");
- hInfo[id][hEnterID] = dini_Int(file, "Int");
- hInfo[id][hLocked] = dini_Int(file, "Locked");
- hInfo[id][hX] = dini_Float(file, "hX");
- hInfo[id][hY] = dini_Float(file, "hY");
- hInfo[id][hZ] = dini_Float(file, "hZ");
- if(!strcmp(hInfo[id][hOwner], "Staat", false)) {
- pID = 1273;
- mID = 31;
- color = green;
- }
- else { pID = 1272; mID = 32; color = blue; }
- lastVirtualWorld = dini_Int(file, "VW");
- hInfo[id][hVirtualWorld] = lastVirtualWorld;
- hInfo[id][hMapID] = bCreateMapIcon(hInfo[id][hX],hInfo[id][hY],hInfo[id][hZ], mID, 0);
- hInfo[id][hPickupid] = CreatePickup(pID, 1, hInfo[id][hX],hInfo[id][hY],hInfo[id][hZ], 0);
- hInfo[id][hPickupExit] = CreatePickup(1318, 1, hEnter[hInfo[id][hEnterID]][x],hEnter[hInfo[id][hEnterID]][y],hEnter[hInfo[id][hEnterID]][z], hInfo[id][hVirtualWorld]);
- new string[255];
- if ( mID == 31 ) { format(string,sizeof string, "Besitzer: %s\nPreis: %d$", hInfo[id][hOwner], hInfo[id][hPreis]); }
- else { format(string,sizeof string, "Besitzer: %s\nPreis: Nicht zum Verkauf", hInfo[id][hOwner]); }
- hInfo[id][hText] = Create3DTextLabel(string, color, hInfo[id][hX],hInfo[id][hY],hInfo[id][hZ] + 0.5,10.0,0);
- }
- }
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(lock,4,cmdtext);
- dcmd(createhouse, 11, cmdtext);
- return 0;
- }
- public OnPlayerDeath(playerid, killerid, reason) {
- SetPlayerVirtualWorld(playerid, 0);
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
- new houseID = hausInfos[playerid], string[255], name[255];
- switch(dialogid) {
- case 1800: {
- if ( response == 1 ) {
- if(!strcmp(hInfo[houseID][hOwner], "Staat", false)) {
- if ( GetPlayerMoney(playerid) >=hInfo[houseID][hPreis] ) {
- GetPlayerName(playerid, name, 255);
- hInfo[houseID][hOwner] = name;
- GivePlayerMoney(playerid, -hInfo[houseID][hPreis]);
- saveHouse(houseID);
- reloadHouse(houseID);
- GameTextForPlayer(playerid, "Immobilien gekauft", 2000, 1);
- }
- else { SendClientMessage(playerid, error, "Du hast nicht genug Geld."); }
- }
- else { SendClientMessage(playerid, error, "Das Haus steht nicht zum Verkauf."); }
- }
- SetTimerEx("resetInfos", 2000, 0, "i", playerid);
- }
- case 1801: {
- if ( response == 1 ) {
- GetPlayerName(playerid, name, 255);
- if(!strcmp(hInfo[houseID][hOwner], name, false)) {
- SendClientMessage(playerid, info, "Du bist jetzt in deinem Haus.");
- SetPlayerInterior(playerid, hEnter[hInfo[houseID][hEnterID]][hInterior]);
- SetPlayerPos(playerid, hEnter[hInfo[houseID][hEnterID]][x],hEnter[hInfo[houseID][hEnterID]][y],hEnter[hInfo[houseID][hEnterID]][z]);
- SetPlayerVirtualWorld(playerid, hInfo[houseID][hVirtualWorld]);
- }
- else {
- if ( hInfo[houseID][hLocked] == 1 ) { SendClientMessage(playerid, error, "Das Haus ist abgeschlossen."); }
- else {
- SendClientMessage(playerid, info, "Du hast das Haus betreten.");
- SetPlayerInterior(playerid, hEnter[hInfo[houseID][hEnterID]][hInterior]);
- SetPlayerPos(playerid, hEnter[hInfo[houseID][hEnterID]][x],hEnter[hInfo[houseID][hEnterID]][y],hEnter[hInfo[houseID][hEnterID]][z]);
- SetPlayerVirtualWorld(playerid, hInfo[houseID][hVirtualWorld]);
- }
- }
- }
- SetTimerEx("resetInfos", 2000, 0, "i", playerid);
- }
- case 1802: {
- if ( response == 1 ) {
- SetPlayerVirtualWorld(playerid, 0);
- SetPlayerInterior(playerid, 0);
- SetPlayerPos(playerid, hInfo[houseID][hX],hInfo[houseID][hY],hInfo[houseID][hZ]);
- format(string,sizeof string, "Du hast das Haus von %s verlassen", hInfo[houseID][hOwner]);
- SendClientMessage(playerid, info, string);
- SetTimerEx("resetInfos", 3500, 0, "i", playerid);
- }
- else { SetTimerEx("resetInfos", 2000, 0, "i", playerid); }
- }
- case 1803: {
- if ( response == 1 ) {
- new house = strval(inputtext);
- GetPlayerName(playerid, name, 255);
- format(string,sizeof string, "House/House%d.cfg", house);
- if ( dini_Exists(string) ) {
- new owner[255];
- owner = dini_Get(string, "Owner");
- if( !strcmp(owner, name, false)) {
- if ( hInfo[house][hLocked] == 1 ) { hInfo[house][hLocked] = 0; SendClientMessage(playerid, info, "Dein Haus wurde aufgeschlossen."); }
- else { hInfo[house][hLocked] = 1; SendClientMessage(playerid, info, "Dein Haus wurde abgeschlossen."); }
- }
- else { SendClientMessage(playerid, error, "Das Haus gehört nicht dir."); }
- }
- else { SendClientMessage(playerid, error, "Es existiert kein Haus mit dieser Hausnummer."); }
- }
- }
- }
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid) {
- new string[255], houseEnter = -1, houseExit = -1, button[255], verkaufstatus[255];
- for (new i=1;i<MAX_HOUSE;i++) {
- format(file,sizeof file, "House/House%d.cfg", i);
- if ( dini_Exists(file) ) {
- if ( hInfo[i][hPickupid] == pickupid ) { houseEnter = i; format(string,sizeof string, "%d - %d",hInfo[i][hPickupid], pickupid); }
- if ( hInfo[i][hPickupExit] == pickupid ) { houseExit = i; format(string,sizeof string, "%d - %d",hInfo[i][hPickupExit], pickupid); }
- }
- }
- if ( houseEnter != -1 && hausInfos[playerid] <= 0 ) {
- new houseNR = houseEnter;
- hausInfos[playerid] = houseNR;
- format(button, 255, ""); format(verkaufstatus,255, "Nicht zum Verkauf");
- if(!strcmp(hInfo[houseNR][hOwner], "Staat", false)) {
- format(verkaufstatus,255, "%d$", hInfo[houseNR][hPreis]);
- format(string,sizeof string, "Hausnummer:\t\t %d\nBesitzer:\t\t %s\nPreis:\t\t\t %s", houseNR, hInfo[houseNR][hOwner], verkaufstatus);
- ShowPlayerDialog(playerid, 1800, DIALOG_STYLE_MSGBOX, "Haus Informationen", string, "Kaufen", "Schließen");
- }
- else {
- format(button, 255, ""); format(verkaufstatus,255, "Nicht zum Verkauf");
- format(string,sizeof string, "Hausnummer:\t\t %d\nBesitzer:\t\t %s\nPreis:\t\t\t %s", houseNR, hInfo[houseNR][hOwner], verkaufstatus);
- ShowPlayerDialog(playerid, 1801, DIALOG_STYLE_MSGBOX, "Haus Informationen", string, "Betreten", "Schließen");
- }
- }
- else if ( houseExit != -1 && hausInfos[playerid] <= 0 ) {
- new houseNR = houseExit;
- hausInfos[playerid] = houseNR;
- format(string,sizeof string, "Willst du das Haus von %s verlassen?", hInfo[houseNR][hOwner]);
- ShowPlayerDialog(playerid, 1802, DIALOG_STYLE_MSGBOX, "Haus Informationen", string, "Ja", "Nein");
- }
- return 1;
- }
- dcmd_lock(playerid, params[]) {
- #pragma unused params
- PlayerWillLockHouse(playerid);
- return 1;
- }
- dcmd_createhouse(playerid, params[]) {
- new preis, string[255], interior;
- if ( IsPlayerAdmin(playerid) ) {
- format(string, sizeof(string), "Bitte benutze /Createhouse [Geld] [HausID].");
- if ( sscanf(params, "ii", preis, interior) ) { SendClientMessage(playerid, error, string); }
- else {
- if ( interior <= sizeof hEnter - 1 ) {
- new Float:pX, Float:pY, Float:pZ;
- GetPlayerPos(playerid, pX, pY, pZ);
- new first = -1;
- for (new i=1;i<=MAX_HOUSE;i++) {
- format(file,sizeof file, "House/House%d.cfg", i);
- if ( !dini_Exists(file) && first == -1 ) { first = i; }
- }
- format(file,sizeof file, "House/House%d.cfg", first);
- format(string,255,"Staat");
- dini_Create(file);
- dini_Set(file, "Owner", string);
- dini_IntSet(file, "Preis", preis);
- dini_IntSet(file, "Int", interior);
- dini_IntSet(file, "Locked", 1);
- dini_IntSet(file, "VW", lastVirtualWorld + 1);
- dini_FloatSet(file, "hX", pX);
- dini_FloatSet(file, "hY", pY);
- dini_FloatSet(file, "hZ", pZ);
- hInfo[first][hOwner] = string;
- hInfo[first][hPreis] = preis;
- hInfo[first][hEnterID] = interior;
- hInfo[first][hVirtualWorld] = lastVirtualWorld + 1;
- hInfo[first][hX] = pX,hInfo[first][hY] = pY,hInfo[first][hZ] = pZ;
- loadHouse(first);
- lastVirtualWorld ++;
- }
- else { SendClientMessage(playerid, error, "Falsche Interior Zahl."); }
- }
- } else { SendClientMessage(playerid, error, "Du bist kein Admin."); }
- return 1;
- }
- forward PlayerWillLockHouse(playerid);
- public PlayerWillLockHouse(playerid) {
- new Float:pX, Float:pY, Float:pZ, name[255], hasHouse;
- GetPlayerPos(playerid, pX, pY, pZ);
- GetPlayerName(playerid, name, 255);
- for (new i=1;i<MAX_HOUSE;i++) {
- format(file,sizeof file, "House/House%d.cfg", i);
- if ( dini_Exists(file) ) {
- if( !strcmp(hInfo[i][hOwner], name, false)) { hasHouse ++; }
- }
- }
- if ( hasHouse >= 1 ) { ShowPlayerDialog(playerid, 1803, DIALOG_STYLE_INPUT, "Haus", "Bitte gib eine Haus Nummer ein.", "Bestätigen", "Abbrechen"); }
- else { SendClientMessage(playerid, error, "Du hast kein Haus"); }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment