15.06.2012, 15:08
hey guys,
I'm having an issue with this command. It would appear that none of the variables get set correctly and occasionally it will get a vehicle plate that dosent have the random letters after it either and try and enter it into sql.
Any yeah, all the vars exist etc.
Anyone have any ideas?
I'm having an issue with this command. It would appear that none of the variables get set correctly and occasionally it will get a vehicle plate that dosent have the random letters after it either and try and enter it into sql.
pawn Код:
CMD:vcreate(playerid, params[])
{
if(playerVariables[playerid][pAdminLevel] >= 3)
{
new
Float:Pos[4],
ivModel,
ivPrice,
ivColors1,
ivColors2,
Query[256],
randomplate[100];
if(sscanf(params, "iiii", ivModel, ivPrice, ivColors1, ivColors2))
{
SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/vcreate [model id] [price] [color 1] [color 2]");
}
else
{
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
++ Total_Veh_Created;
new
cCar = CreateVehicle(ivModel, Pos[0], Pos[1], Pos[2], Pos[3], ivColors1, ivColors2, 500000);
new LetterList[22][] =
{
"A", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "T", "U", "V", "W", "X", "Y", "Z"
};
if(Total_Veh_Created > 9)
{
format(randomplate, sizeof(randomplate), "%d%d %s%s%s", cCar, random(9),LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]);
}
else if(Total_Veh_Created > 99)
{
format(randomplate, sizeof(randomplate), "%d %s%s%s", cCar,LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]);
}
else if(Total_Veh_Created < 10)
{
format(randomplate, sizeof(randomplate), "%d%d%d %s%s%s", cCar,random(9),random(9),LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]);
}
format(Query, sizeof(Query), "INSERT INTO privateveh (vModel, vColor1, vColor2, vPrice, vOwner, vPosX, vPosY, vPosZ, vPosA, vPlate, vPaintJ) VALUES (%d, %d, %d, %d, 'Unbought', %f, %f, %f, %f, %d%s, 0)",
ivModel,
ivColors1,
ivColors2,
ivPrice,
Pos[0],
Pos[1],
Pos[2],
Pos[3],
randomplate);
mysql_query(Query);
vInfo[Total_Veh_Created][vSQLID] = mysql_insert_id();
vInfo[Total_Veh_Created][vModel] = ivModel;
vInfo[Total_Veh_Created][vColor1] = ivColors1;
vInfo[Total_Veh_Created][vColor2] = ivColors2;
vInfo[Total_Veh_Created][vPrice] = ivPrice;
vInfo[Total_Veh_Created][vPosX] = Pos[0];
vInfo[Total_Veh_Created][vPosY] = Pos[1];
vInfo[Total_Veh_Created][vPosZ] = Pos[2];
vInfo[Total_Veh_Created][vPosA] = Pos[3];
strmid(vInfo[Total_Veh_Created][vOwner], "Unbought", 0, 20, 20);
vInfo[Total_Veh_Created][vPaintJ] = 0;
vInfo[Total_Veh_Created][vLocked] = 0;
vInfo[Total_Veh_Created][vDamage] = 100;
vInfo[Total_Veh_Created][vEngine] = 1000;
vInfo[Total_Veh_Created][vFaction] = 0;
vInfo[Total_Veh_Created][vJob] = 0;
vInfo[Total_Veh_Created][vDamage] = 0;
vInfo[Total_Veh_Created][vEngine] = 1000.0;
vInfo[Total_Veh_Created][vFuel] = 100;
vInfo[Total_Veh_Created][vStarted] = 0;
vInfo[Total_Veh_Created][vTrunkSlots][0] = 0;
vInfo[Total_Veh_Created][vTrunkSlots][1] = 0;
vInfo[Total_Veh_Created][vTrunkSlots][2] = 0;
vInfo[Total_Veh_Created][vTrunkSlots][3] = 0;
vInfo[Total_Veh_Created][vTrunkSlots][4] = 0;
vInfo[Total_Veh_Created][vTrunkAmmo][0] = 0;
vInfo[Total_Veh_Created][vTrunkAmmo][1] = 0;
vInfo[Total_Veh_Created][vTrunkAmmo][2] = 0;
vInfo[Total_Veh_Created][vTrunkAmmo][3] = 0;
vInfo[Total_Veh_Created][vTrunkAmmo][4] = 0;
for(new i = 0; i < MAX_VEH_MODS; ++i) vMods[Total_Veh_Created][i] = 0;
strmid(vInfo[Total_Veh_Created][vPlate], randomplate, 0, 32, 32);
SetVehicleNumberPlate(Total_Veh_Created, randomplate);
printf("Plate is: %s" , vInfo[Total_Veh_Created][vPlate]);
SavePrivVeh(Total_Veh_Created);
new iMsg[56];
format(iMsg, sizeof(iMsg), "Vehicle created: %d, Model: %s, Owner: %s, Faction: %d, Plate: %s", Total_Veh_Created, playerid, VehicleNames[vInfo[Total_Veh_Created][vModel] - 400], vInfo[Total_Veh_Created][vOwner], vInfo[Total_Veh_Created][vEngine], vInfo[Total_Veh_Created][vPlate]);
SendClientMessage(playerid, COLOR_RED, iMsg);
new admMsg[80];
format(admMsg, sizeof(admMsg), "<A> %s(%d) has created a %s. [ID: %i | Price: $%i]", pName(playerid), playerid, VehicleNames[vInfo[Total_Veh_Created][vModel] - 400], ivModel, ivPrice);
submitToAdmins(admMsg, COLOR_LIGHTRED);
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(Total_Veh_Created, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(Total_Veh_Created, 0, lights, alarm, doors, bonnet, boot, 0);
}
return 1;
}
return 1;
}
Anyone have any ideas?