Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //==============================================================================
- // SYSTEM Menjac
- // SCRIPTED BY Ranko
- // VERSION v1.0
- //==============================================================================
- #define FILTERSCRIPT
- #include <a_samp>
- #define PRESSED(%0) \
- (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
- #define SpeedCheck(%0,%1,%2,%3,%4) floatround(floatsqroot(%4?(%0*%0+%1*%1+%2*%2):(%0*%0+%1*%1) ) *%3*1.6)
- new BrzinaLimit[MAX_PLAYERS];
- new Brzina[MAX_VEHICLES];
- new Text:Brzinatxd[MAX_PLAYERS];
- #define MAX_BRZINA 5
- #define VOZILO_BRZINA 31
- #if defined FILTERSCRIPT
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Menjanje brzina by Ranko ");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n--------------------------------------");
- print(" Menjanje brzina by Ranko ");
- print("--------------------------------------\n");
- return 1;
- }
- #else
- main()
- {
- return 1;
- }
- #endif
- public OnGameModeInit()
- {
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- Brzinatxd[playerid] = TextDrawCreate(558.5,333,"_");
- TextDrawFont(Brzinatxd[playerid], 3);
- TextDrawLetterSize(Brzinatxd[playerid], 0.53, 1.20);
- TextDrawColor(Brzinatxd[playerid], -16776961);
- TextDrawBackgroundColor(Brzinatxd[playerid], 51);
- TextDrawSetOutline(Brzinatxd[playerid], 0);
- TextDrawSetProportional(Brzinatxd[playerid], 1);
- TextDrawSetShadow(Brzinatxd[playerid], 1);
- BrzinaLimit[playerid] = 0;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- TextDrawDestroy(Brzinatxd[playerid]);
- BrzinaLimit[playerid] = 0;
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- BrzinaLimit[playerid] = 0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- BrzinaLimit[playerid] = 0;
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- Brzina[vehicleid] = 0;
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- Brzina[vehicleid] = 0;
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- BrzinaLimit[playerid] = Brzina[vehicleid] * 20;
- if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
- {
- BrzinaLimit[playerid] = 999;
- }
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- BrzinaLimit[playerid] = 0;
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if (PRESSED(KEY_YES)) // Brzina visa
- {
- if(!IsPlayerInAnyVehicle(playerid)) return 1;
- new string[128];
- if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510) return 1;
- if(Brzina[GetPlayerVehicleID(playerid)] <= MAX_BRZINA)
- {
- Brzina[GetPlayerVehicleID(playerid)] ++;
- format(string, sizeof(string), "Brzina: %d", Brzina[GetPlayerVehicleID(playerid)]);
- TextDrawSetString(Brzinatxd[playerid], string);
- TextDrawShowForPlayer(playerid, Brzinatxd[playerid]);
- }
- else
- {
- }
- }
- if (PRESSED(KEY_NO)) // Brzina manja
- {
- new string[128];
- if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510) return 1;
- if(Brzina[GetPlayerVehicleID(playerid)] > -1)
- {
- Brzina[GetPlayerVehicleID(playerid)] --;
- format(string, sizeof(string), "Brzina: %d", Brzina[GetPlayerVehicleID(playerid)]);
- if(Brzina[GetPlayerVehicleID(playerid)] == -1)
- {
- }
- TextDrawSetString(Brzinatxd[playerid], string);
- TextDrawShowForPlayer(playerid, Brzinatxd[playerid]);
- }
- }
- return 1;
- }
- stock ModifyVehicleSpeed(vehicleid,mph)
- {
- new Float:Vx,Float:Vy,Float:Vz,Float:DV,Float:multiple;
- GetVehicleVelocity(vehicleid,Vx,Vy,Vz);
- DV = floatsqroot(Vx*Vx + Vy*Vy + Vz*Vz);
- if(DV > 0)
- {
- multiple = ((mph + DV * 100) / (DV * 100));
- return SetVehicleVelocity(vehicleid,Vx*multiple,Vy*multiple,Vz*multiple);
- }
- return 0;
- }
- stock IsVehicleDrivingBackwards(vehicleid)
- {
- new
- Float:Float[3]
- ;
- if(GetVehicleVelocity(vehicleid, Float[1], Float[2], Float[0]))
- {
- GetVehicleZAngle(vehicleid, Float[0]);
- if(Float[0] < 90)
- {
- if(Float[1] > 0 && Float[2] < 0) return true;
- }
- else if(Float[0] < 180)
- {
- if(Float[1] > 0 && Float[2] > 0) return true;
- }
- else if(Float[0] < 270)
- {
- if(Float[1] < 0 && Float[2] > 0) return true;
- }
- else if(Float[1] < 0 && Float[2] < 0) return true;
- }
- return false;
- }
- stock GetVehicleSpeed(vehicleid, get3d)
- {
- new Float:x, Float:y, Float:z;
- GetVehicleVelocity(vehicleid, x, y, z);
- return SpeedCheck(x, y, z, 100.0, get3d);
- }
- IsAPlane(carid)
- {
- switch(GetVehicleModel(carid)) {
- case 592, 577, 511, 512, 593, 520, 553, 476, 519, 460, 513, 548, 425, 417, 487, 488, 497, 563, 447, 469: return 1;
- }
- return 0;
- }
- public OnPlayerUpdate(playerid)
- {
- new string[128];
- BrzinaLimit[playerid] = Brzina[GetPlayerVehicleID(playerid)] * VOZILO_BRZINA;
- if(Brzina[GetPlayerVehicleID(playerid)] == -1)
- {
- BrzinaLimit[playerid] = 0;
- }
- if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
- {
- new a, b, c;
- GetPlayerKeys(playerid, a, b ,c);
- if(IsVehicleDrivingBackwards(GetPlayerVehicleID(playerid)))
- {
- if(Brzina[GetPlayerVehicleID(playerid)] == -1)
- {
- return 1;
- }
- else
- {
- ModifyVehicleSpeed(GetPlayerVehicleID(playerid), - GetVehicleSpeed(GetPlayerVehicleID(playerid), 0));
- }
- }
- if(a == 8 && GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) > BrzinaLimit[playerid])
- {
- if(IsVehicleDrivingBackwards(GetPlayerVehicleID(playerid)))
- {
- if(Brzina[GetPlayerVehicleID(playerid)] != -1) return ModifyVehicleSpeed(GetPlayerVehicleID(playerid), - GetVehicleSpeed(GetPlayerVehicleID(playerid), 0));
- }
- if(!IsVehicleDrivingBackwards(GetPlayerVehicleID(playerid)))
- {
- if(Brzina[GetPlayerVehicleID(playerid)] == -1) return ModifyVehicleSpeed(GetPlayerVehicleID(playerid), - GetVehicleSpeed(GetPlayerVehicleID(playerid), 0));
- }
- new newspeed = GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) - BrzinaLimit[playerid];
- ModifyVehicleSpeed(GetPlayerVehicleID(playerid), -newspeed);
- }
- if(GetVehicleModel(GetPlayerVehicleID(playerid)) != 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) != 510 || !IsAPlane(GetPlayerVehicleID(playerid)))
- {
- if(IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid))
- {
- TextDrawShowForPlayer(playerid,Brzinatxd[playerid]);
- format(string,sizeof(string),"Brzina: %d",Brzina[GetPlayerVehicleID(playerid)]);
- if(Brzina[GetPlayerVehicleID(playerid)] == -1)
- {
- format(string,sizeof(string),"Brzina: R");
- }
- TextDrawSetString(Brzinatxd[playerid],string);
- }
- }
- else if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 481 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 509 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 510 || !IsAPlane(GetPlayerVehicleID(playerid)))
- {
- BrzinaLimit[playerid] = 999;
- }
- return 1;
- }
- if(!IsPlayerInAnyVehicle(playerid))
- {
- TextDrawHideForPlayer(playerid,Brzinatxd[playerid]);
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement