10.09.2015, 22:40
So basically in this gas pump system once I create the first pump obviously it creates it as ID 0 (ID 1 in the DB). If I then create another, it again says that it's ID 0 but creates it in the DB as ID 2. And when I try to edit the pump I am only able to edit pump ID 0 and it overwrites the original one created.
Anyone got any idea why it's happening. Lemme know if you need anything else
pawn Код:
CMD:createpump(playerid, params[]) {
new
localPumpID,
bizID = INVALID_BUSINESS_ID;
if(playerData[playerid][pAdmin] < 5)
return sendErrorMessage(playerid, "You are not authorised to use this command.");
if(sscanf(params, "i", bizID))
return sendSyntaxMessage(playerid, "/createpump [businessid]");
if((bizID < 0 || bizID >= MAX_BUSINESSES) || businessData[bizID][businessID] == INVALID_BUSINESS_ID)
return sendErrorMessage(playerid, "You specified an invalid business ID.");
if(businessData[bizID][businessType] != 7)
return sendErrorMessage(playerid, "You specified a business that is not a Gas Station.");
if(GetPlayerInterior(playerid) > 0 || GetPlayerVirtualWorld(playerid) > 0)
return sendErrorMessage(playerid, "You cannot place gas pumps inside interiors.");
localPumpID = createPump(playerid, bizID);
if(localPumpID == INVALID_PUMP_ID)
return sendErrorMessage(playerid, "You cannot create any more gas pumps for the specified business, you have reached the limit.");
sendServerMessage(playerid, "You have successfully created gas pump ID: %i, type '/editpump' to edit.", localPumpID);
return 1;
}
pawn Код:
createPump(playerID, bizID) {
static
Float: playerPos[4],
szQuery[64],
localPumpID = INVALID_PUMP_ID;
if(GetPlayerPos(playerID, playerPos[0], playerPos[1], playerPos[2])) {
if((localPumpID = getPumpFreeID()) != -1) {
GetPlayerFacingAngle(playerID, playerPos[3]);
playerPos[0] += 5.0 * floatsin(-playerPos[3], degrees);
playerPos[1] += 5.0 * floatcos(-playerPos[3], degrees);
pumpData[localPumpID][pumpBusinessID] = bizID;
pumpData[localPumpID][pumpPos][0] = playerPos[0];
pumpData[localPumpID][pumpPos][1] = playerPos[1];
pumpData[localPumpID][pumpPos][2] = playerPos[2];
pumpData[localPumpID][pumpPos][3] = playerPos[3];
pumpData[localPumpID][pumpFuel] = 2000;
pumpData[localPumpID][pumpObject] = CreateDynamicObject(1676, playerPos[0], playerPos[1], playerPos[2], 0.0, 0.0, playerPos[3]);
format(szQuery, sizeof szQuery, "INSERT INTO `pumps` (`pumpBusinessID`) VALUES(%i)", businessData[bizID][businessID]);
mysql_function_query(g_iConnectionHandle[0], szQuery, true, "onCreatePump", "i", localPumpID);
return localPumpID;
}
}
return INVALID_PUMP_ID;
}
pawn Код:
CMD:editpump(playerid, params[]) {
new
localPumpID;
if(playerData[playerid][pAdmin] < 5)
return sendErrorMessage(playerid, "You are not authorised to use this command.");
if(sscanf(params, "i", localPumpID))
return sendSyntaxMessage(playerid, "/editpump [pumpid]");
if((localPumpID < 0 || localPumpID >= MAX_GAS_PUMPS) || pumpData[localPumpID][pumpID] == INVALID_PUMP_ID)
return sendErrorMessage(playerid, "You specified an invalid pump ID.");
sendServerMessage(playerid, "You are editing pump ID %i.", localPumpID);
playerData[playerid][pEditPump] = localPumpID;
EditDynamicObject(playerid, pumpData[localPumpID][pumpObject]);
return 1;
}