Good try but you've designed it insufficiently for most purposes.
1.) You should have a dynamic system
2.) If you have as much copy and paste code as you have you have to know your doing something wrong a lot of this code can be simplified.
3.) Make a function to export the pickups to file all at one time
So for the first step you need to do some basic dynamic code setup usually this involves the following at the very least apart from possibly not requiring an enum (which you do).
- enum
- variable
- create function
- remove function
pawn Код:
// Define max number of pickups
#define MAX_EDIT_PICKUPS 100
// Invalid editing pickup
#define INVALID_PEDIT_ID -1
// Enum pickup information
enum PICKUPINFO
{
PickupID,
PickupModel,
PickupType,
Float:PU_X,
Float:PU_Y,
Float:PU_Z
}
// Variable storing pickup data
new gPickupData[MAX_EDIT_PICKUPS][PICKUPINFO];
// Set default variables
public OnFilterScriptInit()
{
for(new i = 0; i < MAX_EDIT_PICKUPS; i++)
{
gPickupData[i][PickupID] = INVALID_PEDIT_ID;
}
}
// Add a new pickup
stock AddPickup(PModel, PType, Float:px, Float:py, Float:pz)
{
// Find a open slot
for(new i = 0; i < MAX_EDIT_PICKUPS; i++)
{
if(gPickupData[i][PickupID] != INVALID_PEDIT_ID) continue;
// Slot found create pickup
gPickupData[i][PickupID] = CreatePickup(PModel, PType, px, py, pz, 0);
// Store all data for editing/saving
gPickupData[i][PickupModel] = PModel;
gPickupData[i][PickupType] = PType;
gPickupData[i][PU_X] = px;
gPickupData[i][PU_Y] = py;
gPickupData[i][PU_Z] = pz;
// Return the index in which the pickup is created
return i;
}
print("Error: Tried to add too many pickups");
return INVALID_PEDIT_ID;
}
// Remove a pickup
stock RemovePickup(index)
{
if(gPickupData[index][PickupID] != INVALID_PEDIT_ID)
{
DestroyPickup(gPickupData[index][PickupID]);
gPickupData[index][PickupID] = INVALID_PEDIT_ID);
return 1;
}
print("Error: Tried to remove an invalid pickup");
return INVALID_PEDIT_ID;
}
The rest is up to you but that should set you in the right direction any kind of system like this needs a reliable underlying system to control what your manipulating effectively.