Spawning Vehicle Issues

Started by Mötley, Mar 12, 2016, 09:01 PM

Previous topic - Next topic

Mötley

So when Ever i Spawn a Vehicle the Vehicle is Greay/White. Odd This is Not normal correct?

player is in Vehicle when /v 159 is entered etc.

police car does this as well and the longer i drive after a while the vehicle turns black

Murdock

Vehicles do not change colors out of itself. You must be doing something wrong

Mötley

I have tested this a lot and built a lot to vehicle functions in the server. it is almost like they are not synced when spawned into the world. I will mark off some of the checks/functions to see if that helps. but. i don't think that is the issue.,

MaTaDeToR

#3
Well First I would like to give you an Example......
if ( cmd =="color") { local veh = player.Vehicle; if ( veh ) { ClientMessage("Your car color has been changed",player,255,255,0); veh.Color1 =1; veh.Color2 = 5;  } else ClientMessage(" you need to be inside a Vehicle",player,255,255,0);}Explanation : you have to define your particular vehicle in which you are sitting, and Vehicle.Color1-2 are functions in the Wiki.....to change Vehicle colors...
..you could get Vehicle colors from here.
You can also add it through the Class <Vehicle model="" x="" y="" z="" angle="" col1="0" col2="0 "/>Point : Can you show us the Function by which you are creating the Vehicles, if any? like Commands etc. Also make sure you aren't using any timer in the Vehicle Move event, or in command to change your! particular Vehicle color.....
P.S : Kindly reply.....

Mötley

#4
There is a timer that runs checks on your Vehicle and when you exit the vehicle it will decrease the time.

Not a lot of timers Only a Minute timer and a Seconds timer that starts on scriptload. and i use those two to run anything i need either if it is minutes or seconds. Mute etc

I may of messed up the code a little as I have been playing with it a lot(A LOT!!!!!!)
But Tested and still seems fine..
  if (cmd == "vehicle" || cmd == "v" || cmd == "spawncar" || cmd == "car") {
    if (!text) {
       MessagePlayer("Vehicle: /vehicle [130-236]", player);
       return true;
    }
   
    if (!IsNum(text)) {
       MessagePlayer("Vehicle: /vehicle [130-256]", player);
       return true;
    }
 
    local model = text.tointeger();
   
    if (model < 130 || model > 236) {
       MessagePlayer("Vehicle: /vehicle [130-236]", player);
       return true;
    }
   
    if (used_vehicle[player.ID] > 0 && Admin[player.ID] < 1) {
      MessagePlayer("You may spawn your Vehicle in"+Time(used_vehicle[player.ID])+" min", player);
      return true;   
    }
   
    if (!VehicleID(model) && Admin[player.ID] < 2) {
      MessagePlayer("You can't spawn this vehicle", player);
      return true;
    }
   
    if (player.Vehicle) {
       MessagePlayer("Must not be in a vehicle", player);
       return true;
    }
     
    if (Player_Vehicle[player.ID] > 0) {
      local vehicle = FindVehicle(Player_Vehicle[player.ID]);
      if (vehicle) {
        vehicle.Remove();
      }
     
      Player_Vehicle[player.ID];
    } 
         
local vehicle = CreateVehicle(model, player.Pos, player.Angle, -1, -1);
    if (vehicle) {
      Player_vehicle[player.ID] = vehicle.ID;
      MessagePlayer("Vehicle spawned: " + model, player);
      player.Vehicle = vehicle;
      used_vehicle[player.ID] = 30;
    }

    return true;
  }

MaTaDeToR

#5
Quote from: Mr_Motley on Mar 13, 2016, 07:35 AMThere is a timer that runs checks on your Vehicle and when you exit the vehicle it will decrease the time.

Not a lot of timers Only a Minute timer and a Seconds timer that starts on scriptload. and i use those two to run anything i need either if it is minutes or seconds. Mute etc

I may of messed up the code a little as I have been playing with it a lot(A LOT!!!!!!)
But Tested and still seems fine..
  if (cmd == "vehicle" || cmd == "v" || cmd == "spawncar" || cmd == "car") {
    if (!text) {
       MessagePlayer("Vehicle: /vehicle [130-236]", player);
       return true;
    }
   
    if (!IsNum(text)) {
       MessagePlayer("Vehicle: /vehicle [130-256]", player);
       return true;
    }
 
    local model = text.tointeger();
   
    if (model < 130 || model > 236) {
       MessagePlayer("Vehicle: /vehicle [130-236]", player);
       return true;
    }
   
    if (used_vehicle[player.ID] > 0 && Admin[player.ID] < 1) {
      MessagePlayer("You may spawn your Vehicle in"+Time(used_vehicle[player.ID])+" min", player);
      return true;   
    }
   
    if (!VehicleID(model) && Admin[player.ID] < 2) {
      MessagePlayer("You can't spawn this vehicle", player);
      return true;
    }
   
    if (player.Vehicle) {
       MessagePlayer("Must not be in a vehicle", player);
       return true;
    }
     
    if (Player_Vehicle[player.ID] > 0) {
      local vehicle = FindVehicle(Player_Vehicle[player.ID]);
      if (vehicle) {
        vehicle.Remove();
      }
     
      Player_Vehicle[player.ID];
    } 
         
local vehicle = CreateVehicle(model, player.Pos, player.Angle, -1, -1);
    if (vehicle) {
      Player_vehicle[player.ID] = vehicle.ID;
      MessagePlayer("Vehicle spawned: " + model, player);
      player.Vehicle = vehicle;
      used_vehicle[player.ID] = 30;
    }

    return true;
  }
Change this Line to local vehicle = CreateVehicle(model, player.Pos, player.Angle, -1, -1); to this local vehicle = CreateVehicle(model, player.Pos, player.Angle, 1, 1); and tell me, if it works. since -1 isn't used in VC-MP, for this kind of stuff.

MacTavish

you can use rand()%96 for random colour like player.Vehicle.Colour1 = (rand()%96);
player.Vehicle.Colour2 = (rand()%96);
here is something that you may like http://forum.vc-mp.org/?topic=409.msg2613#msg2613

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

DizzasTeR

local vehicle = CreateVehicle(model, player.Pos, player.Angle, rand() % 17, rand() % 17);

MaTaDeToR

#8
Quote from: Doom_Kill3R on Mar 13, 2016, 08:38 AMlocal vehicle = CreateVehicle(model, player.Pos, player.Angle, rand() % 17, rand() % 17);
I guess, i've been mistaken, I thought he doesn't want Random colors o.0?
EDIT : If he do want's Random Colors
if ( cmd =="createveh")
{  // Admin system if you do have......
 if ( text)
    {
   if ( IsNum(text) )
        {
         local Vehicle_Model = text.tointeger();
          if ( Vehicle_Model.tointeger() > 130 && Vehicle_Model.tointeger() < 236 )
                  {
                    if ( !player.Vehicle )
                           {
                             ClientMessage("You have Created a Vehicle with Random Colors",player,255,255,0);
                             CreateVehicle ( Vehicle_Model.tointeger(), player.World, player.Pos, player.Angle, rand() % 94,rand() % 94);
                                 }
                             else ClientMessage("You don't have to be in the Vehicle",player,255,255,0);
                             }
                     else ClientMessage("ID Should be Between 130-256",player,255,255,0);
               }
          else ClientMessage("Syntax : /" + cmd + " <130-256>",player,255,255,0);
         }
     else ClientMessage("/" + cmd + " <130-256>",player,255,255,0);
 }

rww

#9
Quote from: Kusanagi on Mar 13, 2016, 08:31 AMyou can use rand()%96 for random colour like player.Vehicle.Colour1 = (rand()%96);
player.Vehicle.Colour2 = (rand()%96);
here is something that you may like http://forum.vc-mp.org/?topic=409.msg2613#msg2613

http://wiki.vc-mp.org/wiki/Car_Colors

max 94, not 96

Quote from: Mr_Motley on Mar 13, 2016, 07:35 AMThere is a timer that runs checks on your Vehicle and when you exit the vehicle it will decrease the time.

Not a lot of timers Only a Minute timer and a Seconds timer that starts on scriptload. and i use those two to run anything i need either if it is minutes or seconds. Mute etc

I may of messed up the code a little as I have been playing with it a lot(A LOT!!!!!!)
But Tested and still seems fine..
  if (cmd == "vehicle" || cmd == "v" || cmd == "spawncar" || cmd == "car") {
    if (!text) {
       MessagePlayer("Vehicle: /vehicle [130-236]", player);
       return true;
    }
   
    if (!IsNum(text)) {
       MessagePlayer("Vehicle: /vehicle [130-256]", player);
       return true;
    }
 
    local model = text.tointeger();
   
    if (model < 130 || model > 236) {
       MessagePlayer("Vehicle: /vehicle [130-236]", player);
       return true;
    }
   
    if (used_vehicle[player.ID] > 0 && Admin[player.ID] < 1) {
      MessagePlayer("You may spawn your Vehicle in"+Time(used_vehicle[player.ID])+" min", player);
      return true;   
    }
   
    if (!VehicleID(model) && Admin[player.ID] < 2) {
      MessagePlayer("You can't spawn this vehicle", player);
      return true;
    }
   
    if (player.Vehicle) {
       MessagePlayer("Must not be in a vehicle", player);
       return true;
    }
     
    if (Player_Vehicle[player.ID] > 0) {
      local vehicle = FindVehicle(Player_Vehicle[player.ID]);
      if (vehicle) {
        vehicle.Remove();
      }
     
      Player_Vehicle[player.ID];
    } 
         
local vehicle = CreateVehicle(model, player.Pos, player.Angle, -1, -1);
    if (vehicle) {
      Player_vehicle[player.ID] = vehicle.ID;
      MessagePlayer("Vehicle spawned: " + model, player);
      player.Vehicle = vehicle;
      used_vehicle[player.ID] = 30;
    }

    return true;
  }

This isn't LU. Here you can't use -1 (random color from carcols.dat) color in CreateVehicle.
Join to Irrelevant Club Discord: https://discord.gg/MsPPZ5uV4X

MaTaDeToR

Quote from: rwwpl on Mar 13, 2016, 09:05 AM
Quote from: Kusanagi on Mar 13, 2016, 08:31 AMyou can use rand()%96 for random colour like player.Vehicle.Colour1 = (rand()%96);
player.Vehicle.Colour2 = (rand()%96);
here is something that you may like http://forum.vc-mp.org/?topic=409.msg2613#msg2613

http://wiki.vc-mp.org/wiki/Car_Colors

max 94, not 96

Quote from: Mr_Motley on Mar 13, 2016, 07:35 AMThere is a timer that runs checks on your Vehicle and when you exit the vehicle it will decrease the time.

Not a lot of timers Only a Minute timer and a Seconds timer that starts on scriptload. and i use those two to run anything i need either if it is minutes or seconds. Mute etc

I may of messed up the code a little as I have been playing with it a lot(A LOT!!!!!!)
But Tested and still seems fine..
  if (cmd == "vehicle" || cmd == "v" || cmd == "spawncar" || cmd == "car") {
    if (!text) {
       MessagePlayer("Vehicle: /vehicle [130-236]", player);
       return true;
    }
   
    if (!IsNum(text)) {
       MessagePlayer("Vehicle: /vehicle [130-256]", player);
       return true;
    }
 
    local model = text.tointeger();
   
    if (model < 130 || model > 236) {
       MessagePlayer("Vehicle: /vehicle [130-236]", player);
       return true;
    }
   
    if (used_vehicle[player.ID] > 0 && Admin[player.ID] < 1) {
      MessagePlayer("You may spawn your Vehicle in"+Time(used_vehicle[player.ID])+" min", player);
      return true;   
    }
   
    if (!VehicleID(model) && Admin[player.ID] < 2) {
      MessagePlayer("You can't spawn this vehicle", player);
      return true;
    }
   
    if (player.Vehicle) {
       MessagePlayer("Must not be in a vehicle", player);
       return true;
    }
     
    if (Player_Vehicle[player.ID] > 0) {
      local vehicle = FindVehicle(Player_Vehicle[player.ID]);
      if (vehicle) {
        vehicle.Remove();
      }
     
      Player_Vehicle[player.ID];
    } 
         
local vehicle = CreateVehicle(model, player.Pos, player.Angle, -1, -1);
    if (vehicle) {
      Player_vehicle[player.ID] = vehicle.ID;
      MessagePlayer("Vehicle spawned: " + model, player);
      player.Vehicle = vehicle;
      used_vehicle[player.ID] = 30;
    }

    return true;
  }

This isn't LU. Here you can't use -1 (random color from carcols.dat) color in CreateVehicle.
Quote from: Mr_Motley on Mar 13, 2016, 07:35 AMThere is a timer that runs checks on your Vehicle and when you exit the vehicle it will decrease the time.

Not a lot of timers Only a Minute timer and a Seconds timer that starts on scriptload. and i use those two to run anything i need either if it is minutes or seconds. Mute etc

I may of messed up the code a little as I have been playing with it a lot(A LOT!!!!!!)
But Tested and still seems fine..
  if (cmd == "vehicle" || cmd == "v" || cmd == "spawncar" || cmd == "car") {
    if (!text) {
       MessagePlayer("Vehicle: /vehicle [130-236]", player);
       return true;
    }
   
    if (!IsNum(text)) {
       MessagePlayer("Vehicle: /vehicle [130-256]", player);
       return true;
    }
 
    local model = text.tointeger();
   
    if (model < 130 || model > 236) {
       MessagePlayer("Vehicle: /vehicle [130-236]", player);
       return true;
    }
   
    if (used_vehicle[player.ID] > 0 && Admin[player.ID] < 1) {
      MessagePlayer("You may spawn your Vehicle in"+Time(used_vehicle[player.ID])+" min", player);
      return true;   
    }
   
    if (!VehicleID(model) && Admin[player.ID] < 2) {
      MessagePlayer("You can't spawn this vehicle", player);
      return true;
    }
   
    if (player.Vehicle) {
       MessagePlayer("Must not be in a vehicle", player);
       return true;
    }
     
    if (Player_Vehicle[player.ID] > 0) {
      local vehicle = FindVehicle(Player_Vehicle[player.ID]);
      if (vehicle) {
        vehicle.Remove();
      }
     
      Player_Vehicle[player.ID];
    } 
         
local vehicle = CreateVehicle(model, player.Pos, player.Angle, -1, -1);
    if (vehicle) {
      Player_vehicle[player.ID] = vehicle.ID;
      MessagePlayer("Vehicle spawned: " + model, player);
      player.Vehicle = vehicle;
      used_vehicle[player.ID] = 30;
    }

    return true;
  }
Alright as pointing rwwpl, I'd also like to say that if you want to have Random colors, so use the Famous function rand(); however, -1 doesn't work here, for :| Random colors. The Example with command has been mentioned above, but would like to tell again if you didn't notice......
if ( cmd =="createveh")
{  // Admin system if you do have......
 if ( text)
    {
   if ( IsNum(text) )
        {
         local Vehicle_Model = text.tointeger();
          if ( Vehicle_Model.tointeger() > 130 && Vehicle_Model.tointeger() < 236 )
                  {
                    if ( !player.Vehicle )
                           {
                             ClientMessage("You have Created a Vehicle with Random Colors",player,255,255,0);
                             CreateVehicle ( Vehicle_Model.tointeger(), player.World, player.Pos, player.Angle, rand() % 94,rand() % 94);
                                 }
                             else ClientMessage("You don't have to be in the Vehicle",player,255,255,0);
                             }
                     else ClientMessage("ID Should be Between 130-256",player,255,255,0);
               }
          else ClientMessage("Syntax : /" + cmd + " <130-256>",player,255,255,0);
         }
     else ClientMessage("/" + cmd + " <130-256>",player,255,255,0);
 }

Mötley

Tested and the code still works the same.
I have thought about using custom colors on spawning, I prefer to not use custom colors as when I script in Pay and sprays, The garages will have less meaning to them..

I can not seem to figure out to why this is like this. But if it is not Fixable for some reason I will keep it this way to help others in the server to want to use pay n spray,
If anyone plays it :P

MaTaDeToR

#12
Quote from: Mr_Motley on Mar 13, 2016, 12:30 PMTested and the code still works the same.
I have thought about using custom colors on spawning, I prefer to not use custom colors as when I script in Pay and sprays, The garages will have less meaning to them..

I can not seem to figure out to why this is like this. But if it is not Fixable for some reason I will keep it this way to help others in the server to want to use pay n spray,
If anyone plays it :P
Well, so you mean this isn't the case? you don't want it to be changed to many colors automatically right? but you can't also figure out how automatically your Veh is changing color, so meh! if i'm going right, you should search, for "Color1" in your whole script then if that's the case..... or not am I wrong ?

Mötley

I'm at work atm. all I want are for vehicles to spawn there default color as i expected. Is that possible? Would be very nice feature

MaTaDeToR

Quote from: Mr_Motley on Mar 13, 2016, 02:59 PMI'm at work atm. all I want are for vehicles to spawn there default color as i expected. Is that possible? Would be very nice feature
Sure,  it could be possible, so I'm right that unfortunately your veh colors are getting changed while driving them? If yes then, their could be a function inside your script, and you have to find it yourself.....