Car Colors
#1

Ok so i followed this person instruction(https://sampforum.blast.hk/showthread.php?tid=499817) and made a car color system but i have a issue, each time i respawn the cars it wont set it to the team color but when the server restarts it will set to the color i set it to but when i /respawnallcars it sets to the default color ...

Код:
CMD:respawncars(playerid,params[])
{
	if(IsPlayerAdmin(playerid) || pInfo[playerid][Admin] >= 1)
	{
       	SendClientMessageToAll(-1,"{F81414}[WARNING]:{FFFFFF} All unoccupied vehicles will be automatically respawned in {F81414}10 seconds.");
	   	SetTimer("crs",10000,false);
		CommandToAdmins(playerid,"respawncars");
	}
	else return ShowMessage(playerid, error, 1);
	return 1;
}
forward crs(carid);
public crs()
{

	for(new i=0; i<MAX_VEHICLES; i++)
	{
		if(UnoccupiedVehicle(i))
		{
			SetVehicleToRespawn(i);
		}
	}
	SendClientMessageToAll(-1,"{F81414}[RESPAWNED]: {FFFFFF}All unoccupied vehicles have been successfully respawned.");
}
Reply
#2

Don't use -1 for the colors for the cars.

If you set them via AddStaticVehicle then you won't need to set their colors in the first place by that silly function.

You could use something like

PHP код:
#define GroveCarColor 128 
then in the AddStaticVehicle use

PHP код:
AddStaticVehicle(model,x,y,z,r,GroveCarColorGroveCarColor); 
Reply
#3

I don't think "-1" with vehicle color causes this i have the same problem but it only happens to my admin spawn vehicles.

What you could do:

PHP код:
#include <GetVehicleColor>
new c1,c2;

public 
OnVehicleSpawn(..)
GetVehicleColor(vehicleidc1c2);

public 
OnVehicleStreamIn(...)
ChangeVehicleColor(vehicleid,c1,c2); 
https://sampforum.blast.hk/showthread.php?tid=235398
Reply
#4

Quote:
Originally Posted by ISmokezU
Посмотреть сообщение
I don't think "-1" with vehicle color causes this i have the same problem but it only happens to my admin spawn vehicles.
If you use -1 it's a random color...

Respawning the vehicle will not reset the color set to them in the for loop unless you run the loop again, instead it will make a new color each time it respawns.


Stop posting to try and 1-up on me, because the fact is that his code has -1, where it could EASILY simply have 128 in it... No need to make a variable, or a define... It just needs to have the function used correctly rather than having extra shit in the script that's unneeded.


We don't need GetVehicleColor... It's a spawn vehicle, for one team... It simply needs the color that it should have, on it's respawn.

I really hope no-one else has followed the suggestion in the thread that has led to this script issue, and I really hope no-one even gave the guy rep, as it's a really crappy way of making the colors for cars where there is a function for that in the AddStaticVehicle.
Reply
#5

Fixed rep+
Reply
#6

Good to see you've spotted it.

You should remove anything from that color setting loop if you've done what I put up. You shouldn't need it anymore.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)