Advertisement
Guest User

Haussystem

a guest
Feb 7th, 2011
2,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.95 KB | None | 0 0
  1. #include <a_samp>
  2. #include <dini>
  3. #include <ocmd>
  4.  
  5. #define MAX_HAUS 15
  6. enum haus_info
  7. {
  8. Float:haus_x,
  9. Float:haus_y,
  10. Float:haus_z,
  11. haus_besitzer[32],
  12. haus_preis,
  13. haus_pickup
  14. }
  15. new HausInfo[MAX_HAUS][haus_info];
  16.  
  17. public OnFilterScriptInit()
  18. {
  19.     print("\n--------------------------------------");
  20.     print("Haussystem Tutorial by Haxler :D");
  21.     print("--------------------------------------\n");
  22.     CreatePickup(1273,23,0,0,1000,99);
  23.     for(new haus=1;haus<MAX_HAUS;haus++)
  24.     {
  25.         LoadHaus(haus);
  26.     }
  27.     return 1;
  28. }
  29.  
  30. public OnFilterScriptExit()
  31. {
  32.     for(new haus=1;haus<MAX_HAUS;haus++)
  33.     {
  34.         KillHaus(haus);
  35.     }
  36.     return 1;
  37. }
  38.  
  39.  
  40. main()
  41. {
  42.     print("\n----------------------------------");
  43.     print(" Blank Gamemode by your name here");
  44.     print("----------------------------------\n");
  45. }
  46.  
  47.  
  48.  
  49. ocmd:ersetllen(playerid,params[])
  50. {
  51.     new Float:x,Float:y,Float:z;
  52.     GetPlayerPos(playerid,x,y,z);
  53.     CreateHaus(x,y,z,100,"Keiner");
  54.     return 1;
  55. }
  56.  
  57. ocmd:kaufen(playerid,params[])
  58. {
  59.     for(new haus=1;haus<MAX_HAUS;haus++)
  60.     {
  61.         if(IsPlayerInRangeOfPoint(playerid,5,HausInfo[haus][haus_x],HausInfo[haus][haus_y],HausInfo[haus][haus_z]))
  62.         {
  63.             new name[MAX_PLAYER_NAME];
  64.             GetPlayerName(playerid,name,sizeof name);
  65.             if(strcmp(HausInfo[haus][haus_besitzer],name,false) == 0)return SendClientMessage(playerid,0x00FF00,"Dieses Haus gehört dir bereits!");
  66.             if(strcmp(HausInfo[haus][haus_besitzer],"Keiner",false))return SendClientMessage(playerid,0x00FF00,"Dieses Haus steht nicht zum Verkauf!");
  67.             // wenn das Haus frei ist dann kaufen:
  68.             if(GetPlayerMoney(playerid) < HausInfo[haus][haus_preis])return SendClientMessage(playerid,0x00FF00,"Du hast nicht genug Geld!");
  69.             GivePlayerMoney(playerid,-HausInfo[haus][haus_preis]); // Geld abziehen
  70.             new pfad[50];
  71.             format(pfad,50,"/haus/%d.txt",haus); // Pfad formatieren
  72.             dini_Set(pfad,"besitzer",name); // Besitzer überschreiben
  73.             KillHaus(haus); // Hauspickup löschen
  74.             LoadHaus(haus); // Haus laden
  75.         }
  76.     }
  77.     return 1;
  78. }
  79.  
  80.  
  81. public OnPlayerPickUpPickup(playerid, pickupid) // Wenn der Spieler ein Pickup betritt
  82. {
  83.     for(new i=1;i<MAX_HAUS;i++) // schleife für alle Häuser
  84.     {
  85.         if(HausInfo[i][haus_pickup] == pickupid)  // wenn das pickup unser Hauspickup ist
  86.         {
  87.             new s[100];
  88.             format(s,100,"Besitzer: %s, Preis: %d$",HausInfo[i][haus_besitzer],HausInfo[i][haus_preis]); // Nachricht formatieren
  89.             SendClientMessage(playerid,0x00FF00,s);
  90.         }
  91.     }
  92.     return 1;
  93. }
  94.  
  95. stock LoadHaus(hausid)
  96. {
  97.     new pfad[50];
  98.     format(pfad,50,"/haus/%d.txt",hausid);
  99.     if(!fexist(pfad))return 0; //überprüft ob die Datei existiert, wenn nicht wird 0 zurückgegeben
  100.     HausInfo[hausid][haus_x] = dini_Float(pfad,"x"); // hier laden wir die Werte
  101.     HausInfo[hausid][haus_y] = dini_Float(pfad,"y");
  102.     HausInfo[hausid][haus_z] = dini_Float(pfad,"z");
  103.     HausInfo[hausid][haus_preis] = dini_Int(pfad,"preis");
  104.     format(HausInfo[hausid][haus_besitzer],32,"%s",dini_Get(pfad,"besitzer"));
  105.     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
  106.     return print("Das Haus wurde erfolgreich geladen");
  107. }
  108.  
  109. stock KillHaus(hausid)
  110. {
  111.     return DestroyPickup(HausInfo[hausid][haus_pickup]);
  112. }
  113.  
  114. 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
  115. {
  116.     new pfad[50];
  117.     for(new haus=1;haus<MAX_HAUS;haus++)
  118.     {
  119.         format(pfad,50,"/haus/%d.txt",haus); //nun ist der Pfad der Datei im String "pfad".
  120.         if(!fexist(pfad)) // wenn diese Datei noch nicht existiert
  121.         {
  122.             dini_Create(pfad); // dann erstellen wir sie
  123.             dini_FloatSet(pfad,"x",x); // und füllen sie mit unseren Werten.
  124.             dini_FloatSet(pfad,"y",y);
  125.             dini_FloatSet(pfad,"z",z);
  126.             dini_IntSet(pfad,"preis",preis);
  127.             dini_Set(pfad,"besitzer",besitzer);
  128.             dini_IntSet(pfad,"preis",preis);
  129.             dini_Set(pfad,"besitzer",besitzer);
  130.             return LoadHaus(haus);
  131.         }
  132.     }
  133.     return 1;
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement