Advertisement
SynonymousZ-Scripts

Tempomat

Jul 28th, 2014
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.88 KB | None | 0 0
  1. //Filterscript by SynonymousZ
  2. //http://forum.sa-mp.de/index.php?page=User&userID=12300
  3. #include <a_samp>
  4. new Tempo[MAX_PLAYERS] = -1;
  5.  
  6. public OnFilterScriptInit()
  7. {
  8.     SetTimer("TempoUpdate",10,1);
  9.     return 1;
  10. }
  11.  
  12. public OnPlayerCommandText(playerid, cmdtext[])
  13. {
  14.     if (strcmp("/Tempomat", cmdtext, true, 10) == 0)
  15.     {
  16.         ShowPlayerDialog(playerid, 888, DIALOG_STYLE_INPUT,"Tempomat","Gib einen maximalen KM/H-Wert ein.","Okay","Abbrechen");
  17.         return 1;
  18.     }
  19.     return 0;
  20. }
  21.  
  22. public OnPlayerStateChange(playerid, newstate, oldstate)
  23. {
  24.     if(newstate == PLAYER_STATE_DRIVER)Tempo[playerid] = -1;
  25.     return 1;
  26. }
  27.  
  28. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  29. {
  30.     switch(dialogid)
  31.     {
  32.         case 888:
  33.         {
  34.             if(!response)return 1;
  35.             if(!IsNumeric(inputtext))return 1;
  36.             Tempo[playerid] = strval(inputtext);
  37.             return 1;
  38.         }
  39.     }
  40.     return 1;
  41. }
  42.  
  43. GetVehicleSpeed(vehicleid)
  44. {
  45.     if(vehicleid != INVALID_VEHICLE_ID)
  46.     {
  47.         new Float:Pos[3],Float:VS ;
  48.         GetVehicleVelocity(vehicleid, Pos[0], Pos[1], Pos[2]);
  49.         VS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
  50.         return floatround(VS,floatround_round);
  51.     }
  52.     return INVALID_VEHICLE_ID;
  53. }
  54. forward TempoUpdate();
  55. public TempoUpdate()
  56. {
  57.     for(new i = 0; i<MAX_PLAYERS; i++)
  58.     {
  59.         if(!IsPlayerConnected(i))continue;
  60.         if(!IsPlayerInAnyVehicle(i))continue;
  61.         if(Tempo[i] < 0)continue;
  62.         if(GetVehicleSpeed(GetPlayerVehicleID(i))<Tempo[i])continue;
  63.         new Float:vX, Float:vY, Float:vZ;
  64.         GetVehicleVelocity(GetPlayerVehicleID(i),vX,vY,vZ);
  65.         SetVehicleVelocity(GetPlayerVehicleID(i),((vX/100)*97),((vY/100)*97),vZ);
  66.     }
  67. }
  68. IsNumeric(value[])
  69. {
  70.     new cpoint;
  71.     while((value[cpoint] >= '0' && value[cpoint] <= '9') || (cpoint == 0 && value[cpoint] == '-'))cpoint++;
  72.     return (value[0] && strlen(value) == cpoint);
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement