Advertisement
Guest User

CarSpawner (von Vincent Petritz)

a guest
Mar 1st, 2012
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. #include <a_samp>
  2. #include <ocmd>
  3. #include <sscanf2>
  4.  
  5. #define VEHICLES_PER_PLAYER 4
  6. // Dialoge
  7. #define VEHICLE_LIST_DIALOG 1231
  8.  
  9. public OnFilterScriptInit()
  10. {
  11. print("Vehiclespawner by Vincent Petritz");
  12. return 1;
  13. }
  14.  
  15. stock GetPlayerNameEx(playerid)
  16. {
  17. new name[MAX_PLAYER_NAME];
  18. GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  19. return name;
  20. }
  21.  
  22. main()
  23. {
  24. print("Vehiclespawner by Vincent Petritz");
  25. }
  26.  
  27. ocmd:carlist(playerid, params[])
  28. {
  29. #pragma unused params
  30. new str1[100],
  31. str2[70],
  32. str3[500];
  33. format(str1, sizeof(str1), "[%d/%d] Vehicles von dir, %s.", GetPVarInt(playerid, "VehiclesOwned"), VEHICLES_PER_PLAYER, GetPlayerNameEx(playerid));
  34. if(GetPVarInt(playerid, "VehiclesOwned") == 0)
  35. {
  36. format(str2, sizeof(str2), "Fahrzeug mit /createcar hinzufΓΌgen");
  37. ShowPlayerDialog(playerid, VEHICLE_LIST_DIALOG, DIALOG_STYLE_LIST, str1, str2, "Ok", "");
  38. }
  39. else if(GetPVarInt(playerid, "VehiclesOwned") >= 1) {
  40. format(str3, sizeof(str3), "CarID Farben\n%d %d & %d\n%d %d & %d\n%d %d & %d\n%d %d & %d\n%d %d & %d",
  41. GetPVarInt(playerid, "VehicleID1"),
  42. GetPVarInt(playerid, "VehicleCOL11"),
  43. GetPVarInt(playerid, "VehicleCOL21"),
  44. GetPVarInt(playerid, "VehicleID2"),
  45. GetPVarInt(playerid, "VehicleCOL12"),
  46. GetPVarInt(playerid, "VehicleCOL22"),
  47. GetPVarInt(playerid, "VehicleID3"),
  48. GetPVarInt(playerid, "VehicleCOL13"),
  49. GetPVarInt(playerid, "VehicleCOL23"),
  50. GetPVarInt(playerid, "VehicleID4"),
  51. GetPVarInt(playerid, "VehicleCOL14"),
  52. GetPVarInt(playerid, "VehicleCOL24"));
  53. ShowPlayerDialog(playerid, VEHICLE_LIST_DIALOG, DIALOG_STYLE_LIST, str1, str3, "Ok", "");
  54. }
  55. return 1;
  56. }
  57.  
  58. ocmd:createcar(playerid, params[])
  59. {
  60. new carID, colID1, colID2, slot;
  61. if(sscanf(params, "dddd", carID, colID1, colID2, slot))
  62. return SendClientMessage(playerid, 0xFF0023FF, "Falsche Eingabe: /createcar [carID] [colID] [colID] [slotID]");
  63. if(GetPVarInt(playerid, "VehiclesOwned") <= 4)
  64. {
  65. new str[100];
  66. format(str, sizeof(str), "VehicleID%d", slot);
  67. if(GetPVarInt(playerid, str) == 0 && slot < 5)
  68. {
  69. new str1[128],
  70. Float:x,
  71. Float:y,
  72. Float:z,
  73. vehicleForPlayer,
  74. str5[128],
  75. str2[50],
  76. str3[50],
  77. str4[50];
  78. GetPlayerPos(playerid, x, y, z);
  79. format(str1, sizeof(str1), "[VehicleSpawner] Vehicle auf Slot %d gespawned.", slot);
  80. format(str5, sizeof(str5), "[VehicleSpawner] Slot: %d; CarID: %d; Col1: %d; Col2: %d", slot, carID, colID1, colID2);
  81. vehicleForPlayer = CreateVehicle(carID, x, y, z, 0, colID1, colID2, 60);
  82. PutPlayerInVehicle(playerid, vehicleForPlayer, 0);
  83. format(str2, sizeof(str2), "VehicleCOL1%d", slot);
  84. format(str3, sizeof(str3), "VehicleCOL2%d", slot);
  85. format(str4, sizeof(str4), "VehicleIDx%d", slot);
  86. SetPVarInt(playerid, str4, GetPlayerVehicleID(playerid));
  87. SetPVarInt(playerid, str2, colID1);
  88. SetPVarInt(playerid, str3, colID2);
  89. SetPVarInt(playerid, str, carID);
  90. SetPVarInt(playerid, "VehiclesOwned", GetPVarInt(playerid, "VehiclesOwned") +1);
  91. SendClientMessage(playerid, 0xFF8C00FF, str1);
  92. SendClientMessage(playerid, 0xFF8C00FF, str5);
  93. }
  94. else
  95. return SendClientMessage(playerid, 0xFF0023FF, "Fahrzeug auf Slot vorhanden!");
  96. }
  97. else
  98. return SendClientMessage(playerid, 0xFF0023FF, "Maximale Slotanzahl verbraucht!");
  99. return 1;
  100. }
  101.  
  102. ocmd:destroycar(playerid, params[])
  103. {
  104. new slot;
  105. if(sscanf(params, "d", slot))
  106. return SendClientMessage(playerid, 0xFF0023FF, "Falsche Eingabe: /destroycar [Slot]");
  107. if(slot > 0 && slot < 5)
  108. {
  109. new str1[100],
  110. str2[50],
  111. str3[50],
  112. str4[50],
  113. str5[50];
  114. format(str1, sizeof(str1), "[VehicleSpawner] Carslot %d ist nun wieder frei!", slot);
  115. SendClientMessage(playerid, 0xFF8C00FF, str1);
  116. format(str2, sizeof(str2), "VehicleCOL1%d", slot);
  117. format(str3, sizeof(str3), "VehicleCOL2%d", slot);
  118. format(str4, sizeof(str4), "VehicleIDx%d", slot);
  119. format(str5, sizeof(str5), "VehicleID%d", slot);
  120. DestroyVehicle(GetPVarInt(playerid, str4));
  121. SetPVarInt(playerid, str2, 0);
  122. SetPVarInt(playerid, str3, 0);
  123. SetPVarInt(playerid, str4, 0);
  124. SetPVarInt(playerid, str5, 0);
  125. }
  126. else
  127. return SendClientMessage(playerid,0xFF0023FF, "Falsche Slotangabe!");
  128. return 1;
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement