Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Bob on October 20th, 2018, 01:03 PM

Title: Car Colours from Carcols.dat
Post by: Bob on October 20th, 2018, 01:03 PM
I noticed the -1 setting for car colours does not follow Carcols.dat. Some of the vehicles look bad.
For example:
https://cdn.discordapp.com/attachments/495234217987276810/500897701760860180/2018-10-14_01-05-59-0380.png

So I figured why not add them any who.

Code: [Select]
function ColourSlot(vehicle_model, iD) {
 local Generator, Colour;
 switch (vehicle_model) {

  case 130: {
  Generator = ( GetTickCount() % 7 ), Colour = [ [11,73], [18,74], [47,75], [41,76], [64,73], [52,74], [56,75], [32,76] ];
  return Colour[Generator][iD];
  }

  case 131: {
  Generator = ( GetTickCount() % 7 ), Colour = [ [62,37], [78,38], [2,62], [3,87], [2,78], [5,78], [5,62], [7,78] ];
  return Colour[Generator][iD];
  }

  case 132: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [5,5], [6,6], [10,10], [35,35], [33,33], [8,8], [2,2], [3,3] ]
  return Colour[Generator][iD];
  }

  case 133: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [13,76], [24,77], [63,78], [42,76], [54,77], [39,78], [11,76], [62,77] ];
  return Colour[Generator][iD];
  }

  case 134: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [18,1], [37,1], [55,1], [59,1], [43,1], [47,1], [66,1], [31,1] ];
  return Colour[Generator][iD];
  }

  case 135: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [30,0], [2,0], [36,0], [8,0], [10,0], [11,0], [14,0], [49,0] ];
  return Colour[Generator][iD];
  }

  case 136: {
    Generator = ( 0 ), Colour = [ [1,1] ];
  return Colour[Generator][iD];
  }

  case 137: {
    Generator = ( 0 ), Colour = [ [3,1] ];
  return Colour[Generator][iD];
  }

  case 138: {
  Generator = ( 0 ), Colour = [ [1,75] ];
  return Colour[Generator][iD];
  }

  case 139: {
  Generator = ( GetTickCount() % 3 ), Colour = [ [84,84], [1,1], [79,79], [78,78] ];
  return Colour[Generator][iD];
  }

  case 140: {
  Generator = ( GetTickCount() % 7 ), Colour = [ [58,1], [69,1], [75,77], [18,1], [32,1], [45,45], [13,1], [34,1] ];
  return Colour[Generator][iD];
  }

  case 140: {
  Generator = ( GetTickCount() % 7 ), Colour = [ [58,1], [69,1], [75,77], [18,1], [32,1], [45,45], [13,1], [34,1] ];
  return Colour[Generator][iD];
  }

  case 141: {
  Generator = ( GetTickCount() % 4 ), Colour = [ [2,2], [11,11], [12,12], [35,35], [36,36] ];
  return Colour[Generator][iD];
  }

  case 142: {
  Generator = ( 0 ), Colour = [ [13,72] ];
  return Colour[Generator][iD];
  }
  case 143: {
  Generator = ( GetTickCount() % 7 ), Colour = [ [62,62], [58,58], [62,62], [58,58], [32,32], [88,88], [1,1], [3,3] ];
  return Colour[Generator][iD];
  }
 
  case 144: {
    Generator = ( GetTickCount() % 5 ), Colour = [ [63,63], [67,67], [69,69], [91,91], [3,3], [7,7] ];
    return Colour[Generator][iD];
  }

  case 145: {
    Generator = ( GetTickCount() % 5 ), Colour = [ [25,25], [36,36], [52,52], [3,3], [53,53], [76,76] ];
    return Colour[Generator][iD];
  }

  case 146: {
    Generator = ( 0 ), Colour = [ [1,3] ];
    return Colour[Generator][iD];
  }

  case 147: {
    Generator = ( 0 ), Colour = [ [71,73] ];
    return Colour[Generator][iD];
  }
 
  case 148: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [43,43], [48,48], [54,54], [61,61], [64,64], [9,9], [13,13], [32,32] ];
    return Colour[Generator][iD];
  }

  case 149: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [45,75], [47,76], [33,75], [13,76], [54,75], [69,76], [59,75], [87,76] ];
    return Colour[Generator][iD];
  }

  case 150: {
    Generator = ( GetTickCount() % 2 ), Colour = [ [6,75], [6,73], [6,76] ];
    return Colour[Generator][iD];
  }

  case 151: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [9,9], [30,30], [36,36], [42,42], [13,13], [25,25], [54,54], [60,60] ];
    return Colour[Generator][iD];
  }

  case 152: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [5,8], [32,8], [43,8], [67,8], [11,11], [8,90], [2,2], [83,13] ];
    return Colour[Generator][iD];
  }

  case 153: {
    Generator = ( GetTickCount() % 5 ), Colour = [ [1,16], [1,56], [1,17], [1,53], [1,5], [1,35] ];
    return Colour[Generator][iD];
  }

  case 154: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [54,37], [13,1], [25,1], [38,59], [42,1], [46,1], [55,1], [2,37] ];
    return Colour[Generator][iD];
  }

  case 155: {
    Generator = ( 0 ), Colour = [ [43,0] ];
    return Colour[Generator][iD];
  }

  case 156: {
    Generator = ( 0 ), Colour = [ [46,1] ];
  return Colour[Generator][iD];
  }

  case 157: {
    Generator = ( 0 ), Colour = [ [46,1] ];
    return Colour[Generator][iD];
  }

  case 158: {
    Generator = ( 0 ), Colour = [ [4,75] ];
    return Colour[Generator][iD];
  }

  case 159: {
    Generator = ( GetTickCount() % 3 ), Colour = [ [1,1], [3,3], [36,36], [57,57] ];
    return Colour[Generator][iD];
  }

  case 160: {
    Generator = ( 0 ), Colour = [ [46,1] ];
    return Colour[Generator][iD];
  }

  case 161: {
    Generator = ( GetTickCount() % 5 ), Colour = [ [43,82], [48,82], [56,82], [58,82], [63,82], [2,82] ];
    return Colour[Generator][iD];
  }

  case 162: {
  // Tank does not exist, use green for colisions
    Generator = ( 0 ), Colour = [ [43,43] ];
    return Colour[Generator][iD];
  }

  case 163: {
  // cuban hermes does not exist, use black for colisions
    Generator = ( 0 ), Colour = [ [43,0] ];
    return Colour[Generator][iD];
  }

  case 164: {
    Generator = ( 0 ), Colour = [ [0,6] ];
    return Colour[Generator][iD];
  }

  case 166: {
    Generator = ( 0 ), Colour = [ [14,75] ];
    return Colour[Generator][iD];
  }

  case 167: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [56,75], [75,79], [13,76], [44,27], [67,77], [55,52], [21,26], [74,15] ];
    return Colour[Generator][iD];
  }

  case 168: {
    Generator = ( 0 ), Colour = [ [6,76] ];
    return Colour[Generator][iD];
  }

  case 169: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [57,8], [8,17], [43,21], [54,38], [67,8], [37,78], [65,79], [25,78] ];
    return Colour[Generator][iD];
  }

  case 170: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [78,73], [16,72], [1,75], [18,74], [88,88], [37,1], [59,59], [19,19] ];
    return Colour[Generator][iD];
  }

  case 171: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [17,27], [28,38], [38,47], [46,57], [41,27], [57,48], [67,58], [64,37] ];
    return Colour[Generator][iD];
  }

  case 172: {
    Generator = ( GetTickCount() % 4 ), Colour = [ [0,1], [70,1], [71,1], [72,1], [73,1] ];
    return Colour[Generator][iD];
  }

  case 173: {
    Generator = ( GetTickCount() % 6 ), Colour = [ [74,76], [93,77], [76,78], [15,76], [31,77], [43,78], [48,76] ];
    return Colour[Generator][iD];
  }

  case 174: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [51,0], [61,0], [41,0], [11,0], [64,0], [40,0], [38,0], [10,0] ];
    return Colour[Generator][iD];
  }

  case 175: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [37,37], [42,42], [53,53], [62,62], [7,7], [10,10], [11,11], [15,15] ];
    return Colour[Generator][iD];
  }

  case 176: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [1,3], [1,5], [1,16], [1,22], [1,35], [1,44], [1,53], [1,57] ];
    return Colour[Generator][iD];
  }

  case 177: {
    Generator = ( 0 ), Colour = [ [75,2] ];
    return Colour[Generator][iD];
  }

  case 178: {
    Generator = ( 0 ), Colour = [ [14,6] ];
    return Colour[Generator][iD];
  }

  case 179: {
    Generator = ( 0 ), Colour = [ [16,74] ];
    return Colour[Generator][iD];
  }

  case 182: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [1,3], [1,5], [1,16], [1,22], [1,35], [1,44], [1,53], [1,57] ];
    return Colour[Generator][iD];
  }

  case 183: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [57,8], [8,17], [43,21], [54,38], [67,8], [37,78], [65,79], [25,78] ];
    return Colour[Generator][iD];
  }

  case 184: {
    Generator = ( 0 ), Colour = [ [1,1] ];
    return Colour[Generator][iD];
  }

  case 185: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [84,15], [84,58], [84,31], [32,74], [43,31], [1,31], [77,31], [32,74] ];
    return Colour[Generator][iD];
  }

  case 186: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [28,72], [36,73], [48,74], [59,72], [67,73], [34,74], [13,72], [18,73] ];
    return Colour[Generator][iD];
  }

  case 187: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [58,1], [2,1], [5,1], [18,1], [32,1], [45,1], [13,1], [34,1] ];
    return Colour[Generator][iD];
  }

  case 188: {
    Generator = ( 0 ), Colour = [ [12,73] ];
    return Colour[Generator][iD];
  }

  case 189: {
    Generator = ( 0 ), Colour = [ [88,75] ];
    return Colour[Generator][iD];
  }

  case 190: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [1,3], [1,5], [1,16], [1,22], [1,35], [1,44], [1,53], [1,57] ];
    return Colour[Generator][iD];
  }

  case 191: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [13,13], [22,22], [35,35], [38,38], [2,2], [3,3], [48,48], [51,51] ];
    return Colour[Generator][iD];
  }

  case 192: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [2,37], [68,78], [11,79], [15,8], [33,37], [44,78], [56,79], [60,8] ];
    return Colour[Generator][iD];
  }

  case 193: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [79,79], [84,84], [7,7], [11,11], [19,19], [22,22], [36,36], [53,53] ];
    return Colour[Generator][iD];
  }

  case 194: {
    Generator = ( 0 ), Colour = [ [14,75] ];
    return Colour[Generator][iD];
  }

  case 195: {
    Generator = ( 0 ), Colour = [ [14,75] ];
    return Colour[Generator][iD];
  }

  case 196: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [67,76], [68,76], [78,76], [2,76], [16,76], [18,76], [25,76], [45,88] ];
    return Colour[Generator][iD];
  }

  case 197: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [51,1], [58,8], [60,1], [68,8], [2,1], [13,8], [22,1], [36,8] ];
    return Colour[Generator][iD];
  }

  case 198: {
    Generator = ( GetTickCount() % 3 ), Colour = [ [6,6], [46,46], [53,53], [3,3] ];
    return Colour[Generator][iD];
  }

  case 199: {
    Generator = ( 0 ), Colour = [ [75,2] ];
    return Colour[Generator][iD];
  }

  case 200: {
    Generator = ( 0 ), Colour = [ [43,0] ];
    return Colour[Generator][iD];
  }

  case 201: {
    Generator = ( 0 ), Colour = [ [13,13] ];
    return Colour[Generator][iD];
  }

  case 202: {
    Generator = ( GetTickCount() % 1 ), Colour = [ [1,15], [1,53] ];
    return Colour[Generator][iD];
  }

  case 203: {
    Generator = ( GetTickCount() % 1 ), Colour = [ [1,15], [1,53] ];
    return Colour[Generator][iD];
  }

  case 204: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [2,2], [16,16], [17,17], [21,21], [32,32], [38,38], [43,43], [60,60] ];
    return Colour[Generator][iD];
  }

  case 205: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [2,39], [9,39], [17,1], [21,1], [33,0], [37,0], [41,29], [56,29] ];
    return Colour[Generator][iD];
  }

  case 206: {
    Generator = ( 0 ), Colour = [ [16,16] ];
    return Colour[Generator][iD];
  }

  case 207: {
    Generator = ( GetTickCount() % 8 ), Colour = [ [1,1], [3,3], [2,2], [6,6], [79,41], [8,41], [12,76], [16,76], [23,76] ];
    return Colour[Generator][iD];
  }

  case 208: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [72,72], [93,93], [4,4], [11,11], [42,42], [51,51], [60,60], [64,64] ];
    return Colour[Generator][iD];
  }

  case 209: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [53,32], [15,32], [45,32], [34,30], [65,32], [14,32], [12,32], [43,32] ];
    return Colour[Generator][iD];
  }

  case 210: {
    Generator = ( GetTickCount() % 6 ), Colour = [ [1,1], [12,12], [2,2], [6,6], [4,4], [46,46], [53,53] ];
    return Colour[Generator][iD];
  }

  case 211: {
    Generator = ( GetTickCount() % 3 ), Colour = [ [1,1], [3,3], [6,6], [46,46] ];
    return Colour[Generator][iD];
  }

  case 212: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [41,41], [48,48], [52,52], [64,64], [71,71], [85,85], [10,10], [62,62] ];
    return Colour[Generator][iD];
  }

  case 213: {
    Generator = ( GetTickCount() % 5 ), Colour = [ [9,9], [32,32], [69,69], [73,73], [81,81], [34,34] ];
    return Colour[Generator][iD];
  }

  case 214: {
    Generator = ( GetTickCount() % 3 ), Colour = [ [12,35], [50,32], [40,26], [66,36] ];
    return Colour[Generator][iD];
  }

  case 215: {
    Generator = ( GetTickCount() % 6 ), Colour = [ [1,73], [1,74], [1,75], [1,76], [1,77], [1,78], [1,79] ];
    return Colour[Generator][iD];
  }

  case 216: {
    Generator = ( 0 ), Colour = [ [6,76] ];
    return Colour[Generator][iD];
  }

  case 217: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [1,14], [1,42], [1,57], [54,1], [1,3], [3,1], [12,39], [74,35] ];
    return Colour[Generator][iD];
  }

  case 218: {
    Generator = ( 0 ), Colour = [ [1,2] ];
    return Colour[Generator][iD];
  }

  case 219: {
    Generator = ( GetTickCount() % 5 ), Colour = [ [32,3], [32,42], [32,53], [32,66], [32,14], [32,32] ];
    return Colour[Generator][iD];
  }

  case 220: {
    Generator = ( 0 ), Colour = [ [6,6] ];
    return Colour[Generator][iD];
  }

  case 221: {
    Generator = ( GetTickCount() % 5 ), Colour = [ [40,65], [71,72], [52,66], [64,72], [30,72], [60,72] ];
    return Colour[Generator][iD];
  }

  case 222: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [78,78], [80,13], [2,78], [11,79], [16,8], [25,8], [33,78], [42,79] ];
    return Colour[Generator][iD];
  }

  case 223: {
    Generator = ( 0 ), Colour = [ [36,13] ];
    return Colour[Generator][iD];
  }

  case 224:
  case 233: {
    Generator = ( GetTickCount() % 5 ), Colour = [ [7,53], [3,40], [35,53], [40,75], [42,2], [46,6] ];
    return Colour[Generator][iD];
  }

  case 225: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [15,78], [49,78], [69,78], [45,78], [51,78], [66,78], [56,78], [12,78] ];
    return Colour[Generator][iD];
  }

  case 226: {
    Generator = ( GetTickCount() % 8 ), Colour = [ [8,1], [12,1], [16,1], [22,1], [34,1], [35,1], [41,1], [42,1], [54,1] ];
    return Colour[Generator][iD];
  }

  case 227: {
    Generator = ( 0 ), Colour = [ [46,1] ];
    return Colour[Generator][iD];
  }

  case 228: {
    Generator = ( GetTickCount() % 6 ), Colour = [ [22,77], [32,76], [46,75], [57,74], [66,74], [78,75], [1,74] ];
    return Colour[Generator][iD];
  }

  case 229: {
    Generator = ( GetTickCount() % 6 ), Colour = [ [87,54], [87,64], [8,2], [33,55], [56,69], [89,11], [33,2] ];
    return Colour[Generator][iD];
  }

  case 230: {
    Generator = ( GetTickCount() % 6 ), Colour = [ [30,65], [48,65], [64,68], [64,71], [11,73], [60,68], [74,64] ];
    return Colour[Generator][iD];
  }

  case 231: {
    Generator = ( 0 ), Colour = [ [14,75] ];
    return Colour[Generator][iD];
  }

  case 232: {
    Generator = ( GetTickCount() % 5 ), Colour = [ [2,35], [36,2], [51,53], [91,2], [11,22], [40,35] ];
    return Colour[Generator][iD];
  }

  case 234: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [51,9], [57,1], [45,9], [34,1], [65,9], [14,1], [12,9], [26,1] ];
    return Colour[Generator][iD];
  }

  case 235: {
    Generator = ( GetTickCount() % 7 ), Colour = [ [51,39], [57,38], [45,29], [34,9], [65,9], [14,1], [12,9], [26,1] ];
    return Colour[Generator][iD];
  }

  case 236: {
    Generator = ( GetTickCount() % 4 ), Colour = [ [3,3], [6,6], [7,7], [52,52], [76,76] ];
    return Colour[Generator][iD];
  }

  default: {
  // Shouldn't ever get called
    Generator = ( 0 ), Colour = [ [-1, -1] ];
  return Colour[Generator][iD];
  }
 }
}

There were a few modifications, I noticed vcmp likes to show paint during collisions for all vehicles when story mode doesn't do that for certain vehicles, For example the Sabre Turbo is actually blue in the Carcols file so the fact that vcmp loads that is a little weird so I manually changed some of the vehicles colours to match the colour of the vehicles for collisions.

Hopefully this tiny snippet will help someone with there server, maybe you want to modify colours or whatever, regardless this should help!
I used integers instead of vehicle names as squirrel has a harder time finding strings vs integers

Examples:
Code: [Select]
   
local c1 = ColourSlot(model, 0);
local c2 = ColourSlot(model, 1);
CreateVehicle( model, player.Pos, player.Angle, c1, c2 );


Code: [Select]
function onVehicleRespawn(vehicle) {
  // Set vehicles to respawn with random colour
  vehicle.Colour1 = ColourSlot(vehicle.Model, 0);
  vehicle.Colour2 = ColourSlot(vehicle.Model, 1);
}


If you find any issues with the behavior of colours in this script, or anything in general please let me know :)
Title: Re: Car Colours from Carcols.dat
Post by: Bob on November 8th, 2018, 02:09 AM
An Acknowledged Bug

The Reason why GetTicketCount works in this method and still selects the same index is because GetTicketCout reacts in 10 milliseconds to 16 milliseconds, If your using this
Code: [Select]
onVehicleRespawn
Any car with the same model will indeed have the exact colour.

A simple fix I'd suggest would be:

Code: [Select]
  local TimeDifernece = 15, Time = 30000;
  for( local i = 1; i <=GetVehicleCount(); i++ ) {
    local vehicle = FindVehicle(i);
    if (vehicle) { 
      Time = Time + TimeDifernece;
      vehicle.RespawnTimer = Time;
      // Update the Time Difference
      TimeDifernece += 15;
      // Reset the actual time
      Time = 300000;
  }
This isn't code support only an acknowledgment of vehicle colour behavior with a basic example