SERVER - MAX_VEHICLES exceed
#4

65535 is INVALID_VEHICLE_ID your problem is here or at least part of it

LVehicleID = AddStaticVehicleEx( sCarModel, cPos[ 0 ]+3, cPos[ 1 ], cPos[ 2 ], cPos[ 3 ], Color[ 0 ], Color[ 1 ], -1);

You need to use CreateVehicle() instead but there are some other problems your dynamic system design is terrible let me show you a simple example that will work for almost any dynamic system.

You will notice some very important design aspects.

pawn Код:
// Hearts - simple dynamic system concept

#include <a_samp>

// We'll use ZCMD
#include <zcmd>

// We always need to define how many elements a dynamic system contains
#define         MAX_HEARTS          1000

// Heart object for this dynamic system
#define         HEART_OBJECT        1240

// The drawdistance for hearts
#define         HEART_DRAW_DIST     150.0

// This is a bounds checking macro to make sure that referenced array elements are not out of bounds
#define HeartBounds(%0,%1); \
    if(%0 < 0 || %0 > MAX_HEARTS) \
    { \
        printf("Array Out Of Bounds Index: %i", %1); \
        return 0; \
    }

// We need to define an enum which is basically the structure of the values that will be saved in the dynamic system
enum HEARTINFO
{
    HeartObject,
    Float:xPos,
    Float:yPos,
    Float:zPos,
}

// Create a new variable to store the heart information
new HeartData[MAX_HEARTS][HEARTINFO];

// When any dynamic system initializes we need to set any required default values in this case it is the heartobject which
// determines if the dynamic element exists
public OnFilterScriptInit()
{
    // Loop through each element
    for(new i = 0; i < MAX_HEARTS; i++)
    {
        // This marks the element as unused
        HeartData[i][HeartObject] = INVALID_OBJECT_ID;
    }
    return 1;
}

// Destroy any created hearts
public OnFilterScriptExit()
{
    for(new i = 0; i < MAX_HEARTS; i++)
    {
        if(HeartData[i][HeartObject] != INVALID_OBJECT_ID) DestroyObject(HeartData[i][HeartObject]);
    }
    return 1;

}

// Add a new heart
stock AddHeart(Float:x, Float:y, Float:z)
{
    // Loop through hearts for a free slot
    for(new i = 0; i < MAX_HEARTS; i++)
    {
        // Slot was not free continue
        if(HeartData[i][HeartObject] != INVALID_OBJECT_ID) continue;

        // We have a free slot create the new heart element
        HeartData[i][HeartObject] = CreateObject(HEART_OBJECT, x, y, z, 0.0, 0.0, 0.0, HEART_DRAW_DIST);

        // Set any additional data
        HeartData[i][xPos] = x;
        HeartData[i][yPos] = y;
        HeartData[i][zPos] = z;
       
        // Return the id of the heart that was created
        return HeartData[i][HeartObject];
    }
    // There are too many hearts
    print("ERROR: Tried to add too many hearts");
    return INVALID_OBJECT_ID;
}

// Remove a heart
stock RemoveHeart(hid)
{
    // Check the bounds to make sure they are valid
    HeartBounds(hid, "Bounds error: RemoveHeart");
   
    // Does the heart exist?
    if(HeartData[hid][HeartObject] != INVALID_OBJECT_ID)
    {
        // Destroy heart
        DestroyObject(HeartData[hid][HeartObject]);

        // We only need to reset the heart objectid this element can now be re-used
        HeartData[hid][HeartObject] = INVALID_OBJECT_ID;
        return 1;
    }
    // Return 0 heart did not exist
    return 0;
}

// Command for adding a heart
CMD:addheart(playerid, arg[])
{
    // Get the players position
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    z += 1.0;
   
    // Adding the heart was not success
    if(AddHeart(x, y, z) == -1) return SendClientMessage(playerid, 0xFF0000FF, "There are too many hearts");

    // Successfully added!
    SendClientMessage(playerid, -1, "Added a new heart!");
    return 1;
}

// Remove heart
CMD:removeheart(playerid, arg[])
{
    // Remove was successful
    if(RemoveHeart(strval(arg))) return SendClientMessage(playerid, -1, "Heart Removed");
    // That heart does not exist!
    SendClientMessage(playerid, -1, "Heart does not exist");
    return 1;
}

// Checks if the player is near a heart
CMD:nearheart(playerid, arg[])
{
    // Count how many hearts the player is near
    new heartcount;

    // Loop throuugh hearts
    for(new i = 0; i < MAX_HEARTS; i++)
    {
        // Heart does not exist
        if(HeartData[i][HeartObject] == INVALID_OBJECT_ID) continue;

        // Player was in range of a heart increment the heart count
        if(IsPlayerInRangeOfPoint(playerid, 5.0, HeartData[i][xPos], HeartData[i][yPos], HeartData[i][zPos])) heartcount++;
    }

    // There were hearts found show the player how many
    if(heartcount)
    {
        new line[128];
        format(line, sizeof(line), "You are near %i hearts!", heartcount);
        SendClientMessage(playerid, -1, line);
    }
    else SendClientMessage(playerid, 0xFF0000FF, "You are not near any hearts!");
   
    return 1;
}
Reply


Messages In This Thread
SERVER - MAX_VEHICLES exceed - by nGen.SoNNy - 01.11.2013, 16:39
Re: SERVER - MAX_VEHICLES exceed - by Konstantinos - 01.11.2013, 16:45
Re: SERVER - MAX_VEHICLES exceed - by nGen.SoNNy - 01.11.2013, 16:50
Re: SERVER - MAX_VEHICLES exceed - by Pottus - 01.11.2013, 16:52
Re: SERVER - MAX_VEHICLES exceed - by Konstantinos - 01.11.2013, 16:53
Re: SERVER - MAX_VEHICLES exceed - by nGen.SoNNy - 01.11.2013, 16:59
Re: SERVER - MAX_VEHICLES exceed - by Pottus - 01.11.2013, 17:00
Re: SERVER - MAX_VEHICLES exceed - by nGen.SoNNy - 01.11.2013, 17:04
Re: SERVER - MAX_VEHICLES exceed - by Pottus - 01.11.2013, 17:10
Re: SERVER - MAX_VEHICLES exceed - by Djole1337 - 01.11.2013, 18:00

Forum Jump:


Users browsing this thread: 1 Guest(s)