21.01.2014, 18:10
So, the color won't change eh?
why don't you just print what
vehid+PreVehicle, color1 and color2 are holding?
what's this preVehicle anyways?
you might've fucked up there...
like the id of the vehicle which'll get it's color changed ain't the one the player is inside.
So just add some printf's and see what exactly your code is doing.
You'll see where you fucked up like this, it's called debugging![Wink](images/smilies/wink.png)
just in case you don't know how to do this:
why don't you just print what
vehid+PreVehicle, color1 and color2 are holding?
what's this preVehicle anyways?
you might've fucked up there...
like the id of the vehicle which'll get it's color changed ain't the one the player is inside.
So just add some printf's and see what exactly your code is doing.
You'll see where you fucked up like this, it's called debugging
![Wink](images/smilies/wink.png)
just in case you don't know how to do this:
PHP код:
if(strcmp(cmd, "/culoaremasina", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerData[playerid][pPcarkey] == 999)
{
SendClientMessage(playerid, COLOR_GREY,"Nu ai o masina personala.");
return 1;
}
if(GetPlayerCash(playerid) < 1000)
{
SendClientMessage(playerid, COLOR_GREY," Nu ai destui bani la tine.");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendUsage(playerid,"/culoaremasina [ID culoare 1] [ID culoare 2]");
return 1;
}
new color1;
color1 = strval(tmp);
if(color1 < 0 && color1 > 126)
{
SendClientMessage(playerid, COLOR_GREY, "Id-ul culorii trebuie sa fie cuprins intre 0 si 126!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendUsage(playerid,"/culoaremasina [ID culoare 1] [ID culoare 2]");
return 1;
}
new color2;
color2 = strval(tmp);
if(color2 < 0 && color2 > 126)
{
SendClientMessage(playerid, COLOR_GREY, "ID-ul culorii trebuie sa fie cuprins intre 0 si 126!");
return 1;
}
new vehid;
if(GetPlayerVehicleID(playerid) == PlayerData[playerid][pPcarkey]+PreVehicle)
{
vehid = PlayerData[playerid][pPcarkey];
}
else { return 1; }
if(IsPlayerInVehicle(playerid, vehid+PreVehicle))
{
printf("IsInMainControlStructure with veh-ID: %d",vehid+PreVehicle);//////setp1
CarData[vehid][cColorOne] = color1;
CarData[vehid][cColorTwo] = color2;
GivePlayerCash(playerid, -1000);
GameTextForPlayer(playerid, "~w~Costul vopsiri~n~~r~-$1000", 5000, 1);
ChangeVehicleColor(vehid+PreVehicle, color1, color2);
printf("Vehicle-ID %d got it's color changed to: %d and %d",vehid+PreVehicle, color1, color2);//////step2
new query[MAX_STRING];
format(query, sizeof(query), "UPDATE cars SET ColorOne='%d' WHERE id=%d", CarData[vehid][cColorOne], vehid);
mysql_query(query);
format(query, sizeof(query), "UPDATE cars SET ColorTwo='%d' WHERE id=%d", CarData[vehid][cColorTwo], vehid);
mysql_query(query);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY,"Nu esti in masina.");
return 1;
}
}
return 1;
}