Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <dini>
- #include <ocmd>
- #define MAX_HAUS 15
- enum haus_info
- {
- Float:haus_x,
- Float:haus_y,
- Float:haus_z,
- haus_besitzer[32],
- haus_preis,
- haus_pickup
- }
- new HausInfo[MAX_HAUS][haus_info];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print("Haussystem Tutorial by Haxler :D");
- print("--------------------------------------\n");
- CreatePickup(1273,23,0,0,1000,99);
- for(new haus=1;haus<MAX_HAUS;haus++)
- {
- LoadHaus(haus);
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- for(new haus=1;haus<MAX_HAUS;haus++)
- {
- KillHaus(haus);
- }
- return 1;
- }
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- ocmd:ersetllen(playerid,params[])
- {
- new Float:x,Float:y,Float:z;
- GetPlayerPos(playerid,x,y,z);
- CreateHaus(x,y,z,100,"Keiner");
- return 1;
- }
- ocmd:kaufen(playerid,params[])
- {
- for(new haus=1;haus<MAX_HAUS;haus++)
- {
- if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[haus][haus_x],HausInfo[haus][haus_y],HausInfo[haus][haus_z]))
- {
- new name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,sizeof name);
- if(strcmp(HausInfo[haus][haus_besitzer],name,false) == 0)return SendClientMessage(playerid,0x00FF00,"Dieses Haus gehört dir bereits!");
- if(strcmp(HausInfo[haus][haus_besitzer],"Keiner",false))return SendClientMessage(playerid,0x00FF00,"Dieses Haus steht nicht zum Verkauf!");
- // wenn das Haus frei ist dann kaufen:
- if(GetPlayerMoney(playerid) < HausInfo[haus][haus_preis])return SendClientMessage(playerid,0x00FF00,"Du hast nicht genug Geld!");
- GivePlayerMoney(playerid,-HausInfo[haus][haus_preis]); // Geld abziehen
- new pfad[50];
- format(pfad,50,"/haus/%d.txt",haus); // Pfad formatieren
- dini_Set(pfad,"besitzer",name); // Besitzer überschreiben
- KillHaus(haus); // Hauspickup löschen
- LoadHaus(haus); // Haus laden
- }
- }
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid) // Wenn der Spieler ein Pickup betritt
- {
- for(new i=1;i<MAX_HAUS;i++) // schleife für alle Häuser
- {
- if(HausInfo[i][haus_pickup] == pickupid) // wenn das pickup unser Hauspickup ist
- {
- new s[100];
- format(s,100,"Besitzer: %s, Preis: %d$",HausInfo[i][haus_besitzer],HausInfo[i][haus_preis]); // Nachricht formatieren
- SendClientMessage(playerid,0x00FF00,s);
- }
- }
- return 1;
- }
- stock LoadHaus(hausid)
- {
- new pfad[50];
- format(pfad,50,"/haus/%d.txt",hausid);
- if(!fexist(pfad))return 0; //überprüft ob die Datei existiert, wenn nicht wird 0 zurückgegeben
- HausInfo[hausid][haus_x] = dini_Float(pfad,"x"); // hier laden wir die Werte
- HausInfo[hausid][haus_y] = dini_Float(pfad,"y");
- HausInfo[hausid][haus_z] = dini_Float(pfad,"z");
- HausInfo[hausid][haus_preis] = dini_Int(pfad,"preis");
- format(HausInfo[hausid][haus_besitzer],32,"%s",dini_Get(pfad,"besitzer"));
- HausInfo[hausid][haus_pickup] = CreatePickup(1273 ,23,HausInfo[hausid][haus_x],HausInfo[hausid][haus_y],HausInfo[hausid][haus_z],0); //erstellt ein Pickup an den Hauskoordinaten
- return print("Das Haus wurde erfolgreich geladen");
- }
- stock KillHaus(hausid)
- {
- return DestroyPickup(HausInfo[hausid][haus_pickup]);
- }
- stock CreateHaus(Float:x,Float:y,Float:z,preis,besitzer[32]) // die ersten 3 Werte sind die Koordinaten, der 4. der Preis und der 5. der Besitzer
- {
- new pfad[50];
- for(new haus=1;haus<MAX_HAUS;haus++)
- {
- format(pfad,50,"/haus/%d.txt",haus); //nun ist der Pfad der Datei im String "pfad".
- if(!fexist(pfad)) // wenn diese Datei noch nicht existiert
- {
- dini_Create(pfad); // dann erstellen wir sie
- dini_FloatSet(pfad,"x",x); // und füllen sie mit unseren Werten.
- dini_FloatSet(pfad,"y",y);
- dini_FloatSet(pfad,"z",z);
- dini_IntSet(pfad,"preis",preis);
- dini_Set(pfad,"besitzer",besitzer);
- dini_IntSet(pfad,"preis",preis);
- dini_Set(pfad,"besitzer",besitzer);
- return LoadHaus(haus);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement