Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Filterscript by SynonymousZ
- //http://forum.sa-mp.de/index.php?page=User&userID=12300
- #include <a_samp>
- new Tempo[MAX_PLAYERS] = -1;
- public OnFilterScriptInit()
- {
- SetTimer("TempoUpdate",10,1);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if (strcmp("/Tempomat", cmdtext, true, 10) == 0)
- {
- ShowPlayerDialog(playerid, 888, DIALOG_STYLE_INPUT,"Tempomat","Gib einen maximalen KM/H-Wert ein.","Okay","Abbrechen");
- return 1;
- }
- return 0;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)Tempo[playerid] = -1;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case 888:
- {
- if(!response)return 1;
- if(!IsNumeric(inputtext))return 1;
- Tempo[playerid] = strval(inputtext);
- return 1;
- }
- }
- return 1;
- }
- GetVehicleSpeed(vehicleid)
- {
- if(vehicleid != INVALID_VEHICLE_ID)
- {
- new Float:Pos[3],Float:VS ;
- GetVehicleVelocity(vehicleid, Pos[0], Pos[1], Pos[2]);
- VS = floatsqroot(Pos[0]*Pos[0] + Pos[1]*Pos[1] + Pos[2]*Pos[2])*200;
- return floatround(VS,floatround_round);
- }
- return INVALID_VEHICLE_ID;
- }
- forward TempoUpdate();
- public TempoUpdate()
- {
- for(new i = 0; i<MAX_PLAYERS; i++)
- {
- if(!IsPlayerConnected(i))continue;
- if(!IsPlayerInAnyVehicle(i))continue;
- if(Tempo[i] < 0)continue;
- if(GetVehicleSpeed(GetPlayerVehicleID(i))<Tempo[i])continue;
- new Float:vX, Float:vY, Float:vZ;
- GetVehicleVelocity(GetPlayerVehicleID(i),vX,vY,vZ);
- SetVehicleVelocity(GetPlayerVehicleID(i),((vX/100)*97),((vY/100)*97),vZ);
- }
- }
- IsNumeric(value[])
- {
- new cpoint;
- while((value[cpoint] >= '0' && value[cpoint] <= '9') || (cpoint == 0 && value[cpoint] == '-'))cpoint++;
- return (value[0] && strlen(value) == cpoint);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement