Help with command who inversate variables. REP ++ -
buburuzu19 - 15.11.2014
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.
Re: Help with command who inversate variables. REP ++ -
sammp - 15.11.2014
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>
Re: Help with command who inversate variables. REP ++ -
buburuzu19 - 15.11.2014
I make the following command to inversate the car colors.
Not to change them by command!
Re: Help with command who inversate variables. REP ++ -
sammp - 15.11.2014
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]
Re : Help with command who inversate variables. REP ++ -
S4t3K - 15.11.2014
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 ?
Re: Help with command who inversate variables. REP ++ -
sammp - 15.11.2014
And you can use strcat to switch the variables:
pawn Код:
strcat(playerVariables[playerid][pCarColour1][0], color2);
strcat(playerVariables[playerid][pCarColour1][1], color1);
Re: Help with command who inversate variables. REP ++ -
buburuzu19 - 15.11.2014
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 .
Re: Help with command who inversate variables. REP ++ -
sammp - 15.11.2014
you didn't change the variables, look at my message above yours
Re: Help with command who inversate variables. REP ++ -
buburuzu19 - 15.11.2014
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.
Re: Re : Help with command who inversate variables. REP ++ -
buburuzu19 - 15.11.2014
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]);