Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Haussystem by Items4Landwirt aka Music4You
- - Es ist verboten meinen Namen aus dem Skript zu löschen!
- - Es ist verboten Dieses Skript nocheinmal zu veröffentlichen
- - Es ist verboten Dieses Skript als eigenes auszugeben.
- Nun noch ein Paar YT Kanäle, von guten Freunden
- Music4You http://www.youtube.com/user/Music4You43
- Items4Sacred http://www.youtube.com/user/items4sacred
- Metalletsplay666 http://www.youtube.com/user/MetalLetsPlay666
- */
- #define FILTERSCRIPT
- #define DEBUG
- ////=============== Includes ===============
- #include <a_samp>
- #include <ocmd>
- #include <streamer>
- //=============== Defines ===============
- #define rot 0xFF0A00FF
- #define gruen 0x4BB400FF
- #define orange 0xFF9600FF
- #define SCM SendClientMessage
- #define MAX_HAUS 100
- ////=============== News ===============
- new DB:Database, house, houseint[MAX_PLAYERS],inhouse[MAX_PLAYERS];
- enum haus
- {
- Float:X,
- Float:Y,
- Float:Z,
- hausobjekt,
- hPickup,
- Text3D:hLabel,
- Preis,
- vergeben,
- Besitzer[MAX_PLAYER_NAME],
- locked,
- hInt,
- bool:erstellt
- }
- new HausInfo[MAX_HAUS][haus];
- public OnFilterScriptInit()
- {
- print("\n=================================================");
- print(" SQLite Haussystem by Music4You aka Items4Landwirt");
- print("===================================================\n");
- DisableInteriorEnterExits();
- Database = db_open("Haus.db");
- db_query(Database,"CREATE TABLE IF NOT EXISTS `haus`(`ID`,`X`,`Y`,`Z`,`Preis`,`vergeben`,`Besitzer`,`locked`,`hInt`)");
- createhouse();
- #if defined DEBUG
- print("Tabellen wurden erstellt!\nHäuser Geladen!");
- #endif
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- ocmd:chaus(playerid,params[])
- {
- new Float:x,Float:y,Float:z,Float:a,preis,inter,Text[256], query[256];
- if(!IsPlayerAdmin(playerid)) return SCM(playerid,rot,"Du bist nicht befugt!");
- if(sscanf(params,"dd", preis,inter)) return SCM(playerid,rot,"Benutze: /chaus [Preis][Interior ID (1-3)]");
- GetPlayerPos(playerid, x, y, z);
- GetPlayerFacingAngle(playerid,a);
- for(new i = 0;i < MAX_HAUS; i++)
- {
- if(HausInfo[i][erstellt] == true)continue;
- HausInfo[i][erstellt] = true;
- HausInfo[i][X] = x;
- HausInfo[i][Y] = y;
- HausInfo[i][Z] = z;
- HausInfo[i][Preis] = preis;
- HausInfo[i][vergeben] = 0;
- HausInfo[i][Besitzer] = 0;
- HausInfo[i][locked] = 1;
- HausInfo[i][hInt] = inter;
- HausInfo[i][hausobjekt] = CreateDynamicPickup(1273, 1, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z]);
- format(Text,sizeof(Text),"Haus %d Zum Verkauf\n\nPreis:\t%d",i,HausInfo[i][Preis]);
- HausInfo[i][hLabel] = Create3DTextLabel(Text, orange, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z], 15, 0);
- format(query,sizeof(query),"INSERT INTO `haus` (`ID`, `X`,`Y`,`Z`,`Preis`,`vergeben`,`Besitzer`,`locked`,`hInt`) VALUES ('%i','%f','%f','%f','%d','0','Niemand','1','%d')",i,x,y,z,preis,inter);
- db_query(Database,query);
- SCM(playerid,gruen,"Haus erstellt");
- #if defined DEBUG
- print(query);
- #endif
- return 1;
- }
- return SCM(playerid,rot,"Es wude bereits die Maximale Anzahl von Häusern erstellt!");
- }
- ocmd:delhaus(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return SCM(playerid,rot,"Du bist nicht befugt!");
- new id = IsHaus(playerid),query[256];
- if(id != -1)
- {
- HausInfo[id][erstellt] = false;
- HausInfo[id][X] = 0.0;
- HausInfo[id][Y] = 0.0;
- HausInfo[id][Z] = 0.0;
- HausInfo[id][Preis] = 0;
- HausInfo[id][vergeben] = 0;
- HausInfo[id][Besitzer] = 0;
- HausInfo[id][locked] = 0;
- HausInfo[id][hInt] = 0;
- SCM(playerid,gruen,"Du hast das Haus gelöscht");
- DestroyDynamicPickup(HausInfo[id][hausobjekt]);
- Delete3DTextLabel(HausInfo[id][hLabel]);
- format(query,sizeof(query),"SELECT * FROM haus WHERE ID = '%d'",id);
- format(query,sizeof(query),"DELETE FROM haus WHERE ID = '%d'",id);
- db_query(Database,query);
- #if defined DEBUG
- print(query);
- #endif
- return 1;
- }
- else return SCM(playerid,rot,"Du bist an keinem Haus");
- }
- ocmd:delallhaus(playerid,params[])
- {
- if(!IsPlayerAdmin(playerid)) return SCM(playerid,rot,"Du bist nicht befugt!");
- for(new i=0,query[128];i<MAX_HAUS;i++)
- {
- HausInfo[i][erstellt] = false;
- HausInfo[i][X] = 0.0;
- HausInfo[i][Y] = 0.0;
- HausInfo[i][Z] = 0.0;
- HausInfo[i][Preis] = 0;
- HausInfo[i][vergeben] = 0;
- HausInfo[i][Besitzer] = 0;
- HausInfo[i][locked] = 0;
- HausInfo[i][hInt] = 0;
- DestroyDynamicPickup(HausInfo[i][hausobjekt]);
- Delete3DTextLabel(HausInfo[i][hLabel]);
- format(query,sizeof(query),"SELECT * FROM haus WHERE ID = '%d'",i);
- format(query,sizeof(query),"DELETE FROM haus WHERE ID = '%d'",i);
- db_query(Database,query);
- #if defined DEBUG
- print(query);
- #endif
- }
- SCM(playerid,gruen,"Du hast alle häuser gelöscht");
- return 1;
- }
- ocmd:hauskaufen(playerid,params[])
- {
- new id = IsHaus(playerid),Text[256],query[256];
- if(id != -1)
- {
- if(HausInfo[id][vergeben] != 0) return SCM(playerid,rot,"Das haus ist bereits vergeben!");
- HausInfo[id][vergeben] = 1;
- HausInfo[id][Besitzer] = SpielerName(playerid);
- SCM(playerid,gruen,"Du hast das Haus gekauft");
- GivePlayerMoney(playerid,-HausInfo[id][Preis]);
- Delete3DTextLabel(HausInfo[id][hLabel]);
- DestroyDynamicPickup(HausInfo[id][hausobjekt]);
- HausInfo[id][hausobjekt] = CreateDynamicPickup(1239, 1, HausInfo[id][X], HausInfo[id][Y], HausInfo[id][Z]);
- format(Text,sizeof(Text),"Haus\nBesitzer:\t%s\nVerschlossen:\tJa",HausInfo[id][Besitzer]);
- HausInfo[id][hLabel] = Create3DTextLabel(Text, orange, HausInfo[id][X], HausInfo[id][Y], HausInfo[id][Z], 15, 0);
- format(query,sizeof(query),"UPDATE `haus` SET `vergeben` = '%d',`Besitzer` = '%s' WHERE `ID` = '%d'",HausInfo[id][vergeben],HausInfo[id][Besitzer],id);
- db_query(Database,query);
- #if defined DEBUG
- print(query);
- #endif
- return 1;
- }
- else return SCM(playerid,rot,"Du bist an keinem Haus");
- }
- ocmd:hausverkaufen(playerid,params[])
- {
- new id = IsHaus(playerid),Text[256],query[256];
- if(id != -1)
- {
- if(HausInfo[id][vergeben] != 1) return SCM(playerid,rot,"Du kannst das Haus nich verkaufen!");
- if(strcmp(HausInfo[id][Besitzer], SpielerName(playerid), false)) return SCM(playerid,rot,"Das ist nicht dein Haus!");
- HausInfo[id][vergeben] = 0;
- HausInfo[id][Besitzer] = 0;
- HausInfo[id][locked]=1;
- SCM(playerid,gruen,"Du hast das Haus Verkauft");
- GivePlayerMoney(playerid,HausInfo[id][Preis]);
- Delete3DTextLabel(HausInfo[id][hLabel]);
- format(Text,sizeof(Text),"Haus %d Zum Verkauf\n\nPreis:\t%d",id,HausInfo[id][Preis]);
- HausInfo[id][hLabel] = Create3DTextLabel(Text, orange, HausInfo[id][X], HausInfo[id][Y], HausInfo[id][Z], 15, 0);
- format(query,sizeof(query),"UPDATE `haus` SET `vergeben` = '%d',`Besitzer` = 'Niemand',`locked`='1' WHERE `ID` = '%d'",HausInfo[id][vergeben],id);
- db_query(Database,query);
- #if defined DEBUG
- print(query);
- #endif
- return 1;
- }
- else return SCM(playerid,rot,"Du bist an keinem Haus");
- }
- ocmd:aufschliessen(playerid,params[])
- {
- new id = IsHaus(playerid),Text[256],query[256];
- if(id != -1)
- {
- if(HausInfo[id][vergeben] != 1) return SCM(playerid,rot,"Du kannst das Haus nich Abschließen!");
- if(strcmp(HausInfo[id][Besitzer], SpielerName(playerid), false)) return SCM(playerid,rot,"Das ist nicht dein Haus!");
- if(HausInfo[id][locked]!=0) return SCM(playerid,rot,"Das Haus ist bereits Abgeschlossen!");
- HausInfo[id][locked]=1;
- Delete3DTextLabel(HausInfo[id][hLabel]);
- format(Text,sizeof(Text),"Haus\nBesitzer:\t%s\nVerschlossen:\tJa:",HausInfo[id][Besitzer]);
- HausInfo[id][hLabel] = Create3DTextLabel(Text, orange, HausInfo[id][X], HausInfo[id][Y], HausInfo[id][Z], 15, 0);
- format(query,sizeof(query),"UPDATE `haus` SET `locked` = '1' WHERE `ID` = '%d'",id);
- db_query(Database,query);
- SCM(playerid,gruen,"Du hast dein Haus Abgeschlossen");
- #if defined DEBUG
- print(query);
- #endif
- return 1;
- }
- else return SCM(playerid,rot,"Du bist an keinem Haus");
- }
- ocmd:abschliessen(playerid,params[])
- {
- new id = IsHaus(playerid),Text[256],query[256];
- if(id != -1)
- {
- if(HausInfo[id][vergeben] != 1) return SCM(playerid,rot,"Du kannst das Haus nich Abschließen!");
- if(strcmp(HausInfo[id][Besitzer], SpielerName(playerid), false)) return SCM(playerid,rot,"Das ist nicht dein Haus!");
- if(HausInfo[id][locked]!=1) return SCM(playerid,rot,"Das Haus ist bereits Aufgeschlossen!");
- HausInfo[id][locked]=0;
- Delete3DTextLabel(HausInfo[id][hLabel]);
- format(Text,sizeof(Text),"Haus\nBesitzer:\t%s\nVerschlossen:\tNein",HausInfo[id][Besitzer]);
- HausInfo[id][hLabel] = Create3DTextLabel(Text, orange, HausInfo[id][X], HausInfo[id][Y], HausInfo[id][Z], 15, 0);
- format(query,sizeof(query),"UPDATE `haus` SET `locked` = '0' WHERE `ID` = '%d'",id);
- db_query(Database,query);
- SCM(playerid,gruen,"Du hast dein Haus Aufgeschlossen");
- #if defined DEBUG
- print(query);
- #endif
- return 1;
- }
- else return SCM(playerid,rot,"Du bist an keinem Haus");
- }
- ocmd:betreten(playerid,params[])
- {
- new id = IsHaus(playerid);
- if(id != -1)
- {
- if(HausInfo[id][vergeben] != 1) return SCM(playerid,rot,"Du kannst das Haus nich Betreten!");
- if(HausInfo[id][locked]!=0) return SCM(playerid,rot,"Das Haus ist Abgeschlossen");
- switch(HausInfo[id][hInt])
- {
- case 0:
- {
- SCM(playerid,rot,"ERROR: kein interior vergeben, melde dich bei einem Admin!");
- }
- case 1:
- {
- SetPlayerPos(playerid,318.564971,1118.209960,1083.882812);
- SetPlayerInterior(playerid,5);
- SetPlayerVirtualWorld(playerid,id);
- houseint[playerid]=id;
- inhouse[playerid]=1;
- SCM(playerid,gruen,"Du hast das Haus Betreten");
- }
- case 2:
- {
- SetPlayerPos(playerid,2324.419921,-1145.568359,1050.710083);
- SetPlayerInterior(playerid,12);
- SetPlayerVirtualWorld(playerid,id);
- houseint[playerid]=id;
- inhouse[playerid]=1;
- SCM(playerid,gruen,"Du hast das Haus Betreten");
- }
- case 3:
- {
- SetPlayerPos(playerid,1267.663208,-781.323242,1091.906250);
- SetPlayerInterior(playerid,5);
- SetPlayerVirtualWorld(playerid,id);
- houseint[playerid]=id;
- inhouse[playerid]=1;
- SCM(playerid,gruen,"Du hast das Haus Betreten");
- }
- }
- return 1;
- }
- else return SCM(playerid,rot,"Du bist an keinem Haus");
- }
- ocmd:verlassen(playerid,params[])
- {
- new DBResult:Result, str[512],id=houseint[playerid];
- if(inhouse[playerid]!=1)return SCM(playerid,rot,"Du bist in keinem Haus!");
- format(str,sizeof(str),"SELECT * FROM `haus` WHERE `ID` = '%i'",houseint[playerid]);
- Result = db_query(Database,str);
- db_get_field_assoc(Result,"X",str,sizeof(str));
- HausInfo[id][X]=floatstr(str);
- db_get_field_assoc(Result,"Y",str,sizeof(str));
- HausInfo[id][Y]=floatstr(str);
- db_get_field_assoc(Result,"Z",str,sizeof(str));
- HausInfo[id][Z]=floatstr(str);
- SetPlayerPos(playerid,HausInfo[id][X],HausInfo[id][Y],HausInfo[id][Z]);
- SetPlayerInterior(playerid,0);
- SetPlayerVirtualWorld(playerid,0);
- houseint[playerid]=0;
- inhouse[playerid]=0;
- db_free_result(Result);
- return 1;
- }
- stock SpielerName(playerid)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof(name));
- return name;
- }
- stock IsHaus(playerid)
- {
- new i=0;
- while(i != MAX_HAUS)
- {
- if(IsPlayerInRangeOfPoint(playerid, 3.0, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z])) return i;
- i++;
- }
- return -1;
- }
- stock createhouse()
- {
- new DBResult:Result, str[512],Text[256], rows,i=0;
- for(;i<MAX_HAUS;i++)
- {
- format(str,sizeof(str),"SELECT * FROM `haus` WHERE `ID` = '%i'",i);
- Result = db_query(Database,str);
- rows = db_num_rows(Result);
- if(rows == 0)continue;
- db_get_field_assoc(Result,"X",str,sizeof(str));
- HausInfo[i][X]=floatstr(str);
- db_get_field_assoc(Result,"Y",str,sizeof(str));
- HausInfo[i][Y]=floatstr(str);
- db_get_field_assoc(Result,"Z",str,sizeof(str));
- HausInfo[i][Z]=floatstr(str);
- db_get_field_assoc(Result,"Preis",str,sizeof(str));
- HausInfo[i][Preis]=strval(str);
- db_get_field_assoc(Result,"vergeben",str,sizeof(str));
- HausInfo[i][vergeben]=strval(str);
- db_get_field_assoc(Result,"Besitzer",str,sizeof(str));
- format(HausInfo[i][Besitzer],MAX_PLAYER_NAME,"%s",str);
- db_get_field_assoc(Result,"locked",str,sizeof(str));
- HausInfo[i][locked]=strval(str);
- db_get_field_assoc(Result,"hInt",str,sizeof(str));
- HausInfo[i][hInt]=strval(str);
- HausInfo[i][erstellt] = true;
- house++;
- if(HausInfo[i][vergeben] == 1)
- {
- new lock[20];
- if(HausInfo[i][locked] == 1) { lock = "Ja"; }
- else if(HausInfo[i][locked] == 0) { lock = "Nein"; }
- format(Text,sizeof(Text),"Haus\nBesitzer:\t%s\nVerschlossen\t%s",HausInfo[i][Besitzer],locked);
- HausInfo[i][hausobjekt] = CreateDynamicPickup(1239, 1, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z]);
- }
- else
- {
- format(Text,sizeof(Text),"Haus %d Zum Verkauf\n\nPreis:\t%d",i,HausInfo[i][Preis]);
- HausInfo[i][hausobjekt] = CreateDynamicPickup(1273, 1, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z]);
- }
- HausInfo[i][hLabel] = Create3DTextLabel(Text, orange, HausInfo[i][X], HausInfo[i][Y], HausInfo[i][Z], 15, 0);
- db_free_result(Result);
- }
- printf(" **Es wurde %d Häuser erfolgreich Geladen**",house);
- }
- stock sscanf(string[], format[], {Float,_}:...)
- {
- #if defined isnull
- if (isnull(string))
- #else
- if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
- #endif
- {
- return format[0];
- }
- #pragma tabsize 4
- new
- formatPos = 0,
- stringPos = 0,
- paramPos = 2,
- paramCount = numargs(),
- delim = ' ';
- while (string[stringPos] && string[stringPos] <= ' ')
- {
- stringPos++;
- }
- while (paramPos < paramCount && string[stringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = string[stringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = string[++stringPos];
- }
- do
- {
- stringPos++;
- if ('0' <= ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return -1;
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- num = 0,
- ch = string[stringPos];
- do
- {
- stringPos++;
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- default:
- {
- return -1;
- }
- }
- }
- while ((ch = string[stringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, string[stringPos++]);
- }
- case 'f':
- {
- new changestr[16], changepos = 0, strpos = stringPos;
- while(changepos < 16 && string[strpos] && string[strpos] != delim)
- {
- changestr[changepos++] = string[strpos++];
- }
- changestr[changepos] = '\0';
- setarg(paramPos,0,_:floatstr(changestr));
- }
- case 'p':
- {
- delim = format[formatPos++];
- continue;
- }
- case '\'':
- {
- new
- end = formatPos - 1,
- ch;
- while ((ch = format[++end]) && ch != '\'') {}
- if (!ch)
- {
- return -1;
- }
- format[end] = '\0';
- if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
- {
- if (format[end + 1])
- {
- return -1;
- }
- return 0;
- }
- format[end] = '\'';
- stringPos = ch + (end - formatPos);
- formatPos = end + 1;
- }
- case 'u':
- {
- new
- end = stringPos - 1,
- id = 0,
- bool:num = true,
- ch;
- while ((ch = string[++end]) && ch != delim)
- {
- if (num)
- {
- if ('0' <= ch <= '9')
- {
- id = (id * 10) + (ch - '0');
- }
- else
- {
- num = false;
- }
- }
- }
- if (num && IsPlayerConnected(id))
- {
- setarg(paramPos, 0, id);
- }
- else
- {
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- string[end] = '\0';
- num = false;
- new
- name[MAX_PLAYER_NAME];
- id = end - stringPos;
- foreach (Player, playerid)
- {
- GetPlayerName(playerid, name, sizeof (name));
- if (!strcmp(name, string[stringPos], true, id))
- {
- setarg(paramPos, 0, playerid);
- num = true;
- break;
- }
- }
- if (!num)
- {
- setarg(paramPos, 0, INVALID_PLAYER_ID);
- }
- string[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }
- stringPos = end;
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = string[stringPos++]) && ch != delim)
- {
- setarg(paramPos, i++, ch);
- }
- if (!i)
- {
- return -1;
- }
- }
- else
- {
- while ((ch = string[stringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- stringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
- {
- stringPos++;
- }
- while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
- {
- stringPos++;
- }
- paramPos++;
- }
- do
- {
- if ((delim = format[formatPos++]) > ' ')
- {
- if (delim == '\'')
- {
- while ((delim = format[formatPos++]) && delim != '\'') {}
- }
- else if (delim != 'z')
- {
- return delim;
- }
- }
- }
- while (delim > ' ');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement