Help with command who inversate variables. REP ++
#1

pawn Код:
CMD:inversatecarcolors(playerid, params[])
{
    new saveQuery[600];
    new color1,color2;
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(vehicleid == playerVariables[playerid][pCarID1])
        {
            format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarColour1 = '%d', playerCarColour2 = '%d' WHERE playerID = '%d'",playerVariables[playerid][pCarColour1][1], playerVariables[playerid][pCarColour1][0], playerVariables[playerid][pInternalID]);
            mysql_tquery(handle,saveQuery);
            ChangeVehicleColor(vehicleid, playerVariables[playerid][pCarColour1][1],playerVariables[playerid][pCarColour1][0]);
        }
    }
    return 1;
}
I make the following command to inversate the car colors.
Ex: On player enter his vehicle shows up a message: Vehicle:Infernus Colors: 122 ,2 . When he types /inversatecarcolors the car colours are chaning correctly but the message at on player enter vehicle isn't changing because i didn't set the ingame variables.
Ingame variables are:
pawn Код:
playerVariables[playerid][pCarColour1][0] -> COLOR 1 of THE CAR
playerVariables[playerid][pCarColour1][1] -> COLOR 2 of THE CAR
As you can see in my format i swapped the colors but to make the text updating i need to update the ingame variables to show correctly the colors and i don't know how because i need to swap them too and i don't have any ideea how.
Reply
#2

sscanf is your friend.

You can use it to set the variables:

pawn Код:
if(sscanf(params, "dd", colour1, colour2)) return SendClientMessage(playerid, -1, "Usage: /commandname <colour1> <colour2>
Reply
#3

I make the following command to inversate the car colors.
Not to change them by command!
Reply
#4

If you want to inversate the car colours,just set colour 1 as playerVariables[playerid][pCarColour1][1]

And set colour 2 t playerVariables[playerid][pCarColour1][0]
Reply
#5

If I understood good, the problem is that your message doesn't display what it should, doesn't it ?

If so, then may we see the code for your message ?
Reply
#6

And you can use strcat to switch the variables:

pawn Код:
strcat(playerVariables[playerid][pCarColour1][0], color2);
strcat(playerVariables[playerid][pCarColour1][1], color1);
Reply
#7

Quote:
Originally Posted by sammp
Посмотреть сообщение
If you want to inversate the car colours,just set colour 1 as playerVariables[playerid][pCarColour1][1]

And set colour 2 t playerVariables[playerid][pCarColour1][0]
AS you can SEE at my command I INVERSATED THEM , but the text isn't changing at on player enter vehicle, cuz i didn't inversate the ingame variables too,just the mysql query.
Eg: I have vehicle with colors 122,2. I type the command. The colors are changed. I re-enter vehicle , the text who comes up is Vehicle:Infernus Colors: 122 ,2 , and the text should be Vehicle:Infernus Colors: 2,122 .
Reply
#8

you didn't change the variables, look at my message above yours
Reply
#9

Quote:
Originally Posted by sammp
Посмотреть сообщение
you didn't change the variables, look at my message above yours
pawn Код:
format(saveQuery, sizeof(saveQuery), "UPDATE playeraccounts SET playerCarColour1 = '%d', playerCarColour2 = '%d' WHERE playerID = '%d'",playerVariables[playerid][pCarColour1][1], playerVariables[playerid][pCarColour1][0], playerVariables[playerid][pInternalID]);
I updated only the mysq database by format , btw i need the variables to be inversed too. I can't use color1,color2.
Reply
#10

Quote:
Originally Posted by S4t3K
Посмотреть сообщение
If I understood good, the problem is that your message doesn't display what it should, doesn't it ?

If so, then may we see the code for your message ?
Exactly.
Here:
pawn Код:
format(szMessage, sizeof(szMessage), "Colors: %d,%d",  playerVariables[x][pCarColour1][0], playerVariables[x][pCarColour1][1]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)