open.mp forum
[Pawn] Change Vehicle Color After Respawn - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Change Vehicle Color After Respawn (/showthread.php?tid=2803)



Change Vehicle Color After Respawn - LuvaDePedreiro - 2024-06-28

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;




RE: Change Vehicle Color After Respawn - Virsenas - 2024-07-03

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.


RE: Change Vehicle Color After Respawn - LuvaDePedreiro - 2024-07-04

(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;




RE: Change Vehicle Color After Respawn - Virsenas - 2024-07-04

(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?


RE: Change Vehicle Color After Respawn - LuvaDePedreiro - 2024-07-04

(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.


RE: Change Vehicle Color After Respawn - Virsenas - 2024-07-04

There are two things you need to check.

1)
https://www.open.mp/docs/scripting/functions/ChangeVehicleColours

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.


RE: Change Vehicle Color After Respawn - LuvaDePedreiro - 2024-07-05

(2024-07-04, 11:07 PM)Virsenas Wrote: There are two things you need to check.

1)
https://www.open.mp/docs/scripting/functions/ChangeVehicleColours

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