Why does this not save the car color - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Why does this not save the car color (
/showthread.php?tid=356209)
Why does this not save the car color -
Euan Hughes - 02.07.2012
Hey so i am trying to color my car in game and when i do it the color of my car changes but when i log out and log back in it changes back to the color it was..
pawn Код:
command(ocarcolour, playerid, params[])
{
new col1, col2, vehslot;
if(sscanf(params, "ddd", col1, col2, vehslot))
{
SendClientMessage(playerid, WHITE, "SYNTAX: /ocarcolor [colour1] [colour2] [1-5]");
}
else
{
switch(vehslot)
{
case 1:
{
if(col1 >= 0 && col1 < 300 || col2 >= 0 && col2 < 300)
{
if(Player[playerid][PlayerCarModel] > 0)
{
if(Player[playerid][HasSprayCans] >= 1 || Player[playerid][VipRank] >= 2)
{
ChangeVehicleColor(Player[playerid][CarLinkID], col1, col2);
Player[playerid][CarCol1] = col1;
Player[playerid][CarCol2] = col2;
if(Player[playerid][VipRank] < 2)
{
Player[playerid][HasSprayCans]--;
}
}
else
{
SendClientMessage(playerid, WHITE, "You have no spraycans left.");
}
}
}
else
{
SendClientMessage(playerid, WHITE, "Invalid colour, colours are from 0-300.");
}
}
}
}
}
If you need any more code just ask
Thanks
Re: Why does this not save the car color -
Universal - 02.07.2012
Have you noticed that you are assigning the car colors into the player's enum?
pawn Код:
Player[playerid][CarCol1] = col1;
Player[playerid][CarCol2] = col2;
Also, change the if statement into this:
pawn Код:
if( (col1 >= 0 && col1 < 300) && (col2 >= 0 && col2 < 300) )
Because, the current one will only check if one of the colors is correct, but not both of them. So you can enter one valid color and another invalid.
Re: Why does this not save the car color -
Euan Hughes - 02.07.2012
Quote:
Originally Posted by Universal
Have you noticed that you are assigning the car colors into the player's enum?
pawn Код:
Player[playerid][CarCol1] = col1; Player[playerid][CarCol2] = col2;
|
Is this bad ?
When i tried it on my own car it worked but when someone else tried it it did not work
Re: Why does this not save the car color -
Universal - 02.07.2012
Quote:
Originally Posted by Euan Hughes
Is this bad ?
When i tried it on my own car it worked but when someone else tried it it did not work
|
Its not bad (I guess), its just Im used that vehicle info is stored into vehicle's enum. Anyway, do you save those variables upon disconnect? If so, please show the code where you save the colors.