SHOW:
|
|
- or go back to the newest paste.
| 1 | /* | |
| 2 | © Stefantjuh97 | |
| 3 | Mail: [email protected] | |
| 4 | SAMP Forum name: Stefand. | |
| 5 | Release Date: 18-6-2012 | |
| 6 | Version: 3.0 | |
| 7 | ||
| 8 | ||
| 9 | Changelog V2.0 | |
| 10 | Fixed: | |
| 11 | - Headlights keep flashing when you are out of the vehicle. | |
| 12 | Thanks to BrandyPenguin | |
| 13 | ||
| 14 | - if you did /flash 2 times without /flashoff you had a bugged vehicle. | |
| 15 | ||
| 16 | Added: | |
| 17 | - Working for ambulance | |
| 18 | - Working for Firetruck | |
| 19 | ||
| 20 | Changelog V3.0 | |
| 21 | Fixed: | |
| 22 | - /flash for turning flash on and /flash for turning it off | |
| 23 | Thanks to BrandyPenguin | |
| 24 | ||
| 25 | Added: | |
| 26 | - Nothing | |
| 27 | */ | |
| 28 | ||
| 29 | #include <a_samp> | |
| 30 | #include <zcmd> | |
| 31 | ||
| 32 | #define FILTERSCRIPT | |
| 33 | ||
| 34 | forward FlasherFunc(); | |
| 35 | ||
| 36 | new obj[MAX_VEHICLES] = { INVALID_OBJECT_ID, ... };
| |
| 37 | new obj2[MAX_VEHICLES] = { INVALID_OBJECT_ID, ... };
| |
| 38 | new LightPwr[MAX_VEHICLES]; | |
| 39 | new Flasher[MAX_VEHICLES] = 0; | |
| 40 | new FlasherState[MAX_VEHICLES]; | |
| 41 | new FlashTimer; | |
| 42 | ||
| 43 | public OnFilterScriptInit() | |
| 44 | {
| |
| 45 | print("\n--------------------------------------");
| |
| 46 | print(" Police Flash lights V2.1");
| |
| 47 | print(" By Stefantjuh97");
| |
| 48 | print("--------------------------------------\n");
| |
| 49 | ||
| 50 | for (new x=0; x<MAX_VEHICLES; x++) | |
| 51 | {
| |
| 52 | LightPwr[x]=1; | |
| 53 | Flasher[x]=0; | |
| 54 | FlasherState[x]=0; | |
| 55 | } | |
| 56 | ||
| 57 | FlashTimer = SetTimer("FlasherFunc",200,1); // "200" is the speed from the flashing headlights
| |
| 58 | return 1; | |
| 59 | } | |
| 60 | ||
| 61 | public OnFilterScriptExit() | |
| 62 | {
| |
| 63 | KillTimer(FlashTimer); | |
| 64 | for (new i = 0; i < MAX_VEHICLES; i++) | |
| 65 | {
| |
| 66 | DestroyObject(obj[i]); | |
| 67 | DestroyObject(obj2[i]); | |
| 68 | } | |
| 69 | return 1; | |
| 70 | } | |
| 71 | ||
| 72 | ||
| 73 | ||
| 74 | ||
| 75 | public OnVehicleSpawn(vehicleid) | |
| 76 | {
| |
| 77 | DestroyObject(obj[vehicleid]); | |
| 78 | DestroyObject(obj2[vehicleid]); | |
| 79 | Flasher[vehicleid] = 0; | |
| 80 | return 1; | |
| 81 | } | |
| 82 | ||
| 83 | public OnVehicleDeath(vehicleid, killerid) | |
| 84 | {
| |
| 85 | DestroyObject(obj[vehicleid]); | |
| 86 | DestroyObject(obj2[vehicleid]); | |
| 87 | Flasher[vehicleid] = 0; | |
| 88 | return 1; | |
| 89 | } | |
| 90 | ||
| 91 | command(flash, playerid, params[]) | |
| 92 | {
| |
| 93 | if(!IsPlayerAdmin(playerid)) return 1; | |
| 94 | new vehicleid,panels,doors,lights,tires; | |
| 95 | vehicleid = GetPlayerVehicleID(playerid); | |
| 96 | if(!Flasher[vehicleid]) {
| |
| 97 | if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) | |
| 98 | {
| |
| 99 | return SendClientMessage(playerid, -1, "* You are not the driver!"); | |
| 100 | } | |
| 101 | if (!GetVehicleModel(vehicleid)) return SendClientMessage(playerid, -1, "* You are not in a vehicle!"); | |
| 102 | if (IsValidObject(obj[vehicleid]) || IsValidObject(obj2[vehicleid])) | |
| 103 | {
| |
| 104 | SendClientMessage(playerid, -1, "You switched off the lights."), DestroyObject(obj[vehicleid]), DestroyObject(obj2[vehicleid]); | |
| 105 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 106 | if(LightPwr[vehicleid] == 1) | |
| 107 | UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires); | |
| 108 | else | |
| 109 | UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires); | |
| 110 | Flasher[vehicleid] = 0; | |
| 111 | } | |
| 112 | switch (GetVehicleModel(vehicleid)) | |
| 113 | {
| |
| 114 | case 596: | |
| 115 | {
| |
| 116 | obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 117 | obj2[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 118 | AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000); | |
| 119 | AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000); | |
| 120 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 121 | Flasher[vehicleid] = 1; | |
| 122 | } | |
| 123 | case 597: | |
| 124 | {
| |
| 125 | obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 126 | obj2[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 127 | AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000); | |
| 128 | AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000); | |
| 129 | ||
| 130 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 131 | Flasher[vehicleid] = 1; | |
| 132 | } | |
| 133 | case 598: | |
| 134 | {
| |
| 135 | obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 136 | obj2[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 137 | AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.524999, -0.300000, 0.899999, 0.000000, 0.000000, 0.000000); | |
| 138 | AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.524999, -0.300000, 0.899999, 0.000000, 0.000000, 0.000000); | |
| 139 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 140 | Flasher[vehicleid] = 1; | |
| 141 | } | |
| 142 | case 599: | |
| 143 | {
| |
| 144 | obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 145 | obj2[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 146 | AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.524999,0.000000,1.125000,0.000000,0.000000,0.000000); | |
| 147 | AttachObjectToVehicle(obj2[vehicleid], vehicleid, -0.524999,0.000000,1.125000,0.000000,0.000000,0.000000); | |
| 148 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 149 | Flasher[vehicleid] = 1; | |
| 150 | } | |
| 151 | case 541://bullet | |
| 152 | {
| |
| 153 | obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 154 | AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.375000,0.524999,0.375000,0.000000,0.000000,0.000000); | |
| 155 | ||
| 156 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 157 | Flasher[vehicleid] = 1; | |
| 158 | } | |
| 159 | case 426://premier | |
| 160 | {
| |
| 161 | obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 162 | AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.524999,0.749999,0.375000,0.000000,0.000000,0.000000); | |
| 163 | ||
| 164 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 165 | Flasher[vehicleid] = 1; | |
| 166 | } | |
| 167 | case 427://enforcer | |
| 168 | {
| |
| 169 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 170 | Flasher[vehicleid] = 1; | |
| 171 | } | |
| 172 | case 416://Ambulance | |
| 173 | {
| |
| 174 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 175 | Flasher[vehicleid] = 1; | |
| 176 | } | |
| 177 | case 407://FireTruck | |
| 178 | {
| |
| 179 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 180 | Flasher[vehicleid] = 1; | |
| 181 | } | |
| 182 | case 560://sultan | |
| 183 | {
| |
| 184 | obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 185 | AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.225000,0.750000,0.449999,0.000000,0.000000,0.000000); | |
| 186 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 187 | Flasher[vehicleid] = 1; | |
| 188 | } | |
| 189 | case 490://FBI | |
| 190 | {
| |
| 191 | obj[vehicleid] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); | |
| 192 | AttachObjectToVehicle(obj[vehicleid], vehicleid, 0.000000,1.125000,0.599999,0.000000,0.000000,0.000000); | |
| 193 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 194 | Flasher[vehicleid] = 1; | |
| 195 | } | |
| 196 | default: | |
| 197 | {
| |
| 198 | return SendClientMessage(playerid, -1, "You are not in a CODE 2 compatible police vehicle!"); | |
| 199 | } | |
| 200 | } | |
| 201 | return SendClientMessage(playerid, -1, "Lights on, you are now in a CODE 2 run!"); | |
| 202 | } else {
| |
| 203 | if (IsValidObject(obj[vehicleid]) || IsValidObject(obj2[vehicleid])) {
| |
| 204 | SendClientMessage(playerid, -1, "You switched off the lights."), DestroyObject(obj[vehicleid]), DestroyObject(obj2[vehicleid]); | |
| 205 | } | |
| 206 | GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires); | |
| 207 | if(LightPwr[vehicleid] == 1) | |
| 208 | UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires); | |
| 209 | else | |
| 210 | UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires); | |
| 211 | Flasher[vehicleid] = 0; | |
| 212 | } | |
| 213 | return 1; | |
| 214 | } | |
| 215 | ||
| 216 | public FlasherFunc() {
| |
| 217 | new panelsx,doorsx,lightsx,tiresx; | |
| 218 | for (new p=0; p<MAX_VEHICLES; p++) | |
| 219 | {
| |
| 220 | if (Flasher[p] == 1) | |
| 221 | {
| |
| 222 | if (FlasherState[p] == 1) | |
| 223 | {
| |
| 224 | GetVehicleDamageStatus(p,panelsx,doorsx,lightsx,tiresx); | |
| 225 | UpdateVehicleDamageStatus(p, panelsx, doorsx, 4, tiresx); | |
| 226 | FlasherState[p] = 0; | |
| 227 | } | |
| 228 | else | |
| 229 | {
| |
| 230 | GetVehicleDamageStatus(p,panelsx,doorsx,lightsx,tiresx); | |
| 231 | UpdateVehicleDamageStatus(p, panelsx, doorsx, 1, tiresx); | |
| 232 | FlasherState[p] = 1; | |
| 233 | } | |
| 234 | } | |
| 235 | } | |
| 236 | return 1; | |
| 237 | } |