Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Dynamisches Biz System by Freakynight
- !!!!-Ihr müsst den Ordner "Bizz" in den Scritpfiles erstellen-!!!!
- */
- #include <a_samp>
- #include <dini>
- #include <ocmd>
- #define MAX_BIZZ 500 //Wie viele Bizzes
- #define BLAU "{0080FF}" //farbe für Pickup | BLAU
- #define WEISS "{FFFFFF}" //Farbe für Pickup | WEISS
- #define BLUE 0x0000FFFF
- #define ROT 0xE10000FF
- new inBizz[MAX_PLAYERS] = -1;
- enum BizzInformationen
- {
- Float:PosX,
- Float:PosY,
- Float:PosZ,
- Besitzer[64],
- Besetzt,
- Preis,
- Level,
- Konto,
- Interior,
- Text3D:Label,
- Pickup,
- World
- }
- new bInfo[MAX_BIZZ][BizzInformationen];
- enum BizzInnen
- {
- Float:SpawnX,
- Float:SpawnY,
- Float:SpawnZ,
- Int
- }
- new bInt[][BizzInnen] =
- {
- {363.4149,-74.2596,1001.5078,10}, //BSN
- {365.7547,-10.8823,1001.8516,9}, //cluckin
- {372.1370,-132.7309,1001.4922,5}, //well stacked pizza
- {286.1115,-41.3004,1001.5156,1}, //ammu
- {206.9614,-139.4169,1003.5078,3}, //Kleidung
- {-26.9958,-30.0071,1003.5573,4}, //24/7
- {771.9066,-3.8409,1000.7285,5}, //gym
- {493.4917,-23.5213,1000.6797,17} //disco
- };
- //Ihr könnt neue Interiorbizzes erstellen indem ihr hier oben es so einfügt: SpawnX,SpawnY,SpawnZ,Interior
- public OnFilterScriptInit()
- {
- print("\n----------------");
- print("BizSystem by Freakynight wurde geladen.");
- print("----------------\n");
- for(new b = 1; b <MAX_BIZZ; b++)
- {
- LoadBizz(b);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- ocmd:cbizz(playerid,params[])
- {
- if(IsPlayerAdmin(playerid))
- {
- new Float:x,Float:y,Float:z,preis,level,int;
- if(sscanf(params,"ddd",preis,level,int))return SendClientMessage(playerid,BLUE,"Benutze: /cbizz [PREIS] [LEVEL] [INT-NR]");
- GetPlayerPos(playerid,x,y,z);
- CreateBizz(x,y,z,"Keiner",preis,level,int,playerid+20+preis);
- }
- return 1;
- }
- ocmd:sellfirma(playerid,params[])
- {
- for(new b = 1; b <MAX_BIZZ; b++)
- {
- if(IsPlayerInRangeOfPoint(playerid,5,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]))
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof name);
- if(strcmp(bInfo[b][Besitzer],name,false) == 0)
- {
- SendClientMessage(playerid,BLUE,"Sie haben ihr Bizz an den Staat verkauft!");
- GivePlayerMoney(playerid,bInfo[b][Preis]);
- new BizzDatei[50];
- format(BizzDatei,50,"/Bizz/%d.txt",b);
- dini_IntSet(BizzDatei,"Besetzt",0);
- dini_Set(BizzDatei,"Besitzer","Keiner");
- KillBizz(b);
- LoadBizz(b);
- }
- else SendClientMessage(playerid,ROT,"Du bist nicht der Besitzer von dem Bizz!");
- }
- }
- return 1;
- }
- ocmd:bizhelp(playerid,params[])
- {
- SendClientMessage(playerid,-1,"/bauszahlen - /beinzahlen - /buyfirma - /sellfirma - /bkonto");
- return 1;
- }
- ocmd:bkonto(playerid,params[])
- {
- for(new b = 1; b <MAX_BIZZ; b++)
- {
- new Innenraum = bInfo[b][Interior];
- if(IsPlayerInRangeOfPoint(playerid,20,bInt[Innenraum][SpawnX],bInt[Innenraum][SpawnY],bInt[Innenraum][SpawnZ]))
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof name);
- if(strcmp(bInfo[b][Besitzer],name,false) == 1)
- {
- new string[188];
- format(string,sizeof(string),"In deinem Biz sind zurzeit %d$ drin.",bInfo[b][Konto]);
- SendClientMessage(playerid,BLUE,string);
- return 1;
- }
- else return SendClientMessage(playerid,ROT,"Das ist nicht dein Biz!");
- }
- else return SendClientMessage(playerid,ROT,"Du bist nicht IN deinen Biz!");
- }
- return 1;
- }
- ocmd:buyfirma(playerid,params[])
- {
- for(new b = 1; b <MAX_BIZZ; b++)
- {
- if(IsPlayerInRangeOfPoint(playerid,5,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]))
- {
- if(bInfo[b][Besetzt] == 0)
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof name);
- if(strcmp(bInfo[b][Besitzer],name,false) == 0)return SendClientMessage(playerid,ROT,"Dieses Bizz gehört dir bereits!");
- if(GetPlayerMoney(playerid) >= bInfo[b][Preis])
- {
- if(GetPlayerScore(playerid) >= bInfo[b][Level])
- {
- GivePlayerMoney(playerid,-bInfo[b][Preis]);
- new BizzDatei[64];
- format(BizzDatei,64,"/Bizz/%d.txt",b);
- dini_IntSet(BizzDatei,"Besetzt",1);
- dini_Set(BizzDatei,"Besitzer",name);
- SendClientMessage(playerid,BLUE,"Du hast erfolgreich das Bizz gekauft!");
- KillBizz(b);
- LoadBizz(b);
- }
- else SendClientMessage(playerid,ROT,"Dein Level ist zu niedrig!");
- }
- else SendClientMessage(playerid,ROT,"Du hast nicht genug Geld dabei!");
- }
- else SendClientMessage(playerid,ROT,"Das BIZZ gehört schon jemandem!");
- }
- }
- return 1;
- }
- ocmd:beinzahlen(playerid,params[])
- {
- for(new b = 1; b <MAX_BIZZ; b++)
- {
- new Innenraum = bInfo[b][Interior];
- if(IsPlayerInRangeOfPoint(playerid,20,bInt[Innenraum][SpawnX],bInt[Innenraum][SpawnY],bInt[Innenraum][SpawnZ]))
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof name);
- if(strcmp(bInfo[b][Besitzer],name,false) == 1)
- {
- new egeld, string[128];
- if(sscanf(params,"d",egeld))return SendClientMessage(playerid,BLUE,"Benutze: /beinzahlen [Einzahl-Menge]");
- if(GetPlayerMoney(playerid) >= egeld)
- {
- new BizzDatei[50];
- format(BizzDatei,50,"/Bizz/%d.txt",b);
- bInfo[b][Konto] += egeld;
- dini_IntSet(BizzDatei,"Konto",bInfo[b][Konto]);
- GivePlayerMoney(playerid,-egeld);
- format(string,sizeof(string),"Du hast %d$ in die Bizz Kasse eingezahlt! Neuer Stand: %d",egeld,bInfo[b][Konto]);
- SendClientMessage(playerid,BLUE,string);
- KillBizz(b);
- LoadBizz(b);
- return 1;
- }
- else return SendClientMessage(playerid,ROT,"Du hast nicht genug Geld dabei!");
- }
- else return SendClientMessage(playerid,ROT,"Das ist nicht dein Biz!");
- }
- else return SendClientMessage(playerid,ROT,"Du bist nicht IN deinen Biz!");
- }
- return 1;
- }
- ocmd:bauszahlen(playerid,params[])
- {
- for(new b = 1; b <MAX_BIZZ; b++)
- {
- new Innenraum = bInfo[b][Interior];
- if(IsPlayerInRangeOfPoint(playerid,20,bInt[Innenraum][SpawnX],bInt[Innenraum][SpawnY],bInt[Innenraum][SpawnZ]))
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof name);
- if(strcmp(bInfo[b][Besitzer],name,false) == 1)
- {
- new ageld, string[128];
- if(sscanf(params,"d",ageld))return SendClientMessage(playerid,BLUE,"Benutze: /bauszahlen [Auszahl-Menge]");
- if(bInfo[b][Konto] >= ageld)
- {
- new BizzDatei[50];
- format(BizzDatei,50,"/Bizz/%d.txt",b);
- bInfo[b][Konto] -= ageld;
- dini_IntSet(BizzDatei,"Konto",bInfo[b][Konto]);
- GivePlayerMoney(playerid,ageld);
- format(string,sizeof(string),"Du hast %d$ aus der Bizz Kasse ausgezahlt! Neuer Stand: %d",ageld, bInfo[b][Konto]);
- SendClientMessage(playerid,BLUE,string);
- KillBizz(b);
- LoadBizz(b);
- return 1;
- }
- else return SendClientMessage(playerid,ROT,"In der Bizz Kasse ist nicht soviel Geld!");
- }
- else return SendClientMessage(playerid,ROT,"Das ist nicht dein Biz!");
- }
- else return SendClientMessage(playerid,ROT,"Du bist nicht IN deinen Biz!");
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(newkeys == KEY_YES)
- {
- for(new b = 1; b <MAX_BIZZ; b++)
- {
- if(IsPlayerInRangeOfPoint(playerid,5,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]))
- {
- new innenraum = bInfo[b][Interior];
- SetPlayerPos(playerid,bInt[innenraum][SpawnX],bInt[innenraum][SpawnY],bInt[innenraum][SpawnZ]);
- SetPlayerInterior(playerid,bInt[innenraum][Int]);
- SetPlayerVirtualWorld(playerid,bInfo[b][World]);
- inBizz[playerid] = b;
- return 1;
- }
- }
- }
- if(newkeys == KEY_NO)
- {
- if(inBizz[playerid] != -1)
- {
- new b = inBizz[playerid];
- new Innenraum = bInfo[b][Interior];
- if(IsPlayerInRangeOfPoint(playerid,10,bInt[Innenraum][SpawnX],bInt[Innenraum][SpawnY],bInt[Innenraum][SpawnZ]))
- {
- SetPlayerPos(playerid,bInfo[b][PosX],bInfo[b][PosY],bInfo[b][PosZ]);
- SetPlayerInterior(playerid,0);
- SetPlayerVirtualWorld(playerid,0);
- return 1;
- }
- }
- }
- return 1;
- }
- stock CreateBizz(Float:x,Float:y,Float:z,besitzer[64],preis,level,int,world)
- {
- new BizzDatei[50];
- for(new b = 1; b <MAX_BIZZ; b++)
- {
- format(BizzDatei,50,"/Bizz/%d.txt",b);
- if(!fexist(BizzDatei))
- {
- dini_Create(BizzDatei);
- dini_FloatSet(BizzDatei,"PosX",x);
- dini_FloatSet(BizzDatei,"PosY",y);
- dini_FloatSet(BizzDatei,"PosZ",z);
- dini_IntSet(BizzDatei,"Preis",preis);
- dini_IntSet(BizzDatei,"Level",level);
- dini_IntSet(BizzDatei,"Konto",0);
- dini_IntSet(BizzDatei,"Besetzt",0);
- dini_Set(BizzDatei,"Besitzer",besitzer);
- dini_IntSet(BizzDatei,"Interior",int);
- dini_IntSet(BizzDatei,"World",world);
- return LoadBizz(b);
- }
- }
- return 1;
- }
- stock KillBizz(bizid)
- {
- Delete3DTextLabel(bInfo[bizid][Label]);
- return DestroyPickup(bInfo[bizid][Pickup]);
- }
- stock LoadBizz(bizid)
- {
- new BizzDatei[64];
- format(BizzDatei,64,"/Bizz/%d.txt",bizid);
- if(!fexist(BizzDatei))return 0;
- bInfo[bizid][PosX] = dini_Float(BizzDatei,"PosX");
- bInfo[bizid][PosY] = dini_Float(BizzDatei,"PosY");
- bInfo[bizid][PosZ] = dini_Float(BizzDatei,"PosZ");
- bInfo[bizid][Level] = dini_Int(BizzDatei,"Level");
- bInfo[bizid][Konto] = dini_Int(BizzDatei,"Konto");
- bInfo[bizid][Preis] = dini_Int(BizzDatei,"Preis");
- bInfo[bizid][Interior] = dini_Int(BizzDatei,"Interior");
- bInfo[bizid][Besetzt] = dini_Int(BizzDatei,"Besetzt");
- format(bInfo[bizid][Besitzer],64,"%s",dini_Get(BizzDatei,"Besitzer"));
- if(bInfo[bizid][Besetzt] == 0)
- {
- bInfo[bizid][Pickup] = CreatePickup(1272 ,23,bInfo[bizid][PosX],bInfo[bizid][PosY],bInfo[bizid][PosZ],0);
- new string[196];
- format(string,196,""BLAU"Besitzer: "WEISS"Keiner\n"BLAU"Preis: "WEISS"%d$\n"BLAU"Level: "WEISS"%d\nZum Kaufen "WEISS"/buyfirma",bInfo[bizid][Preis],bInfo[bizid][Level]);
- bInfo[bizid][Label] = Create3DTextLabel(string,BLUE,bInfo[bizid][PosX],bInfo[bizid][PosY],bInfo[bizid][PosZ],20,0,0);
- return print("Das Biz wurde erfolgreich geladen");
- }
- if(bInfo[bizid][Besetzt] == 1)
- {
- bInfo[bizid][Pickup] = CreatePickup(1239 ,23,bInfo[bizid][PosX],bInfo[bizid][PosY],bInfo[bizid][PosZ],0);
- new string[196];
- format(string,196,""BLAU"Besitzer: "WEISS"%s\nZum Betreten: "BLAU"Z",bInfo[bizid][Besitzer]);
- bInfo[bizid][Label] = Create3DTextLabel(string,BLUE,bInfo[bizid][PosX],bInfo[bizid][PosY],bInfo[bizid][PosZ],20,0,0);
- return print("Das Biz wurde erfolgreich geladen");
- }
- return 1;
- }
- 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