guhgames

Untitled

Jun 7th, 2012
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. new Float:VehicleX[MAX_VEHICLES],Float:VehicleY[MAX_VEHICLES],Float:VehicleZ[MAX_VEHICLES],Float:Percorreu[MAX_VEHICLES],Timer[MAX_VEHICLES];
  2.  
  3. stock Float:GetDistanceVehicleFromPoint(vehicleid,float:pontox,float:pontoy,float:pontoz)
  4. {
  5.     new Float:x,Float:y,Float:z;
  6.     GetVehiclePos(vehicleid,x1,y1,z1);
  7.     return floatsqroot(floatpower(floatabs(floatsub(pontox,x)),2)+floatpower(floatabs(floatsub(pontoy,y)),2)+floatpower(floatabs(floatsub(pontoz,z)),2));
  8. }
  9. stock GetDistanceTraveled(vehicleid) return Percorreu[vehicleid];
  10.  
  11. public OnGameModeInit()
  12. {
  13.     for(new v; v < MAX_VEHICLES; v++)
  14.     {
  15.        GetVehiclePos(v,VehicleX[v],VehicleY[v],VehicleZ[v]);
  16.     }
  17.     return 1;
  18. }
  19. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  20. {
  21.     Timer[vehicleid] = SetTimerEx("Corrida",2000,true,"i",vehicleid);
  22.     return 1;
  23. }
  24. public OnPlayerExitVehicle(playerid, vehicleid)
  25. {
  26.     KillTimer(Timer[vehicleid]);
  27.     return 1;
  28. }
  29. public forward Corrida(vehicleid)
  30. {
  31.     Percorreu[vehicleid] += GetDistanceVehicleFromPoint(vehicleid,VehicleX[vehicleid],VehicleY[vehicleid],VehicleZ[vehicleid]);
  32.     GetVehiclePos(vehicleid,VehicleX[vehicleid],VehicleY[vehicleid],VehicleZ[vehicleid]);
  33.     return 1;
  34. }
  35. stock SetVehiclePosEx(vehicleid,float:X,float:Y,float:Z)
  36. {
  37.     SetVehiclePos(vehicleid,X,Y,Z);
  38.     VehicleX[vehicleid] = X;
  39.     VehicleY[vehicleid] = Y;
  40.     VehicleZ[vehicleid] = Z;
  41.     return 1;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment