Author Topic: So I'm working on a code to change vehicle color but line 8 keeps having issues.  (Read 2894 times)

Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Code: [Select]
player.Vehicle.RGBColour1 = Colour( Co, Co, Co );
That is the line, anyone see a issue in it? I'm using the line I got from Pop.

Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
Please, post on the forum instead of PMing members. Also, Co is not defined, and has no sense.

In the Colour( ) function, you pass bytes ( in our case, integers ). Which range from 0 to 255, according to RGB Format ( red,green,blue ), each of the integers representing the intensity of the colour, 255,255,255 would be white, 0,0,0 would be black, 255,0,0 red, and so on.

Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Please, post on the forum instead of PMing members. Also, Co is not defined, and has no sense.

In the Colour( ) function, you pass bytes ( in our case, integers ). Which range from 0 to 255, according to RGB Format ( red,green,blue ), each of the integers representing the intensity of the colour, 255,255,255 would be white, 0,0,0 would be black, 255,0,0 red, and so on.
I didn't PM anyone, he randomly PM'd it to me.
Anyways, so what is it that I'm missing?

Also I think I should probably stop listening to Pop considering that he doesn't ever tell me what I did wrong and he gave me that bad string.

Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
I didn't PM anyone, he randomly PM'd it to me.
Anyways, so what is it that I'm missing?

Also I think I should probably stop listening to Pop considering that he doesn't ever tell me what I did wrong and he gave me that bad string.

Co is not defined, and has no sense.

In the Colour( ) function, you pass bytes ( in our case, integers ). Which range from 0 to 255, according to RGB Format ( red,green,blue ), each of the integers representing the intensity of the colour, 255,255,255 would be white, 0,0,0 would be black, 255,0,0 red, and so on.


Example of usage:
Code: [Select]
player.Vehicle.RGBColour1 = Colour(255,255,0); // This would make the car yellow
By combining R(ed), G(reen) and B(lue), you can obtain new colours.

Please read the entire posts.

Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
I did read the entire post, I know how the RGB scale works and such.

So I should take and replace "Co" with an integer?

Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
yes, each of them.

Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
yes, each of them.
Alright, thanks.
I apologize in advance if I somehow mess this up while fixing.

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
 :( man Co mean the color.ID



Shadow.

  • Tester
  • Full Member
  • ****
  • Posts: 144
  • Karma: +16/-35
    • View Profile
:( man Co mean the color.ID

There is no such thing as color.ID. Check up the RGB Scale next time.

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
:( man Co mean the color.ID

There is no such thing as color.ID. Check up the RGB Scale next time.

Shit Man ,I Mean Like This > player.Vehicle.RGBColour1 = Colour(255 ,0 ,0 );



Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Well I managed to make it change to black and nothing more, should I use what mido_pop said and put the 255 in the first 0?

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
It depends on what color you want for the car. Using Colour(255,0,0) will turn it red.

Tell us what color are you trying to use, and maybe we can help.

Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Oh, you must have misunderstood me. I mean a command that lets you select the color, not have a set color.

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Maybe this will help. It's untested and a pretty lengthy piece of code, but it should do the trick.

Code: [Select]
function onPlayerCommand( player, command, params )
{
switch( command.tolower() )
{
case "c1":
if( player.Vehicle )
{
if( params )
{
if( NumTok( params, " " ) == 3 )
{
local red = GetTok( params, " ", 1 );
local green = GetTok( params, " ", 2 );
local blue = GetTok( params, " ", 3 );

if( IsNum( red ) && IsNum( blue ) && IsNum( red ) )
{
if( red >= 0 && red <= 255 && green >= 0 && green <= 255 && blue >= 0 && blue <= 255 )
{
player.Vehicle.RGBColour1 = Colour( red, green, blue );
}
else
{
MessagePlayer("All the colors must be between 0 and 255!", player, Colour( 255, 0, 0 ) );
}
}
else
{
MessagePlayer("All the colors must be numbers!", player, Colour( 255, 0, 0 ) );
}
}
else
{
MessagePlayer("Usage: /c1 <red> <green> <blue>", player,  Colour( 200, 200, 200 ) );
}
}
else
{
MessagePlayer("Usage: /c1 <red> <green> <blue>", player,  Colour( 200, 200, 200 ) );
}
}
else
{
MessagePlayer("You must be in a vehicle!", player, Colour( 255, 0, 0 ) );
}
break;

case "c2":
if( player.Vehicle )
{
if( params )
{
if( NumTok( params, " " ) == 3 )
{
local red = GetTok( params, " ", 1 );
local green = GetTok( params, " ", 2 );
local blue = GetTok( params, " ", 3 );

if( IsNum( red ) && IsNum( blue ) && IsNum( red ) )
{
if( red >= 0 && red <= 255 && green >= 0 && green <= 255 && blue >= 0 && blue <= 255 )
{
player.Vehicle.RGBColour2 = Colour( red, green, blue );
}
else
{
MessagePlayer("All the colors must be between 0 and 255!", player, Colour( 255, 0, 0 ) );
}
}
else
{
MessagePlayer("All the colors must be numbers!", player, Colour( 255, 0, 0 ) );
}
}
else
{
MessagePlayer("Usage: /c2 <red> <green> <blue>", player,  Colour( 200, 200, 200 ) );
}
}
else
{
MessagePlayer("Usage: /c2 <red> <green> <blue>", player,  Colour( 200, 200, 200 ) );
}
}
else
{
MessagePlayer("You must be in a vehicle!", player, Colour( 255, 0, 0 ) );
}
break;
}
}

Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
I'm about to test it. Sorry I hadn't checked here yesterday, stuff came up.

 

© Liberty Unleashed Team.