SHOW:
|
|
- or go back to the newest paste.
| 1 | /* | |
| 2 | SA-MP "GetVehicleColor v2.1" Include | |
| 3 | Copyright © 2011 RyDeR` | |
| 4 | */ | |
| 5 | ||
| 6 | #if defined _Included_GetVehicleColor | |
| 7 | #endinput | |
| 8 | #endif | |
| 9 | ||
| 10 | #define _Included_GetVehicleColor | |
| 11 | ||
| 12 | #define PROPERTY_OFFSET(%0) \ | |
| 13 | ((((%0) * ((%0) << 1)) << 2) + 65536) | |
| 14 | ||
| 15 | stock n_AddStaticVehicle(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2) | |
| 16 | {
| |
| 17 | if(color1 < 0 || color2 < 0) | |
| 18 | {
| |
| 19 | color1 = random(127); | |
| 20 | color2 = random(127); | |
| 21 | } | |
| 22 | modelID = AddStaticVehicle(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2); | |
| 23 | ||
| 24 | new | |
| 25 | colorStr[24] | |
| 26 | ; | |
| 27 | format(colorStr, sizeof(colorStr), "%d-%d", color1, color2); | |
| 28 | setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr); | |
| 29 | ||
| 30 | return modelID; | |
| 31 | } | |
| 32 | #if defined _ALS_AddStaticVehicle | |
| 33 | #undef AddStaticVehicle | |
| 34 | #else | |
| 35 | #define _ALS_AddStaticVehicle | |
| 36 | #endif | |
| 37 | #define AddStaticVehicle n_AddStaticVehicle | |
| 38 | ||
| 39 | stock n_AddStaticVehicleEx(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2, respawn_Delay) | |
| 40 | {
| |
| 41 | if(color1 < 0 || color2 < 0) | |
| 42 | {
| |
| 43 | color1 = random(127); | |
| 44 | color2 = random(127); | |
| 45 | } | |
| 46 | modelID = AddStaticVehicleEx(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2, respawn_Delay); | |
| 47 | ||
| 48 | new | |
| 49 | colorStr[24] | |
| 50 | ; | |
| 51 | format(colorStr, sizeof(colorStr), "%d-%d", color1, color2); | |
| 52 | setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr); | |
| 53 | ||
| 54 | return modelID; | |
| 55 | } | |
| 56 | #if defined _ALS_AddStaticVehicleEx | |
| 57 | #undef AddStaticVehicleEx | |
| 58 | #else | |
| 59 | #define _ALS_AddStaticVehicleEx | |
| 60 | #endif | |
| 61 | #define AddStaticVehicleEx n_AddStaticVehicleEx | |
| 62 | ||
| 63 | stock n_CreateVehicle(modelID, Float: spawn_X, Float: spawn_Y, Float: spawn_Z, Float: z_Angle, color1, color2, respawn_Delay) | |
| 64 | {
| |
| 65 | if(color1 < 0 || color2 < 0) | |
| 66 | {
| |
| 67 | color1 = random(127); | |
| 68 | color2 = random(127); | |
| 69 | } | |
| 70 | modelID = CreateVehicle(modelID, spawn_X, spawn_Y, spawn_Z, z_Angle, color1, color2, respawn_Delay); | |
| 71 | ||
| 72 | new | |
| 73 | colorStr[24] | |
| 74 | ; | |
| 75 | format(colorStr, sizeof(colorStr), "%d-%d", color1, color2); | |
| 76 | setproperty(_, "", PROPERTY_OFFSET(modelID), colorStr); | |
| 77 | ||
| 78 | return modelID; | |
| 79 | } | |
| 80 | #if defined _ALS_CreateVehicle | |
| 81 | #undef CreateVehicle | |
| 82 | #else | |
| 83 | #define _ALS_CreateVehicle | |
| 84 | #endif | |
| 85 | #define CreateVehicle n_CreateVehicle | |
| 86 | ||
| 87 | stock n_DestroyVehicle(vehicleID) | |
| 88 | {
| |
| 89 | deleteproperty(_, "", PROPERTY_OFFSET(vehicleID)); | |
| 90 | ||
| 91 | return DestroyVehicle(vehicleID); | |
| 92 | } | |
| 93 | #if defined _ALS_DestroyVehicle | |
| 94 | #undef DestroyVehicle | |
| 95 | - | if(funcidx("n_OnVehicleRespray") != -1)
|
| 95 | + | |
| 96 | #define _ALS_DestroyVehicle | |
| 97 | - | return CallLocalFunction("n_OnVehicleRespray", "iiii", playerid, vehicleid, color1, color2);
|
| 97 | + | |
| 98 | #define DestroyVehicle n_DestroyVehicle | |
| 99 | - | return 1; |
| 99 | + | |
| 100 | stock n_ChangeVehicleColor(vehicleID, color1, color2) | |
| 101 | {
| |
| 102 | new | |
| 103 | colorStr[24] | |
| 104 | ; | |
| 105 | format(colorStr, sizeof(colorStr), "%d-%d", color1, color2); | |
| 106 | setproperty(_, "", PROPERTY_OFFSET(vehicleID), colorStr); | |
| 107 | ||
| 108 | return ChangeVehicleColor(vehicleID, color1, color2); | |
| 109 | } | |
| 110 | #if defined _ALS_ChangeVehicleColor | |
| 111 | #undef ChangeVehicleColor | |
| 112 | #else | |
| 113 | #define _ALS_ChangeVehicleColor | |
| 114 | #endif | |
| 115 | #define ChangeVehicleColor n_ChangeVehicleColor | |
| 116 | ||
| 117 | public OnVehicleRespray(playerid, vehicleid, color1, color2) | |
| 118 | {
| |
| 119 | new | |
| 120 | colorStr[24] | |
| 121 | ; | |
| 122 | format(colorStr, sizeof(colorStr), "%d-%d", color1, color2); | |
| 123 | setproperty(_, "", PROPERTY_OFFSET(vehicleid), colorStr); | |
| 124 | ||
| 125 | #if defined n_OnVehicleRespray | |
| 126 | return n_OnVehicleRespray(playerid, vehicleid, color1, color2); | |
| 127 | #else | |
| 128 | return 0; | |
| 129 | #endif | |
| 130 | } | |
| 131 | #if defined _ALS_OnVehicleRespray | |
| 132 | #undef OnVehicleRespray | |
| 133 | #else | |
| 134 | #define _ALS_OnVehicleRespray | |
| 135 | #endif | |
| 136 | #define OnVehicleRespray n_OnVehicleRespray | |
| 137 | #if defined n_OnVehicleRespray | |
| 138 | forward n_OnVehicleRespray(playerid, vehicleid, color1, color2); | |
| 139 | - | forward n_OnVehicleRespray(playerid, vehicleid, color1, color2); |
| 139 | + | |
| 140 | ||
| 141 | stock GetVehicleColor(vehicleID, &color1, &color2) | |
| 142 | {
| |
| 143 | vehicleID = PROPERTY_OFFSET(vehicleID); | |
| 144 | ||
| 145 | if(existproperty(_, "", vehicleID)) | |
| 146 | {
| |
| 147 | new | |
| 148 | colorStr[24], | |
| 149 | strPos | |
| 150 | ; | |
| 151 | getproperty(_, "", vehicleID, colorStr); | |
| 152 | strunpack(colorStr, colorStr); | |
| 153 | ||
| 154 | if((strPos = strfind(colorStr, "-")) != -1) | |
| 155 | {
| |
| 156 | color1 = strval(colorStr); | |
| 157 | color2 = strval(colorStr[strPos + 1]); | |
| 158 | return 1; | |
| 159 | } | |
| 160 | } | |
| 161 | return 0; | |
| 162 | } |