Liberty Unleashed

Scripting => Script Help => Topic started by: Peavy on June 08, 2013, 10:52:44 pm

Title: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Peavy on June 08, 2013, 10:52:44 pm
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.
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Shadow. on June 08, 2013, 11:06:23 pm
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.
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Peavy on June 08, 2013, 11:08:56 pm
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.
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Shadow. on June 08, 2013, 11:27:03 pm
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.
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Peavy on June 08, 2013, 11:31:23 pm
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?
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Shadow. on June 09, 2013, 12:07:56 am
yes, each of them.
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Peavy on June 09, 2013, 12:20:18 am
yes, each of them.
Alright, thanks.
I apologize in advance if I somehow mess this up while fixing.
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Mido_Pop on June 09, 2013, 01:08:15 pm
 :( man Co mean the color.ID
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Shadow. on June 09, 2013, 03:26:09 pm
:( man Co mean the color.ID

There is no such thing as color.ID. Check up the RGB Scale next time.
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Mido_Pop on June 09, 2013, 04:06:50 pm
:( 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 );
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Peavy on June 12, 2013, 04:40:32 pm
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?
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Vortrex on June 12, 2013, 07:16:01 pm
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.
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Peavy on June 12, 2013, 10:52:51 pm
Oh, you must have misunderstood me. I mean a command that lets you select the color, not have a set color.
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Vortrex on June 13, 2013, 04:46:40 pm
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;
}
}
Title: Re: So I'm working on a code to change vehicle color but line 8 keeps having issues.
Post by: Peavy on June 14, 2013, 03:28:05 am
I'm about to test it. Sorry I hadn't checked here yesterday, stuff came up.