OtaconEvil

[CODE] Simple encendido/apagado del motor | By OTACON

Dec 15th, 2014
411
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. new bool:Motor[MAX_VEHICLES],
  2. bool:pMotor[MAX_VEHICLES][7];
  3.  
  4. #if defined FILTERSCRIPT
  5. public OnFilterScriptInit() ManualVehicleEngineAndLights();
  6. #else
  7. public OnGameModeInit() ManualVehicleEngineAndLights();
  8. #endif
  9.  
  10. if(!strcmp("/motor", cmdtext)){
  11.     new cmd[100];
  12.     new vehicleid = GetPlayerVehicleID(playerid);
  13.     if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,-1,"no estas en un vehiculo");
  14.     if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)return SendClientMessage(playerid,-1,"no eres conductor");
  15.     cmd = strtok(cmdtext, idx);
  16.     if(!strcmp(cmd, "encender")){
  17.         if(Motor[vehicleid] != true){
  18.             Motor[vehicleid] = true;
  19.             pMotor[vehicleid][0] = true;
  20.             GetVehicleParamsEx(vehicleid, pMotor[vehicleid][0], pMotor[vehicleid][1], pMotor[vehicleid][2], pMotor[vehicleid][3], pMotor[vehicleid][4], pMotor[vehicleid][5], pMotor[vehicleid][6]);
  21.             SetVehicleParamsEx(vehicleid, pMotor[vehicleid][0], pMotor[vehicleid][1], pMotor[vehicleid][2], pMotor[vehicleid][3], pMotor[vehicleid][4], pMotor[vehicleid][5], pMotor[vehicleid][6]);
  22.             SendClientMessage(playerid,-1,"haz encendido el motor");
  23.         }else{
  24.             SendClientMessage(playerid,-1,"el motor ya esta encendido");
  25.         }
  26.     }
  27.     else if(!strcmp(cmd, "apagar")){
  28.         if(Motor[vehicleid] == true){
  29.             Motor[vehicleid] = true;
  30.             pMotor[vehicleid][0] = false;
  31.             GetVehicleParamsEx(vehicleid, pMotor[vehicleid][0], pMotor[vehicleid][1], pMotor[vehicleid][2], pMotor[vehicleid][3], pMotor[vehicleid][4], pMotor[vehicleid][5], pMotor[vehicleid][6]);
  32.             SetVehicleParamsEx(vehicleid, pMotor[vehicleid][0], pMotor[vehicleid][1], pMotor[vehicleid][2], pMotor[vehicleid][3], pMotor[vehicleid][4], pMotor[vehicleid][5], pMotor[vehicleid][6]);
  33.             SendClientMessage(playerid,-1,"haz apagado el motor");
  34.         }else{
  35.             SendClientMessage(playerid,-1,"el motor no esta encendido");
  36.         }
  37.     }
  38.     return true;
  39. }
  40.  
  41. public OnPlayerStateChange(playerid, newstate, oldstate){
  42.     new vehicleid = GetPlayerVehicleID(playerid);
  43.     if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER){
  44.         if(Motor[vehicleid] == true)SendClientMessage(playerid,-1,"el motor esta encendido, usa el comando /motor[apagar] para apagarlo");
  45.         else SendClientMessage(playerid,-1,"el motor esta apagado, usa el comando /motor[encender] para encenderlo");
  46.     }
  47.     return true;
  48. }
RAW Paste Data