Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ----------------------[Vehicle Breakdancing System]---------------------- //
- // //
- // Author: Libra | Margi First Release: 21.08.2011 //
- // Last Update: 21.08.2011 Version: v1.0 //
- // Lines: 127 All Rights Reserved //
- // Created for SA-MP 0.3c //
- // //
- // ------------------------------------------------------------------------- //
- #include <a_samp>
- #include <sscanf2>
- #define yellow 0xFFFF00FF
- #define red 0xFF0000FF
- #define BreakdanceMultipier 0.01 //Multipier of vehicle breakdancing system
- #define BreakdanceTime 100 //Number of miliseconds that updates velocity
- #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
- new BreakdanceStyle[MAX_PLAYERS]; //To check which breakdance style does player use
- new Float:BreakdanceVelocity[MAX_PLAYERS]; //To check current velocity of vehicle
- public OnFilterScriptInit()
- {
- SetTimer("OnBreakdanceUpdate",BreakdanceTime,1);
- }
- public OnPlayerConnect(playerid)
- {
- BreakdanceStyle[playerid] = 0;
- BreakdanceVelocity[playerid] = 0.00;
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- dcmd(breakdance,10,cmdtext);
- return 0;
- }
- dcmd_breakdance(playerid,params[])
- {
- new string[200], Style;
- if(!sscanf(params,"d",Style))
- {
- if(Style >= 0 && Style <= 6)
- {
- if(Style == 0)
- {
- SendClientMessage(playerid,yellow,"[INFO]{C0C0C0} You have disabled Vehicle Breakdancing!");
- }
- else
- {
- format(string,sizeof(string),"[INFO]{C0C0C0} You have set your Vehicle Breakdance style to %d!", Style);
- SendClientMessage(playerid,yellow,string);
- }
- BreakdanceStyle[playerid] = Style;
- }
- else return SendClientMessage(playerid,red,"[ERROR]{C0C0C0} Invaild style - vaild styles are between 1 and 6! Use 0 to disable Vehicle Breakdancing!");
- }
- else return SendClientMessage(playerid,red,"[USAGE]{C0C0C0} /breakdance [style 1-6]");
- return 1;
- }
- forward OnBreakdanceUpdate();
- public OnBreakdanceUpdate()
- {
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i) && !IsPlayerNPC(i))
- {
- new Keys,Up,Down;
- GetPlayerKeys(i,Keys,Up,Down);
- if(Keys &= KEY_SUBMISSION)
- {
- if(GetPlayerState(i) == PLAYER_STATE_DRIVER && BreakdanceStyle[i] >= 1)
- {
- new Float:X, Float:Y, Float:Z;
- GetVehicleVelocity(GetPlayerVehicleID(i),X,Y,Z);
- SetVehicleVelocity(GetPlayerVehicleID(i),X,Y,Z);
- BreakdanceVelocity[i]+=Float:BreakdanceMultipier;
- if(X == 0 && Y == 0 && Z == 0)
- {
- SetVehicleVelocity(GetPlayerVehicleID(i),X,Y,Z+0.05); //If X, Y and Z is 0, breakdance wouldn't work
- }
- if(BreakdanceStyle[i] == 1)
- {
- SetVehicleAngularVelocity(GetPlayerVehicleID(i),BreakdanceVelocity[i],0,0);
- }
- else if(BreakdanceStyle[i] == 2)
- {
- SetVehicleAngularVelocity(GetPlayerVehicleID(i),-BreakdanceVelocity[i],0,0);
- }
- else if(BreakdanceStyle[i] == 3)
- {
- SetVehicleAngularVelocity(GetPlayerVehicleID(i),0,BreakdanceVelocity[i],0);
- }
- else if(BreakdanceStyle[i] == 4)
- {
- SetVehicleAngularVelocity(GetPlayerVehicleID(i),0,-BreakdanceVelocity[i],0);
- }
- else if(BreakdanceStyle[i] == 5)
- {
- SetVehicleAngularVelocity(GetPlayerVehicleID(i),0,0,BreakdanceVelocity[i]);
- }
- else if(BreakdanceStyle[i] == 6)
- {
- SetVehicleAngularVelocity(GetPlayerVehicleID(i),0,0,-BreakdanceVelocity[i]);
- }
- }
- }
- else
- {
- BreakdanceVelocity[i] = 0.00;
- }
- }
- }
- return 1;
- }
- // -----------------------------------[EOF]--------------------------------- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement