• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Change Vehicle Color After Respawn
#1
Question 
Hello everybody! I have a question about a possible problem I am facing. I added some vehicles using the "AddStaticVehicleEx" function with a respawn delay of 300 seconds, and with colors already defined. Is it possible to make the colors change after it respawns? The way I'm trying to make this work is to use the "OnVehicleSpawn" callback with the "ChangeVehicleColor" function. However, after the vehicle is respawned, the color remains the same.

PHP Code:
public OnVehicleSpawn(vehicleid)
{
ChangeVehicleColor(vehicleidrandom(127), random(127));
return 
1;

RECEBA! É O CARA DA LUVA DE PEDREIRO!
GRAÇAS A DEUS PAI! O MELHOR DO MUNDO!

[Image: giphy.gif]
  Reply
#2
I'm pretty sure the word static in AddStaticVehicle means that after respawn it will remain the same as it was created and will not change.

Try the same procedure with a non-static vehicle and see if it works. If it does, then you will get your answer for your question. But I think by now you should have figured it out.
  Reply
#3
(2024-07-03, 05:00 PM)Virsenas Wrote: I'm pretty sure the word static in AddStaticVehicle means that after respawn it will remain the same as it was created and will not change.

Try the same procedure with a non-static vehicle and see if it works. If it does, then you will get your answer for your question. But I think by now you should have figured it out.

Thanks for the answer. I changed the "AddStaticVehicleEx" function to "CreateVehicle" function. But I still have the same result. Is there another function to create a vehicle? Or am I doing something wrong?

PHP Code:
public OnGameModeInit()
{
CreateVehicle(4801716.5469971432.69628910.3687880.27774710013300);
return 
1;

  Reply
#4
(2024-07-04, 11:35 AM)LuvaDePedreiro Wrote:
(2024-07-03, 05:00 PM)Virsenas Wrote: I'm pretty sure the word static in AddStaticVehicle means that after respawn it will remain the same as it was created and will not change.

Try the same procedure with a non-static vehicle and see if it works. If it does, then you will get your answer for your question. But I think by now you should have figured it out.

Thanks for the answer. I changed the "AddStaticVehicleEx" function to "CreateVehicle" function. But I still have the same result. Is there another function to create a vehicle? Or am I doing something wrong?

PHP Code:
public OnGameModeInit()
{
CreateVehicle(4801716.5469971432.69628910.3687880.27774710013300);
return 
1;


Is this an empty gamemode or is it a fully built one which has other functionality that might conflict with your code?
  Reply
#5
(2024-07-04, 02:22 PM)Virsenas Wrote:
(2024-07-04, 11:35 AM)LuvaDePedreiro Wrote:
(2024-07-03, 05:00 PM)Virsenas Wrote: I'm pretty sure the word static in AddStaticVehicle means that after respawn it will remain the same as it was created and will not change.

Try the same procedure with a non-static vehicle and see if it works. If it does, then you will get your answer for your question. But I think by now you should have figured it out.

Thanks for the answer. I changed the "AddStaticVehicleEx" function to "CreateVehicle" function. But I still have the same result. Is there another function to create a vehicle? Or am I doing something wrong?

PHP Code:
public OnGameModeInit()
{
CreateVehicle(4801716.5469971432.69628910.3687880.27774710013300);
return 
1;


Is this an empty gamemode or is it a fully built one which has other functionality that might conflict with your code?

Just empty, I'm testing this method that I wanted to work before putting it into a fully built mode. I don't know why it doesn't work.
  Reply
#6
There are two things you need to check.

1)
https://www.open.mp/docs/scripting/funct...cleColours

Go read the warning of the function and check your omp version.

2)
If the version is fine, then just change the model of the car, try something other than 480 and see if the color still does not change.

If neither of these things get to your answer, then I don't really have any more suggestions.
  Reply
#7
Wink 
(2024-07-04, 11:07 PM)Virsenas Wrote: There are two things you need to check.

1)
https://www.open.mp/docs/scripting/funct...cleColours

Go read the warning of the function and check your omp version.

2)
If the version is fine, then just change the model of the car, try something other than 480 and see if the color still does not change.

If neither of these things get to your answer, then I don't really have any more suggestions.

I don't think there's much that can be done, I've already tested every possible way. I'll have to add another way for this, since this one isn't working.

Thanks again dude. +rep
  Reply


Forum Jump: