Why does this not save the car color
#1

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
Reply
#2

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.
Reply
#3

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
Reply
#4

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


Forum Jump:


Users browsing this thread: 2 Guest(s)