Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- - Sistema de Freno de Mano - ( RolePlay Script )
- - Tipo: Base.
- - Autor: [J]ulian.
- - Para: sa-mp.com
- */
- #include <a_samp>
- #define COLOR_PURPLE 0xC2A2DAAA
- new idioma; // 0 - Spanish. 1 - English.
- new FrenodeMano[MAX_VEHICLES] = 0;
- new Float:VehFrenoPOS[MAX_VEHICLES][4];
- new Float:VehComprobar[MAX_VEHICLES][4];
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/frenodemano", true) || !strcmp(cmdtext, "/handbrake", true))
- {
- if(IsPlayerInAnyVehicle(playerid))
- {
- new coche = GetPlayerVehicleID(playerid);
- new nombre[MAX_PLAYER_NAME], string_freno[128], partes[7];
- GetPlayerName(playerid, nombre, sizeof(nombre));
- if(FrenodeMano[coche] == 1)
- {
- FrenodeMano[coche] = 0;
- if(idioma == 0) format(string_freno, sizeof(string_freno), "* %s quitó el freno de mano al vehículo.", nombre);
- if(idioma == 1) format(string_freno, sizeof(string_freno), "* %s took the hand brake the vehicle.", nombre);
- ProxDetector(30.0, playerid, string_freno, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
- GetVehicleParamsEx(coche, partes[0], partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
- SetVehicleParamsEx(coche,VEHICLE_PARAMS_ON, partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
- return 1;
- }
- if(FrenodeMano[coche] == 0)
- {
- FrenodeMano[coche] = 1;
- GetVehiclePos(coche, VehFrenoPOS[coche][0], VehFrenoPOS[coche][1], VehFrenoPOS[coche][2]);
- GetVehicleZAngle(coche, VehFrenoPOS[coche][3]);
- SetVehicleVelocity(coche, 0, 0, 0);
- if(idioma == 0) format(string_freno, sizeof(string_freno), "* %s colocó el freno de mano al vehículo.", nombre);
- if(idioma == 1) format(string_freno, sizeof(string_freno), "* %s put the hand brake the vehicle.", nombre);
- ProxDetector(30.0, playerid, string_freno, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
- GetVehicleParamsEx(coche, partes[0], partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
- SetVehicleParamsEx(coche,VEHICLE_PARAMS_OFF, partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
- return 1;
- }
- }
- else
- {
- if(idioma == 0) return SendClientMessage(playerid, -1, "* Debés estar en un vehículo.");
- if(idioma == 1) return SendClientMessage(playerid, -1, "* You must be in a vehicle.");
- }
- return 1;
- }
- return 0;
- }
- public OnUnoccupiedVehicleUpdate(vehicleid, playerid, passenger_seat)
- {
- if(FrenodeMano[vehicleid] == 1)
- {
- GetVehiclePos(playerid, VehComprobar[vehicleid][0], VehComprobar[vehicleid][1], VehComprobar[vehicleid][2]);
- GetVehicleZAngle(playerid, VehComprobar[playerid][3]);
- if(VehComprobar[vehicleid][0] == VehFrenoPOS[vehicleid][0] || VehComprobar[vehicleid][1] == VehFrenoPOS[vehicleid][1] || VehComprobar[vehicleid][2] == VehFrenoPOS[vehicleid][2]|| VehComprobar[vehicleid][3] == VehFrenoPOS[vehicleid][3]) return 1;
- SetVehiclePos(vehicleid, VehFrenoPOS[vehicleid][0], VehFrenoPOS[vehicleid][1], VehFrenoPOS[vehicleid][2]);
- SetVehicleZAngle(vehicleid, VehComprobar[playerid][3]);
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
- {
- if (IsPlayerInAnyVehicle(playerid))
- {
- new coche = GetPlayerVehicleID(playerid);
- new nombre[MAX_PLAYER_NAME], string_freno[128], partes[7];
- GetPlayerName(playerid, nombre, sizeof(nombre));
- if(FrenodeMano[coche] == 1)
- {
- FrenodeMano[coche] = 0;
- if(idioma == 0) format(string_freno, sizeof(string_freno), "* %s quitó el freno de mano al vehículo.", nombre);
- if(idioma == 1) format(string_freno, sizeof(string_freno), "* %s took the hand brake the vehicle.", nombre);
- ProxDetector(30.0, playerid, string_freno, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
- GetVehicleParamsEx(coche, partes[0], partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
- SetVehicleParamsEx(coche,VEHICLE_PARAMS_ON, partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
- return 1;
- }
- if(FrenodeMano[coche] == 0)
- {
- FrenodeMano[coche] = 1;
- GetVehiclePos(coche, VehFrenoPOS[coche][0], VehFrenoPOS[coche][1], VehFrenoPOS[coche][2]);
- GetVehicleZAngle(coche, VehFrenoPOS[coche][3]);
- SetVehicleVelocity(coche, 0, 0, 0);
- if(idioma == 0) format(string_freno, sizeof(string_freno), "* %s colocó el freno de mano al vehículo.", nombre);
- if(idioma == 1) format(string_freno, sizeof(string_freno), "* %s put the hand brake the vehicle.", nombre);
- ProxDetector(30.0, playerid, string_freno, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
- GetVehicleParamsEx(coche, partes[0], partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
- SetVehicleParamsEx(coche,VEHICLE_PARAMS_OFF, partes[1], partes[2], partes[3], partes[4], partes[5], partes[6]);
- return 1;
- }
- }
- }
- return 1;
- }
- forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
- public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
- {
- if(IsPlayerConnected(playerid))
- {
- new Float:posx, Float:posy, Float:posz;
- new Float:oldposx, Float:oldposy, Float:oldposz;
- new Float:tempposx, Float:tempposy, Float:tempposz;
- GetPlayerPos(playerid, oldposx, oldposy, oldposz);
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
- {
- GetPlayerPos(i, posx, posy, posz);
- tempposx = (oldposx -posx);
- tempposy = (oldposy -posy);
- tempposz = (oldposz -posz);
- //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
- if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
- {
- SendClientMessage(i, col1, string);
- }
- else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
- {
- SendClientMessage(i, col2, string);
- }
- else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
- {
- SendClientMessage(i, col3, string);
- }
- else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
- {
- SendClientMessage(i, col4, string);
- }
- else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
- {
- SendClientMessage(i, col5, string);
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement