Car color hack
#1

Hello!

I have a RP Server with my own Gamemode.
From Yesterday I'm having some problems with someone who enters server when nobody's in an change the vehicle colors of the vehicle server.

How I can prevent this?

Thanks!
Reply
#2

you can make it server sided,

If I were you, I would store vehicle colors into variables
like when you would spray you vehicle, this would happen (vInfo[vehicleid][vColor] = "Black" or vInfo[vehicleid][vColor] = "RED")

then run a repetivive timer, and loop thought every vehicle,
PHP код:
for(new i;i<MAX_VEHICES;i++){
       if(!
strcmp(vInfo[vehicleid][vColor], "Black"true)){
              
ChangeVehicleColor(i00);
       }
       
//etc..

Reply
#3

So, you're telling him to loop through 2000 vehicles? Surely that's bad coding practice?
Reply
#4

Why store color name instead of its id?
Reply
#5

Surely something like this would suffice;
Код:
new color_name[][] = {
{"Black"}
};
new color_id[][] = {
{0}
};
Obviously there'd be a better way to do that but I couldn't think of it.

Or use OnVehicleRespray and just make some checks to see if the player actually changed the vehicle colour.
Reply
#6

If you have a timer for vehicle fuel (which I'm sure you do), then just set the vehicle color to their saved vehicle color in that timer.

If you don't have file saving for your vehicles, then you need to get it now before it's too late.
Reply
#7

Thanks to all, I'll try the Aerotactics solution, sure I'm using a timer for fuel and I'm storing all the data in MySQL. The problem is, that the person who is changing the colors also changes de color in the database. I'm not at house in this moment but when I arrive I'll post the code for the saved color on vehicles because I have the mech work so I need to change the color of cars sometimes..

Thanks!
Reply
#8

The best I can think of right now is to store the server-side colors in a vehicle variable (vColor1, vColor2 for example) and what you could do then is perform a check every so often to see if the server-side colors match up with the variables, if not then change it back to the variables.
Reply
#9

The variables are:
Код:
Vehicle[MAX_VEHICLES][Color1];
Vehicle[MAX_VEHICLES][Color2];
The function that saves the data in MySQL:
Код:
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	Vehicle[VehicleIDX(vehicleid)][Color1] = color1;
	Vehicle[VehicleIDX(vehicleid)][Color2] = color2;
	mysql_format(dbHandle, query, sizeof(query), "UPDATE `Vehicles` SET `color1` = %i, `color2` = %i WHERE ID = '%d'", color1, color2, Vehicle[VehicleIDX(vehicleid)][ID]);
	mysql_tquery(dbHandle, query);
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)