Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=== FileScript Sencillo del comando /motor.
- //=== - Creditos: Ner0x (Creación en el FS).
- #include <a_samp>
- #define COLOR 0xC2A2DAAA
- #define COLOR_GRAD2 0xBFC0C2FF
- new PrendiendoM[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n-----------------------------------------");
- print("Cargado correctamente");
- print("-------------------------------------------\n");
- ManualVehicleEngineAndLights();
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n-----------------------------------------");
- print("Cerrado Correctamente");
- print("-------------------------------------------\n");
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new string[256];
- new cmd[256];
- new idx;
- cmd = strtok(cmdtext, idx);
- if(strcmp(cmd, "/engine", true) == 0 || strcmp(cmd, "/motor", true) == 0)
- {
- if(GetPlayerState(playerid) == 2)
- {
- new enginem, lights, alarm, doors, bonnet, boot, objective;
- GetVehicleParamsEx(GetPlayerVehicleID(playerid),enginem, lights, alarm, doors, bonnet, boot, objective);
- if(enginem == VEHICLE_PARAMS_ON)
- {
- SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
- format(string,sizeof(string),"* %s apaga el motor del vehiculo.",NombreEx(playerid));
- MensajeCercaDe(10.0, playerid, string, COLOR,COLOR,COLOR,COLOR,COLOR);
- SendClientMessage(playerid, 0xFFFFFFFF, "* Motor {FF0000}Apagado.");
- return 1;
- }
- if(enginem == VEHICLE_PARAMS_OFF)
- {
- if(PrendiendoM[playerid] == 1) return 1;
- SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
- format(string,sizeof(string),"* %s intenta encender el motor del vehiculo.",NombreEx(playerid));
- MensajeCercaDe(10.0, playerid, string, COLOR,COLOR,COLOR,COLOR,COLOR);
- SendClientMessage(playerid, 0x00B000FF, "* Encendiendo{FF0000}...");
- PrendiendoM[playerid] = 1;
- SetTimerEx("PMotor",2000,0,"d",playerid);
- return 1;
- }
- if(enginem == VEHICLE_PARAMS_UNSET)
- {
- if(PrendiendoM[playerid] == 1) return 1;
- SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
- format(string,sizeof(string),"* %s intenta encender el motor del vehiculo.",NombreEx(playerid));
- MensajeCercaDe(10.0, playerid, string, COLOR,COLOR,COLOR,COLOR,COLOR);
- SendClientMessage(playerid, 0x00B000FF, "* Encendiendo{FF0000}...");
- PrendiendoM[playerid] = 1;
- SetTimerEx("PMotor",2000,0,"d",playerid);
- return 1;
- }
- } return SendClientMessage(playerid, COLOR_GRAD2, "Debes estar en un vehiculo.");
- }
- return 0;
- }
- public OnPlayerStateChange(playerid,newstate,oldstate)
- {
- if(newstate == PLAYER_STATE_DRIVER)
- {
- new vehicleid = GetPlayerVehicleID(playerid);
- new enginem, lights, alarm, doors, bonnet, boot, objective;
- GetVehicleParamsEx(vehicleid,enginem, lights, alarm, doors, bonnet, boot, objective);
- if(enginem == VEHICLE_PARAMS_OFF || enginem == VEHICLE_PARAMS_UNSET)
- {
- SendClientMessage(playerid,COLOR,"*MOTOR: El motor del vehiculo se encuentra apagado. Para encender use /motor");
- }
- if(enginem == VEHICLE_PARAMS_ON)
- {
- SendClientMessage(playerid,COLOR,"*MOTOR: El motor del vehiculo se encuentra encendido. Para apagar use /motor");
- }
- }
- return 1;
- }
- forward MensajeCercaDe(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
- public MensajeCercaDe(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);
- 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;
- }
- stock NombreEx(playerid)
- {
- new string[24];
- GetPlayerName(playerid,string,24);
- new str[24];
- strmid(str,string,0,strlen(string),24);
- for(new i = 0; i < MAX_PLAYER_NAME; i++)
- {
- if (str[i] == '_') str[i] = ' ';
- }
- return str;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- forward PMotor(playerid);
- public PMotor(playerid)
- {
- if(GetPlayerState(playerid) == 2)
- {
- new enginem, lights, alarm, doors, bonnet, boot, objective;
- GetVehicleParamsEx(GetPlayerVehicleID(playerid),enginem, lights, alarm, doors, bonnet, boot, objective);
- PrendiendoM[playerid] = 0;
- new REnce = random(2);
- if(REnce == 0)
- {
- SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
- SendClientMessage(playerid, 0x00C900FF, "* Motor Encendido!");
- return 1;
- }
- else if(REnce == 1)
- {
- SendClientMessage(playerid, COLOR_ROJO, "* El motor se atasca y no enciende...");
- }
- return 1;
- }
- PrendiendoM[playerid] = 0;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement