Advertisement
Guest User

Untitled

a guest
Sep 28th, 2014
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. CMD:vontat(playerid)
  2. {
  3. if(Belepve[playerid]!= 0)
  4. {
  5. if(IsPlayerInAnyVehicle(playerid))
  6. {
  7. new vehid = GetPlayerVehicleID(playerid);
  8. if(GetVehicleModel(vehid) == 525)
  9. {
  10. new kocsi = GetClosestVehicle(playerid);
  11. new id= -1;
  12. for(new x=0;x<MAX_VEHICLES;x++)
  13. {
  14. if(GetDistanceToVehicle(playerid, x) < 10)
  15. {
  16. if(id == -1)
  17. {
  18. id = x;
  19. }
  20. else
  21. {
  22. if(GetDistanceToVehicle(playerid,id) > GetDistanceToVehicle(playerid,x) && kocsi != x)
  23. {
  24. id=x;
  25.  
  26. }
  27. }
  28. }
  29. }
  30. if(id == -1) return SendClientMessage(playerid, HIBA, "A közelben nincs jármű!");
  31. if(GetVehicleTrailer(vehid) == 0)
  32. {
  33. AttachTrailerToVehicle(id, vehid);
  34. SendClientMessage(playerid,SIKERES,"Felcsatolva.");
  35. new string[256];
  36. format(string,sizeof(string),"TESZT: Vontató: %d | Vontatni való: %d",kocsi,id);
  37. SendClientMessage(playerid,-1,string);
  38. return 1;
  39. }
  40. else
  41. {
  42. DetachTrailerFromVehicle(vehid);
  43. SendClientMessage(playerid,SIKERES,"Lecsatolva.");
  44. new string[256];
  45. format(string,sizeof(string),"TESZT: Vontató: %d | Vontatni való: %d",kocsi,id);
  46. SendClientMessage(playerid,-1,string);
  47. return 1;
  48. }
  49.  
  50.  
  51. }
  52. else SendClientMessage(playerid,HIBA,"Ez nem vontatókocsi!");
  53. }
  54. else SendClientMessage(playerid,HIBA,"Nem vagy autóban!");
  55. }
  56. else Logolj(playerid);
  57. return 1;
  58. }
  59. stock GetClosestVehicle(playerid)
  60. {
  61. #define ALAPKOCSI 1
  62.  
  63. new kocsi = -1;
  64. if(IsPlayerInAnyVehicle(playerid)) kocsi = GetPlayerVehicleID(playerid);
  65.  
  66. if(kocsi != -1)
  67. return kocsi;
  68.  
  69. if(IsPlayerConnected(playerid) && IsVehicleConnected(ALAPKOCSI))
  70. {
  71. new closestvehicle=ALAPKOCSI;
  72. new Float:closestdist=GetDistanceToVehicle(playerid,ALAPKOCSI);
  73. for(new vehicleid=ALAPKOCSI; vehicleid<MAX_VEHICLES; vehicleid++)
  74. {
  75. new Float:dist = GetDistanceToVehicle(playerid,vehicleid);
  76. if(dist < closestdist)
  77. {
  78. if(kocsi == -1 || kocsi != -1 && kocsi != vehicleid)
  79. closestdist = dist;
  80. closestvehicle = vehicleid;
  81. }
  82. }
  83. return closestvehicle;
  84. }
  85. return -1;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement