Advertisement
Guest User

CreateChangeVeh v0.3

a guest
Dec 24th, 2011
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. /* By irinel1996.
  2. GetVehicleColor by RyDeR`
  3. Keep the credits please.
  4. (c) 2011-2012
  5. */
  6. #include <a_samp>
  7. #include <GetVehicleColor>
  8. //----------------------------------[MACROS]-----------------------------------//
  9. #define MAX_PCambio MAX_PLAYERS*3
  10. #define INVALID_CPID -1
  11. #define LABEL_COLOR 0xFF00EBFF
  12. #define CALLBACK:%0(%1) forward%0(%1); public%0(%1)
  13. //-----------------------------------[NEWS]------------------------------------//
  14. enum PicksCmb
  15. {
  16. IDPC,
  17. Type,
  18. Float:PX,
  19. Float:PY,
  20. Float:PZ,
  21. IDNewCar
  22. };
  23. new PickCam[MAX_PCambio][PicksCmb], PickupC, JustUsed[MAX_PLAYERS];
  24.  
  25. //-------------------------------[FUNCTIONS]-----------------------------------//
  26. start_sveh()
  27. {
  28. SetTimer("UpdatePos",30,true);
  29. return 1;
  30. }
  31.  
  32. stock CreateNitroPickup(Float:X, Float:Y, Float:Z, Texto[])
  33. {
  34. new IDPCmb = PickupC;
  35. if(PickupC > MAX_PCambio-1)
  36. {
  37. print(">> ERROR: Pickups limit reached!");
  38. IDPCmb = INVALID_CPID;
  39. return IDPCmb;
  40. }
  41. PickupC++;
  42. PickCam[IDPCmb][IDPC] = IDPCmb, PickCam[IDPCmb][Type] = 1;
  43. PickCam[IDPCmb][PX] = X, PickCam[IDPCmb][PY] = Y, PickCam[IDPCmb][PZ] = Z;
  44. AddStaticPickup(1010,23,X,Y,Z,-1);
  45. if(strlen(Texto)) { Create3DTextLabel(Texto,LABEL_COLOR,X,Y,Z,30,0); }
  46. return 0;
  47. }
  48.  
  49. stock CreateRepairPickup(Model, Float:X, Float:Y, Float:Z, Texto[]) //Model, recommended = 1248.
  50. {
  51. new IDPCmb = PickupC;
  52. if(PickupC > MAX_PCambio-1)
  53. {
  54. print(">> ERROR: Pickups limit reached!");
  55. IDPCmb = INVALID_CPID;
  56. return IDPCmb;
  57. }
  58. PickupC++;
  59. PickCam[IDPCmb][IDPC] = IDPCmb, PickCam[IDPCmb][Type] = 2;
  60. PickCam[IDPCmb][PX] = X, PickCam[IDPCmb][PY] = Y, PickCam[IDPCmb][PZ] = Z;
  61. AddStaticPickup(Model,23,X,Y,Z,-1);
  62. if(strlen(Texto)) { Create3DTextLabel(Texto,LABEL_COLOR,X,Y,Z,30,0); }
  63. return 0;
  64. }
  65.  
  66. stock CreateChangeVeh(Model, NewCar, Float:X, Float:Y, Float:Z, Texto[])
  67. {
  68. new IDPCmb = PickupC;
  69. if(PickupC > MAX_PCambio-1)
  70. {
  71. print(">> ERROR: Pickups limit reached!");
  72. IDPCmb = INVALID_CPID;
  73. return IDPCmb;
  74. }
  75. PickupC++; PickCam[IDPCmb][Type] = 0;
  76. PickCam[IDPCmb][IDPC] = IDPCmb, PickCam[IDPCmb][IDNewCar] = NewCar;
  77. PickCam[IDPCmb][PX] = X, PickCam[IDPCmb][PY] = Y, PickCam[IDPCmb][PZ] = Z;
  78. AddStaticPickup(Model,23,X,Y,Z,-1);
  79. if(strlen(Texto)) { Create3DTextLabel(Texto,LABEL_COLOR,X,Y,Z,30,0); }
  80. return 0;
  81. }
  82.  
  83. ScarMaxPC()
  84. {
  85. return PickupC;
  86. }
  87.  
  88. CALLBACK: UpdatePos()
  89. {
  90. for(new pcsc = 0; pcsc < ScarMaxPC(); pcsc++)
  91. {
  92. if(pcsc != INVALID_CPID)
  93. {
  94. ChangeVeh(pcsc);
  95. }
  96. }
  97. }
  98.  
  99. CALLBACK: ChangeVeh(IDPCmb)
  100. {
  101. for(new i = 0; i <MAX_PLAYERS; i++)
  102. {
  103. if(IsPlayerConnected(i))
  104. {
  105. if(IsPlayerInAnyVehicle(i) && JustUsed[i] == 0)
  106. {
  107. new vehicleid = GetPlayerVehicleID(i), color1, color2;
  108. if(IsVehicleInRangeOfPoint(vehicleid,0.8,PickCam[IDPCmb][PX],PickCam[IDPCmb][PY],PickCam[IDPCmb][PZ]))
  109. {
  110. PlayerPlaySound(i, 1133, 0.0, 0.0, 0.0);
  111. if(PickCam[IDPCmb][Type] == 0)
  112. {
  113. PlayerPlaySound(i, 1054, 0.0, 0.0, 0.0);
  114. new Float:Velocidad[3], Float:X, Float:Y, Float:Z, Float:Angulo;
  115. GetVehiclePos(vehicleid, X,Y,Z); GetVehicleZAngle(vehicleid,Angulo);
  116. GetVehicleVelocity(vehicleid, Velocidad[0], Velocidad[1], Velocidad[2]);
  117. GetVehicleColor(vehicleid, color1, color2); DestroyVehicle(vehicleid);
  118. new NewVeh = CreateVehicle(PickCam[IDPCmb][IDNewCar],X,Y,Z,Angulo,color1,color2,180);
  119. PutPlayerInVehicle(i,NewVeh,0);
  120. SetVehicleVelocity(NewVeh, Velocidad[0], Velocidad[1], Velocidad[2]);
  121. }
  122. else if(PickCam[IDPCmb][Type] == 1) { AddVehicleComponent(vehicleid, 1010); }
  123. else if(PickCam[IDPCmb][Type] == 2) { RepairVehicle(vehicleid); }
  124. JustUsed[i] = 1; SetTimerEx("ReactivarT",900,0,"i",i);
  125. }
  126. }
  127. }
  128. }
  129. return 1;
  130. }
  131.  
  132. CALLBACK: ReactivarT(playerid) { JustUsed[playerid] = 0; return 1; }
  133.  
  134. IsVehicleInRangeOfPoint(vehicleid, Float:vrange, Float:x, Float:y, Float:z) //I don't know who made this, sorry.
  135. {
  136. new Float:oldpos[3], Float:temppos[3];
  137. GetVehiclePos(vehicleid, oldpos[0], oldpos[1], oldpos[2]);
  138. temppos[0] = (oldpos[0] -x); temppos[1] = (oldpos[1] -y); temppos[2] = (oldpos[2] -z);
  139. if(((temppos[0] < vrange) && (temppos[0] > -vrange)) && ((temppos[1] < vrange) && (temppos[1] > -vrange)) && ((temppos[2] < vrange) && (temppos[2] > -vrange)))
  140. { return 1; }
  141. return 0;
  142. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement