AdnanD

poscmd.inc

Jul 14th, 2015
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.68 KB | None | 0 0
  1. #include <a_samp>
  2. #include <streamer>
  3. #include <YSI\y_iterate>
  4. #include <YSI\y_timers>
  5.  
  6. #define MAX_POS_COMMANS                                                         2048
  7.  
  8. #define BOJA_POS_CMD                                                            "{00FF00}"
  9.  
  10. #define PRESSED(%0) \
  11.     (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
  12.  
  13. new Iterator:PosComand<MAX_POS_COMMANS>;
  14.  
  15. enum pcI {
  16.     Text3D:_label,
  17.     _pickup,
  18.     _id,
  19.     bool:_mozeizvozila,
  20.     bool:_postavljena,
  21.     Float:_XX,
  22.     Float:_YY,
  23.     Float:_ZZ
  24. };
  25. new PC[MAX_POS_COMMANS][pcI];
  26.  
  27.  
  28. #if defined FILTERSCRIPT
  29. hook OnFilterScriptExit()
  30. #else
  31. hook OnGameModeExit()
  32. #endif
  33. {
  34.  
  35.     foreach(new i: PosComand) {
  36.         DestroyPosCommand(i);
  37.     }
  38.     return 1;
  39. }
  40.  
  41. hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  42. {
  43.     if(PRESSED(KEY_YES) && !GetPVarInt(playerid, "PCmdOdario")) {
  44.         foreach(new i: PosComand) {
  45.             if(IsPlayerInRangeOfPoint(playerid, 3.0, PC[i][_XX], PC[i][_YY], PC[i][_ZZ])) {
  46.                 if(IsPlayerInAnyVehicle(playerid) && PC[i][_mozeizvozila] == false) return 1;
  47.                 else {
  48.                     OnPosCommandPreesed(playerid, PC[i][_id]);
  49.                     SetPVarInt(playerid, "PCmdOdario", 1);
  50.                     defer SkiniPCmdOdradio(playerid);
  51.                     return 1;
  52.                 }
  53.             }
  54.         }
  55.  
  56.     }
  57.     return 1;
  58.  
  59. }
  60.  
  61. timer SkiniPCmdOdradio[2000](playerid) return DeletePVar(playerid, "PCmdOdario");
  62.  
  63. stock CreatePosCommand(poscmdID, const PCText[], Float:pcX, Float:pcY, Float:pcZ, bool:MozeIzVozila = true, pickupTip = 1239) {
  64.  
  65.     if(poscmdID >= MAX_POS_COMMANS-1) {
  66.         if(poscmdID == MAX_POS_COMMANS-1)  print("ERROR: Dostigli ste maximalan broj PosComand. Povecajte 'MAX_POS_COMMANS'.");
  67.         return 1;
  68.     }
  69.  
  70.     if(PC[poscmdID][_postavljena] == true) {
  71.         printf("ERROR: Pokusali ste kreirati PocComand ID: %d, ona vec postoji.", poscmdID);
  72.         return 1;
  73.     }
  74.  
  75.     new pcString[256];
  76.  
  77.     strcat(pcString, PCText, sizeof(pcString));
  78.     strcat(pcString, "\n"BOJA_POS_CMD"Pritisnite tipku 'Y'", sizeof(pcString));
  79.  
  80.     PC[poscmdID][_label] = CreateDynamic3DTextLabel(pcString, 0xFFFFFFCC, pcX, pcY, pcZ, 20.0);
  81.  
  82.     PC[poscmdID][_pickup] = CreateDynamicPickup(pickupTip, 1, pcX, pcY, pcZ);
  83.  
  84.     PC[poscmdID][_id] = poscmdID;
  85.     PC[poscmdID][_mozeizvozila] = MozeIzVozila;
  86.     PC[poscmdID][_postavljena] = true;
  87.  
  88.     PC[poscmdID][_XX] = pcX;
  89.     PC[poscmdID][_YY] = pcY;
  90.     PC[poscmdID][_ZZ] = pcZ;
  91.  
  92.     Iter_Add(PosComand, poscmdID);
  93.  
  94.     return 1;
  95. }
  96.  
  97. stock DestroyPosCommand(poscmdID) {
  98.  
  99.     if(PC[poscmdID][_postavljena] == false) return 1;
  100.  
  101.     DestroyDynamic3DTextLabel(PC[poscmdID][_label]);
  102.  
  103.     DestroyDynamicPickup(PC[poscmdID][_pickup]);
  104.  
  105.     PC[poscmdID][_postavljena] = false;
  106.  
  107.     Iter_Remove(PosComand, poscmdID);
  108.  
  109.     return 1;
  110. }
  111.  
  112. forward OnPosCommandPreesed(playerid, pcid);
Advertisement
Add Comment
Please, Sign In to add comment