Advertisement
Johurt

[FS] jLights.

Jul 18th, 2013
1,142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.80 KB | None | 0 0
  1. /*
  2.         jLights by Johurt(ES.^, Edgar).
  3.         Date: 2013-07-18
  4.         Video: http://www.youtube.com/watch?v=mM2epAmab8c
  5. */
  6. #include <a_samp>
  7. new pLights[MAX_PLAYERS], bool:LightsOnOff[MAX_PLAYERS];
  8.  
  9. public OnGameModeInit()
  10. {
  11.     SetTimer("Timer", 300, true);
  12.     return 1;
  13. }
  14.  
  15. public OnPlayerCommandText(playerid, cmdtext[])
  16. {
  17.     if(!strcmp("/lights", cmdtext, true, 7))
  18.     {
  19.         if(!LightsOnOff[playerid])
  20.         {
  21.             LightsOnOff[playerid] = true;
  22.         }
  23.         else
  24.         {
  25.             LightsOnOff[playerid] = false;
  26.             new vehicleid = GetPlayerVehicleID(playerid), panels, doors, lights, tires;
  27.             if(vehicleid != 0 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  28.             {
  29.                 GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
  30.                 UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
  31.             }
  32.         }
  33.         return 1;
  34.     }
  35.     return 0;
  36. }
  37.  
  38. public OnPlayerExitVehicle(playerid, vehicleid)
  39. {
  40.     new panels, doors, lights, tires;
  41.     GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
  42.     UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
  43.     return 1;
  44. }
  45.  
  46. forward Timer();
  47. public Timer()
  48. {
  49.     new p, vehicleid, panels, doors, lights, tires;
  50.     for(p = 0; p < MAX_PLAYERS; p++)
  51.     {
  52.         if(!IsPlayerConnected(p) || IsPlayerNPC(p)) continue;
  53.         {
  54.             vehicleid = GetPlayerVehicleID(p);
  55.             if(vehicleid != 0 && GetPlayerState(p) == PLAYER_STATE_DRIVER)
  56.             {
  57.                 if(LightsOnOff[p])
  58.                 {
  59.                     if(pLights[p] != 1 && pLights[p] != 4)
  60.                     {
  61.                         pLights[p] = 1;
  62.                     }
  63.                     else
  64.                     {
  65.                         if(pLights[p] == 1)
  66.                         {
  67.                             pLights[p] = 4;
  68.                         }
  69.                         else
  70.                         {
  71.                             pLights[p] = 1;
  72.                         }
  73.                     }
  74.                     GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
  75.                     UpdateVehicleDamageStatus(vehicleid, panels, doors, pLights[p], tires);
  76.                 }
  77.             }
  78.         }
  79.     }
  80.     return 1;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement