Advertisement
Guest User

prepreka

a guest
Sep 21st, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. #define BR_PREPREKE 11
  2.  
  3. enum preprekaInfo
  4. {
  5. Float:PreprekaX[BR_PREPREKE],
  6. Float:PreprekaY[BR_PREPREKE],
  7. Float:PreprekaZ[BR_PREPREKE],
  8. PreprekaId[BR_PREPREKE],
  9. };
  10. new PreprekaInfo[MAX_PLAYERS][preprekaInfo];
  11.  
  12.  
  13. public OnPlayerConnect(playerid)
  14. {
  15. for(new i = 0; i < BR_PREPREKE; i++)
  16. {
  17. PreprekaInfo[playerid][PreprekaX][i] = 0.0;
  18. PreprekaInfo[playerid][PreprekaY][i] = 0.0;
  19. PreprekaInfo[playerid][PreprekaZ][i] = 0.0;
  20. PreprekaInfo[playerid][PreprekaId][i] = -1;
  21. }
  22. return 1;
  23. }
  24.  
  25. public OnPlayerDisconnect(playerid, reason)
  26. {
  27. for(new i = 0; i < BR_PREPREKE; i++)
  28. {
  29. if(PreprekaInfo[playerid][PreprekaId][i]!=-1)
  30. {
  31. DestroyDynamicObject(PreprekaInfo[playerid][PreprekaId][i]); // unistava prepreku ako igrac napusti server
  32. }
  33. }
  34. return 1;
  35. }
  36.  
  37. COMMAND:makniprepreku(playerid, params[])
  38. {
  39. if(IsACop(playerid))
  40. {
  41. new p;
  42. if(sscanf(params,"i", p)) SendClientMessage(playerid,-1,"/makniprepreku [Broj prepreke]");
  43. else if(p < 1 || p > 10) SendClientMessage(playerid, -1,"Pogresan odabir");
  44. else if(PreprekaInfo[playerid][PreprekaId][p] == -1) SendClientMessage(playerid, -1,"Nemas napravljenu prepreku!");
  45. else if(!IsPlayerInRangeOfPoint(playerid, 7.0, PreprekaInfo[playerid][PreprekaX][p], PreprekaInfo[playerid][PreprekaY][p], PreprekaInfo[playerid][PreprekaZ][p])) SendClientMessage(playerid, -1, "Predaleko si od prepreke!");
  46. else
  47. {
  48. PreprekaInfo[playerid][PreprekaX][p]=0.0;
  49. PreprekaInfo[playerid][PreprekaY][p]=0.0;
  50. PreprekaInfo[playerid][PreprekaZ][p]=0.0;
  51. DestroyDynamicObject(PreprekaInfo[playerid][PreprekaId][p]);
  52. PreprekaInfo[playerid][PreprekaId][p]=-1;
  53. SendClientMessage(playerid, -1,"Maknuli ste prepreku.");
  54. }
  55. }
  56. else return SendClientMessage(playerid,-1,"Niste clan Policije");
  57. return 1;
  58. }
  59.  
  60. COMMAND:prepreka(playerid, params[])
  61. {
  62. if(IsACop(playerid))
  63. {
  64. new vrsta, p;
  65. if (sscanf(params, "dd", vrsta,p)) SendClientMessage(playerid, -1,"/prepreka [1-Mala, 2-Srednja, 3-Velika, 4-Cunj] [Broj prepreke]");
  66. else if(vrsta < 1 || vrsta > 4) SendClientMessage(playerid, -1, "Pogresan odabir(1-4).");
  67. else if(p < 1 || p > 10) SendClientMessage(playerid, -1,"Pogresan odabir");
  68. else
  69. {
  70. if(PreprekaInfo[playerid][PreprekaId][p] != -1)
  71. {
  72. SendClientMessage(playerid,-1,"Vec imas postavljenu prepreku!");
  73. return 1;
  74. }
  75. if(IsPlayerInAnyVehicle(playerid))
  76. {
  77. SendClientMessage(playerid,-1,"Ne smijes biti u vozilu!");
  78. return 1;
  79. }
  80.  
  81. new Float:pozx,Float:pozy,Float:pozz,Float:poza;
  82. GetPlayerPos(playerid, pozx, pozy, pozz); GetPlayerFacingAngle(playerid,poza);
  83. PreprekaInfo[playerid][PreprekaX][p]=pozx; PreprekaInfo[playerid][PreprekaY][p]=pozy; PreprekaInfo[playerid][PreprekaZ][p]=pozz;
  84. if(vrsta==1)
  85. {
  86. PreprekaInfo[playerid][PreprekaId][p] = CreateDynamicObject(1459, pozx,pozy,pozz-0.7, 0, 0, poza);
  87. GameTextForPlayer( playerid,"~w~Mala prepreka ~b~postavljena!",1500,1);
  88. }
  89. else if(vrsta==2)
  90. {
  91. PreprekaInfo[playerid][PreprekaId][p] = CreateDynamicObject(978, pozx,pozy,pozz-0.7, 0, 0, poza);
  92. GameTextForPlayer( playerid,"~w~Srednja prepreka ~b~postavljena!",1500,1);
  93. }
  94. else if(vrsta==3)
  95. {
  96. PreprekaInfo[playerid][PreprekaId][p] = CreateDynamicObject(981, pozx,pozy,pozz-0.7, 0, 0, poza);
  97. GameTextForPlayer( playerid,"~w~Velika prepreka ~b~postavljena!",1500,1);
  98. }
  99. else if(vrsta==4)
  100. {
  101. PreprekaInfo[playerid][PreprekaId][p] = CreateDynamicObject(1238, pozx,pozy,pozz-0.7, 0, 0, poza);
  102. GameTextForPlayer( playerid,"~w~Cunj ~b~postavljen!",1500,1);
  103. }
  104. }
  105. }
  106. else return SendClientMessage(playerid,-1,"Niste clan Policije");
  107. return 1;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement