Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*------------------------------------------------------------------------------
- Thanks for downloading the SA-MP Light Control FS by Pghpunkid. Please feel free
- to modify as you need. Also, please do not redistribute without my authorization
- first. And if you do (with or without my permission) Please leave this header
- section. To make this work, simply delete the "//" before "#include" on line 16
- then recompile! By doing this, you agree to the above requirements and are going
- to follow these few rules of using this free code.
- Thanks and enjoy!
- -Pghpunkid
- ------------------------------------------------------------------------------*/
- #include <a_samp>
- new LightPwr[MAX_VEHICLES];
- new Flasher[MAX_VEHICLES];
- new FlasherState[MAX_VEHICLES];
- new FlashTimer;
- public OnFilterScriptInit()
- {
- print("\n-----------------------------------");
- print(" Light Control FS by Pghpunkid");
- print("-----------------------------------\n");
- for (new x=0; x<MAX_VEHICLES; x++)
- {
- LightPwr[x]=1;
- Flasher[x]=0;
- FlasherState[x]=0;
- }
- FlashTimer = SetTimer("FlasherFunc",100,1);
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n-----------------------------------");
- print(" Light Control FS Unloaded");
- print("-----------------------------------\n");
- KillTimer(FlashTimer);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256], idx;
- cmd = strtok(cmdtext, idx);
- new vehicleid,panels,doors,lights,tires;
- if (strcmp("/lightsoff", cmd, true) == 0)
- {
- vehicleid = GetPlayerVehicleID(playerid);
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
- LightPwr[vehicleid] = 0;
- Flasher[vehicleid] = 0;
- return 1;
- }
- if (strcmp("/lightswat", cmd, true) == 0)
- {
- vehicleid = GetPlayerVehicleID(playerid);
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 3, tires);
- LightPwr[vehicleid] = 1;
- Flasher[vehicleid] = 0;
- return 1;
- }
- if (strcmp("/lightson", cmd, true) == 0)
- {
- vehicleid = GetPlayerVehicleID(playerid);
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
- LightPwr[vehicleid] = 1;
- Flasher[vehicleid] = 0;
- return 1;
- }
- if (strcmp("/lightsflash", cmd, true) == 0)
- {
- vehicleid = GetPlayerVehicleID(playerid);
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- Flasher[vehicleid] = 1;
- return 1;
- }
- if (strcmp("/lightsflashoff", cmd, true) == 0)
- {
- vehicleid = GetPlayerVehicleID(playerid);
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- if (LightPwr[vehicleid] == 1)
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
- else
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
- Flasher[vehicleid] = 0;
- return 1;
- }
- return 0;
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- if (LightPwr[vehicleid] == 0)
- {
- new panels,doors,lights,tires;
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
- }
- else
- {
- new panels,doors,lights,tires;
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
- }
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- Flasher[vehicleid] = 0;
- if (LightPwr[vehicleid] == 0)
- {
- new panels,doors,lights,tires;
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
- }
- else
- {
- new panels,doors,lights,tires;
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
- }
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- if (LightPwr[vehicleid] == 0)
- {
- new panels,doors,lights,tires;
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
- }
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- if (LightPwr[vehicleid] == 0)
- {
- new panels,doors,lights,tires;
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
- }
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- if (LightPwr[vehicleid] == 0)
- {
- new panels,doors,lights,tires;
- GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
- }
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- //Option A
- /*
- public OnPlayerUpdate(playerid)
- {
- if (IsPlayerInAnyVehicle(playerid))
- {
- new id;
- id = GetPlayerVehicleID(playerid);
- if (Flasher[id] == 1)
- {
- if (FlasherState[id] == 1)
- {
- new panels,doors,lights,tires;
- GetVehicleDamageStatus(id,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(id, panels, doors, 4, tires);
- FlasherState[id] = 0;
- }
- else {
- new panels,doors,lights,tires;
- GetVehicleDamageStatus(id,panels,doors,lights,tires);
- UpdateVehicleDamageStatus(id, panels, doors, 1, tires);
- FlasherState[id] = 1;
- }
- }
- }
- return 1;
- }
- */
- //Option B
- forward FlasherFunc();
- public FlasherFunc() {
- for (new p=0; p<MAX_PLAYERS; p++)
- {
- if (IsPlayerInAnyVehicle(p) && IsPlayerConnected(p) && !IsPlayerNPC(p))
- {
- new id;
- new panelsx,doorsx,lightsx,tiresx;
- id = GetPlayerVehicleID(p);
- if (Flasher[id] == 1)
- {
- if (FlasherState[id] == 1)
- {
- GetVehicleDamageStatus(id,panelsx,doorsx,lightsx,tiresx);
- UpdateVehicleDamageStatus(id, panelsx, doorsx, 4, tiresx);
- FlasherState[id] = 0;
- }
- else {
- GetVehicleDamageStatus(id,panelsx,doorsx,lightsx,tiresx);
- UpdateVehicleDamageStatus(id, panelsx, doorsx, 1, tiresx);
- FlasherState[id] = 1;
- }
- }
- }
- }
- return 1;
- }
- 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;
- }
- stock DelPrint(string1[])
- {
- strmid(string1, string1, 0, strlen(string1)-1, 255);
- //printf("%s", string1);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment