├── .gitattributes ├── README.md ├── README-en.md ├── README-es.md └── 3dspeed.inc /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SAMP-3dspeed 2 | 3D Speedometer for SA-MP with a drag-and-drop implementation. 3 | 4 |
5 | 6 | #### Instructions 7 | 8 | - For instructions in english, [click here](README-en.md). 9 | 10 | - Para instrucciones en español, [haz click aqui](README-es.md). 11 | 12 |
13 | 14 | 15 | ## How does it look? 16 | 17 | ![](https://i.imgur.com/x7Ak5d5.png) 18 | ![](https://i.imgur.com/3Nu9jjv.png) 19 | ![](https://i.imgur.com/2mM29sd.png) 20 | ![](https://i.imgur.com/vhqG1Ky.png) 21 | ![](https://i.imgur.com/THGrFdv.png) 22 | 23 | ## TODO 24 | 25 | - Add a way for scripters to provide more player-specific customization to their users, such as colours and sizes. 26 | - ??? 27 | 28 | ## Known bugs 29 | - Unusable in vehicles too wide such as airplanes 30 | - ??? 31 | 32 | ## How to collaborate 33 | Just open a Pull Request with your code 34 | -------------------------------------------------------------------------------- /README-en.md: -------------------------------------------------------------------------------- 1 | # SAMP-3dspeed 2 | 3dspeed is a 3d speedometer for samp of simple implementation. 3 | 4 | ## Instalation 5 | 6 | To install, simply download [3dspeed.inc](3dspeed.inc) and include it in the gamemode. 7 | 8 | The speedometer will automatically appear and disappear as players enter and exit vehicles. 9 | 10 | ### Configuration 11 | The following lines must be placed above the `#include <3dspeed>` line. 12 | - `#define TDSPEED_SPANISH` if you wish the speedometer to show spanish text. 13 | - `#define TDSPEED_MPH` if you wish the speedometer to say MPH instead of KMH. 14 | - `#define TDSPEED_HIDENAME` if yoou wish the speedometer to not include the vehicle's name. 15 | 16 |
17 | 18 | ## Functions 19 | 20 | 3dspeed only implements one function 21 | 22 | #### Update3DSpeedometer(playerid, speed, fuel) 23 | 24 | Call this function when you wish to update it's contents 25 | 26 | `speed` must be an integer containing the vehicle's speed. 27 | `fuel`can be an integer containing the vehicle's fuel count. Use -1 or completely skip the parameter to hide that line. 28 | 29 | ## Callbacks 30 | 31 | 3dspeed implements no callbacks. 32 | -------------------------------------------------------------------------------- /README-es.md: -------------------------------------------------------------------------------- 1 | # SAMP-3dspeed 2 | 3dspeed es un tacometro en 3D para samp de muy simple implementación. 3 | 4 | ## Instalacion 5 | 6 | Para instalar esta libreria, simplemente descarga [3dspeed.inc](3dspeed.inc) e incluyelo en tu gamemode. 7 | 8 | El tacometro aparecera y desaparecera automaticamente cuando los jugadores entren y salgan de vehiculos. 9 | 10 | ### Configuración 11 | Las siguientes lineas se agregan arriba de la linea `#include <3dspeed>`. 12 | - `#define TDSPEED_SPANISH` si deseas que el tacometro este en español. 13 | - `#define TDSPEED_MPH` si deseas que el tacometro diga MPH en lugar de KMH. 14 | - `#define TDSPEED_HIDENAME` si deseas que el tacometro no incluya el nombre del vehiculo. 15 | 16 |
17 | 18 | ## Funciones 19 | 20 | 3dspeed solo implementa una funcion 21 | 22 | #### Update3DSpeedometer(playerid, speed, fuel) 23 | 24 | Llama a esta funcion cada vez que desees actualizar los valores en el tacometro. 25 | 26 | `speed` debe ser un numero entero que contenga la velocidad del vehiculo. 27 | `fuel` debe ser un numero entero que contenga el combustible de el vehiculo. Si pones -1 o no incluyes el parametro, esa linea no se mostrara. 28 | 29 | ## Callbacks 30 | 31 | 3dspeed no implementa callbacks. 32 | -------------------------------------------------------------------------------- /3dspeed.inc: -------------------------------------------------------------------------------- 1 | /* 2 | 3dspeed 1.0.1 3 | markski.ar | github.com/markski1 4 | Thanks to: 5 | open.mp/docs contributors 6 | SACNR 7 | */ 8 | 9 | #if defined tdspeed_included 10 | #endinput 11 | #endif 12 | 13 | #define tdspeed_included 14 | 15 | /* 16 | Configuration constants, include before this file. 17 | 18 | TDSPEED_MPH to say MPH instead of KMH 19 | TDSPEED_SPANISH to have spanish text. 20 | TDSPEED_HIDENAME to not show vehicle name. 21 | */ 22 | 23 | enum SpeedometerComponents { 24 | #if !defined TDSPEED_HIDENAME 25 | Name, 26 | #endif 27 | Status, 28 | Speed, 29 | Enabled 30 | } 31 | 32 | static tds_Player[MAX_PLAYERS][SpeedometerComponents]; 33 | 34 | /* Vehicle names array */ 35 | 36 | #if !defined TDSPEED_HIDENAME 37 | 38 | static gVehicleNames[][] = { 39 | "Landstalker", 40 | "Bravura", 41 | "Buffalo", 42 | "Linerunner", 43 | "Perenniel", 44 | "Sentinel", 45 | "Dumper", 46 | "Firetruck", 47 | "Trashmaster", 48 | "Stretch", 49 | "Manana", 50 | "Infernus", 51 | "Voodoo", 52 | "Pony", 53 | "Mule", 54 | "Cheetah", 55 | "Ambulance", 56 | "Leviathan", 57 | "Moonbeam", 58 | "Esperanto", 59 | "Taxi", 60 | "Washington", 61 | "Bobcat", 62 | "Mr Whoopee", 63 | "BF Injection", 64 | "Hunter", 65 | "Premier", 66 | "Enforcer", 67 | "Securicar", 68 | "Banshee", 69 | "Predator", 70 | "Bus", 71 | "Rhino", 72 | "Barracks", 73 | "Hotknife", 74 | "Trailer", 75 | "Previon", 76 | "Coach", 77 | "Cabbie", 78 | "Stallion", 79 | "Rumpo", 80 | "RC Bandit", 81 | "Romero", 82 | "Packer", 83 | "Monster Truck", 84 | "Admiral", 85 | "Squalo", 86 | "Seasparrow", 87 | "Pizzaboy", 88 | "Tram", 89 | "Trailer", 90 | "Turismo", 91 | "Speeder", 92 | "Reefer", 93 | "Tropic", 94 | "Flatbed", 95 | "Yankee", 96 | "Caddy", 97 | "Solair", 98 | "Berkley's RC Van", 99 | "Skimmer", 100 | "PCJ-600", 101 | "Faggio", 102 | "Freeway", 103 | "RC Baron", 104 | "RC Raider", 105 | "Glendale", 106 | "Oceanic", 107 | "Sanchez", 108 | "Sparrow", 109 | "Patriot", 110 | "Quad", 111 | "Coastguard", 112 | "Dinghy", 113 | "Hermes", 114 | "Sabre", 115 | "Rustler", 116 | "ZR-350", 117 | "Walton", 118 | "Regina", 119 | "Comet", 120 | "BMX", 121 | "Burrito", 122 | "Camper", 123 | "Marquis", 124 | "Baggage", 125 | "Dozer", 126 | "Maverick", 127 | "News Chopper", 128 | "Rancher", 129 | "FBI Rancher", 130 | "Virgo", 131 | "Greenwood", 132 | "Jetmax", 133 | "Hotring", 134 | "Sandking", 135 | "Blista Compact", 136 | "Police Maverick", 137 | "Boxville", 138 | "Benson", 139 | "Mesa", 140 | "RC Goblin", 141 | "Hotring Racer", 142 | "Hotring Racer", 143 | "Bloodring Banger", 144 | "Rancher", 145 | "Super GT", 146 | "Elegant", 147 | "Journey", 148 | "Bike", 149 | "Mountain Bike", 150 | "Beagle", 151 | "Cropdust", 152 | "Stunt Plane", 153 | "Tanker", 154 | "RoadTrain", 155 | "Nebula", 156 | "Majestic", 157 | "Buccaneer", 158 | "Shamal", 159 | "Hydra", 160 | "FCR-900", 161 | "NRG-500", 162 | "HPV1000", 163 | "Cement Truck", 164 | "Tow Truck", 165 | "Fortune", 166 | "Cadrona", 167 | "FBI Truck", 168 | "Willard", 169 | "Forklift", 170 | "Tractor", 171 | "Combine", 172 | "Feltzer", 173 | "Remington", 174 | "Slamvan", 175 | "Blade", 176 | "Freight", 177 | "Streak", 178 | "Vortex", 179 | "Vincent", 180 | "Bullet", 181 | "Clover", 182 | "Sadler", 183 | "Firetruck", 184 | "Hustler", 185 | "Intruder", 186 | "Primo", 187 | "Cargobob", 188 | "Tampa", 189 | "Sunrise", 190 | "Merit", 191 | "Utility", 192 | "Nevada", 193 | "Yosemite", 194 | "Windsor", 195 | "Monster Truck", 196 | "Monster Truck", 197 | "Uranus", 198 | "Jester", 199 | "Sultan", 200 | "Stratum", 201 | "Elegy", 202 | "Raindance", 203 | "RC Tiger", 204 | "Flash", 205 | "Tahoma", 206 | "Savanna", 207 | "Bandito", 208 | "Freight", 209 | "Trailer", 210 | "Kart", 211 | "Mower", 212 | "Duneride", 213 | "Sweeper", 214 | "Broadway", 215 | "Tornado", 216 | "AT-400", 217 | "DFT-30", 218 | "Huntley", 219 | "Stafford", 220 | "BF-400", 221 | "Newsvan", 222 | "Tug", 223 | "Trailer", 224 | "Emperor", 225 | "Wayfarer", 226 | "Euros", 227 | "Hotdog", 228 | "Club", 229 | "Trailer", 230 | "Trailer", 231 | "Andromada", 232 | "Dodo", 233 | "RC Cam", 234 | "Launch", 235 | "Police Car (LSPD)", 236 | "Police Car (SFPD)", 237 | "Police Car (LVPD)", 238 | "Police Ranger", 239 | "Picador", 240 | "S.W.A.T. Van", 241 | "Alpha", 242 | "Phoenix", 243 | "Glendale", 244 | "Sadler", 245 | "Luggage Trailer", 246 | "Luggage Trailer", 247 | "Stair Trailer", 248 | "Boxville", 249 | "Farm Plow", 250 | "Utility Trailer" 251 | }; 252 | 253 | #endif 254 | 255 | /* Functions */ 256 | 257 | stock Update3DSpeedometer(playerid, speed, fuel=-1) { 258 | if (!tds_Player[playerid][Enabled]) return 1; 259 | if (!IsPlayerInAnyVehicle(playerid)) { 260 | tdSpeedo_Toggle(playerid, 0); 261 | return 1; 262 | } else if (!IsPlayerNPC(playerid)) { 263 | new vehid = GetPlayerVehicleID(playerid); 264 | new Float:pvX, Float:pvY, Float:pvZ, Float:vhp; 265 | GetVehicleHealth(vehid, vhp); 266 | vhp = (((vhp - 250.0) / 750.0) * 100.0); 267 | new speedText[48]; 268 | new statusText[48]; 269 | if (fuel > -1) { 270 | #if !defined TDSPEED_SPANISH 271 | format(statusText, 48, "Fuel: %i%%, Health: %3.0f%%", fuel, vhp); 272 | #else 273 | format(statusText, 48, "Combustible: %i%%, Vida: %3.0f%%", fuel, vhp); 274 | #endif 275 | } else { 276 | #if !defined TDSPEED_SPANISH 277 | format(statusText, 48, "Health: %3.0f%%", vhp); 278 | #else 279 | format(statusText, 48, "Vida: %3.0f%%", vhp); 280 | #endif 281 | } 282 | #if !defined TDSPEED_MPH 283 | format(speedText, 48, "%i KMH", speed); 284 | #else 285 | format(speedText, 48, "%i MPH", speed); 286 | #endif 287 | #if !defined TDSPEED_HIDENAME 288 | new modelid = GetVehicleModel(vehid); 289 | SetDynamicObjectMaterialText(tds_Player[playerid][Name], 0, gVehicleNames[modelid-400], OBJECT_MATERIAL_SIZE_512x256, "Arial", 30, true, 0xFFFFFFFF, 0, OBJECT_MATERIAL_TEXT_ALIGN_RIGHT); 290 | #endif 291 | SetDynamicObjectMaterialText(tds_Player[playerid][Status], 0, statusText, OBJECT_MATERIAL_SIZE_512x256, "Arial", 30, false, 0xFFFFFFFF, 0, OBJECT_MATERIAL_TEXT_ALIGN_RIGHT); 292 | SetDynamicObjectMaterialText(tds_Player[playerid][Speed], 0, speedText, OBJECT_MATERIAL_SIZE_512x256, "Arial", 30, false, 0xFFFFFFFF, 0, OBJECT_MATERIAL_TEXT_ALIGN_RIGHT); 293 | } 294 | return 1; 295 | } 296 | 297 | static tdSpeedo_Toggle(playerid, activate) { 298 | if (activate) { 299 | if (tds_Player[playerid][Enabled]) { 300 | return 1; 301 | } 302 | new vid = GetPlayerVehicleID(playerid); 303 | new vmod = GetVehicleModel(vid); 304 | #if !defined TDSPEED_HIDENAME 305 | tds_Player[playerid][Name] = CreateDynamicObject(19482, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, playerid, 200.0); 306 | #endif 307 | tds_Player[playerid][Status] = CreateDynamicObject(19482, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, playerid, 200.0); 308 | tds_Player[playerid][Speed] = CreateDynamicObject(19482, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1, -1, playerid, 200.0); 309 | new Float:vX,Float:vY,Float:vZ; 310 | GetVehicleModelInfo(vmod, VEHICLE_MODEL_INFO_SIZE, vX, vY, vZ); 311 | if (vX < 1.5) { 312 | vX = 1.5; 313 | } 314 | #if !defined TDSPEED_HIDENAME 315 | AttachDynamicObjectToVehicle(tds_Player[playerid][Name], vid, -vX-1.75, -1.0, 0.0, 0.0, 0.0, 290.0); 316 | #endif 317 | AttachDynamicObjectToVehicle(tds_Player[playerid][Status], vid, -vX-1.75, -1.0, -0.3, 0.0, 0.0, 290.0); 318 | AttachDynamicObjectToVehicle(tds_Player[playerid][Speed], vid, -vX-1.75, -1.0, -0.6, 0.0, 0.0, 290.0); 319 | Streamer_Update(playerid); 320 | tds_Player[playerid][Enabled] = 1; 321 | } else { 322 | if (tds_Player[playerid][Status] != INVALID_OBJECT_ID) { 323 | #if !defined TDSPEED_HIDENAME 324 | DestroyDynamicObject(tds_Player[playerid][Name]); 325 | tds_Player[playerid][Name] = INVALID_OBJECT_ID; 326 | #endif 327 | DestroyDynamicObject(tds_Player[playerid][Status]); 328 | tds_Player[playerid][Status] = INVALID_OBJECT_ID; 329 | DestroyDynamicObject(tds_Player[playerid][Speed]); 330 | tds_Player[playerid][Speed] = INVALID_OBJECT_ID; 331 | } 332 | tds_Player[playerid][Enabled] = 0; 333 | } 334 | return 1; 335 | } 336 | 337 | 338 | /* 339 | Hooks 340 | */ 341 | 342 | public OnPlayerConnect(playerid) { 343 | for (new i = 0; i < _:SpeedometerComponents-1; i++) { 344 | tds_Player[playerid][SpeedometerComponents:i] = INVALID_OBJECT_ID; 345 | } 346 | tds_Player[playerid][Enabled] = 0; 347 | 348 | #if defined tf_OnPlayerConnect 349 | return tds_OnPlayerConnect(playerid); 350 | #endif 351 | } 352 | 353 | 354 | public OnPlayerDisconnect(playerid, reason) { 355 | if(tds_Player[playerid][Status] != INVALID_OBJECT_ID) { 356 | #if !defined TDSPEED_HIDENAME 357 | DestroyDynamicObject(tds_Player[playerid][Name]); 358 | #endif 359 | DestroyDynamicObject(tds_Player[playerid][Status]); 360 | DestroyDynamicObject(tds_Player[playerid][Speed]); 361 | } 362 | 363 | #if defined tf_OnPlayerDisconnect 364 | return tds_OnPlayerDisconnect(playerid); 365 | #endif 366 | } 367 | 368 | public OnPlayerStateChange(playerid, newstate, oldstate) { 369 | if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER) { 370 | tdSpeedo_Toggle(playerid, 1); 371 | } else { 372 | tdSpeedo_Toggle(playerid, 0); 373 | } 374 | 375 | #if defined tf_OnPlayerStateChange 376 | return tds_OnPlayerStateChange(playerid); 377 | #endif 378 | } 379 | 380 | #if defined _ALS_OnPlayerConnect 381 | #undef OnPlayerConnect 382 | #else 383 | #define _ALS_OnPlayerConnect 384 | #endif 385 | 386 | #define OnPlayerConnect tds_OnPlayerConnect 387 | 388 | #if defined tds_OnPlayerConnect 389 | forward tds_OnPlayerConnect(); 390 | #endif 391 | 392 | #if defined _ALS_OnPlayerDisconnect 393 | #undef OnPlayerDisconnect 394 | #else 395 | #define _ALS_OnPlayerDisconnect 396 | #endif 397 | 398 | #define OnPlayerDisconnect tds_OnPlayerDisconnect 399 | 400 | #if defined tds_OnPlayerDisconnect 401 | forward tds_OnPlayerDisconnect(); 402 | #endif 403 | 404 | #if defined _ALS_OnPlayerStateChange 405 | #undef OnPlayerStateChange 406 | #else 407 | #define _ALS_OnPlayerStateChange 408 | #endif 409 | 410 | #define OnPlayerStateChange tds_OnPlayerStateChange 411 | 412 | #if defined tds_OnPlayerStateChange 413 | forward tds_OnPlayerStateChange(); 414 | #endif 415 | --------------------------------------------------------------------------------