Ship Problem error
#1

heyc an anyone help me make it so the ship stop at route to for 1 minute and send amessage to all

and also anyone help me fix this error:
pawn Код:
error 018: initialization data exceeds declared size
Code:
pawn Код:
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*\
    ||                                                                                            ||
    ||                                              Created 8th April 2012 By Faisal Khan (faisal3325@gmail.com).                                 ||
    ||              WARNING: Do NOT Claim This As Your Own. Do NOT Re-Release This Without Permission.    ||
    ||                                                              DO NOT SELL THIS SCRIPT!                                                                  ||
    ||                                        Credits: Faisal_khan, Kye and Ahemad_khan                                                ||
    \*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


    //=================================INCLUDES=================================//
    #include <a_samp>
    //=================================DEFINES==================================//
    #define FILTERSCRIPT
    #define NUM_SHIP_ROUTE_POINTS   25
    #define SHIP_MOVE_SPEED         30.0
    #define SHIP_DRAW_DISTANCE      300.0
    #define NUM_SHIP_ATTACHMENTS    10
    #define SHIP_HULL_ID            9585
    //--------------------------------------------------------------------------//
    new gShipsAttachments[NUM_SHIP_ROUTE_POINTS];
    new gMainShipObjectId;
    new gShipCurrentPoint = 1;
    new Float:gShipHullOrigin[3] =
    { -2409.8438, 1544.9453, 7.0000 }; // so we can convert world space to model space for attachment positions

    new gShipAttachmentModelIds[NUM_SHIP_ATTACHMENTS] = {
    9586, // Ship main platform
    9761, // Ship rails
    9584, // Bridge exterior
    9698, // Bridge interior
    9821, // Bridge interior doors
    9818, // Bridge radio desk
    9819, // Captain's desk
    9822, // Captain's seat
    9820, // Bridge ducts and lights
    9590  // Cargo bay area
    };

    new Float:gShipAttachmentPos[NUM_SHIP_ATTACHMENTS][3] = {
    // these are world space positions used on the original cargo ship in the game
    // they will be converted to model space before attaching
    {-2412.1250, 1544.9453, 17.0469},
    {-2411.3906, 1544.9453, 27.0781},
    {-2485.0781, 1544.9453, 26.1953},
    {-2473.5859, 1543.7734, 29.0781},
    {-2474.3594, 1547.2422, 24.7500},
    {-2470.2656, 1544.9609, 33.8672},
    {-2470.4531, 1551.1172, 33.1406},
    {-2470.9375, 1550.7500, 32.9063},
    {-2474.6250, 1545.0859, 33.0625},
    {-2403.5078, 1544.9453, 8.7188}
    };
    //This is our ship route points you can modify this as to your wish
    new Float:gShipRoutePoints[NUM_SHIP_ROUTE_POINTS][2] = {
    {2616.2410, 486.0572, -0.2505,   259.1930, 92, 108},/*route 1 <----->This is the error line*/
    {2767.4495, 445.9613, -0.2555,   260.4986, 92, 108}// route 2
    };

    //==================================FORWARDS============================================//
    forward StartMovingTimer();
    //=======================================================================================//
    public OnFilterScriptInit()
    {
            print("\n--------------------------------");
            print("Moving Ship By Faisal_khan");
            print("--------------------------------\n");

            gMainShipObjectId = CreateObject(SHIP_HULL_ID, gShipRoutePoints[0][0], gShipRoutePoints[0][1], gShipRoutePoints[0][1],
                                                                            gShipRoutePoints[0][1], gShipRoutePoints[0][1], gShipRoutePoints[0][1], SHIP_DRAW_DISTANCE);

            new x=0;
            while(x != NUM_SHIP_ATTACHMENTS) {
                gShipsAttachments[x] = CreateObject(gShipAttachmentModelIds[x], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SHIP_DRAW_DISTANCE);
                    AttachObjectToObject(gShipsAttachments[x], gMainShipObjectId,
                                            gShipAttachmentPos[x][0] - gShipHullOrigin[0],
                                            gShipAttachmentPos[x][1] - gShipHullOrigin[1],
                                            gShipAttachmentPos[x][1] - gShipHullOrigin[1],
                                            0.0, 0.0, 0.0);
                    x++;
            }
            SetTimer("StartMovingTimer",50*1000,0); // pause at route 0 for 50 seconds
              SendClientMessageToAll(0xDEEE20FF, "Ferry Has Docked At Bishop Tree Ferry Port");
            return 1;
    }

    public StartMovingTimer()
    {
            MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
                                       gShipRoutePoints[gShipCurrentPoint][1],
                                                               gShipRoutePoints[gShipCurrentPoint][1],
                                                               SHIP_MOVE_SPEED / 3.0,
                                                               gShipRoutePoints[gShipCurrentPoint][1],
                                                               gShipRoutePoints[gShipCurrentPoint][1],
                                                               gShipRoutePoints[gShipCurrentPoint][1]);
    }

    public OnObjectMoved(objectid)
    {
            if(objectid != gMainShipObjectId) return 0;

            if(gShipCurrentPoint > 0 && !(gShipCurrentPoint % 1)) {
                // play some seagulls audio every 5 points
                    PlaySoundForPlayersInRange(6200, 200.0, gShipRoutePoints[gShipCurrentPoint][0],
                                                    gShipRoutePoints[gShipCurrentPoint][1],
                                                    gShipRoutePoints[gShipCurrentPoint][1]);
            }

        gShipCurrentPoint++;

        if(gShipCurrentPoint == NUM_SHIP_ROUTE_POINTS) {
                    gShipCurrentPoint = 0;

                    MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
                                       gShipRoutePoints[gShipCurrentPoint][1],
                                                               gShipRoutePoints[gShipCurrentPoint][1],
                                                               SHIP_MOVE_SPEED / 2.0,
                                                               gShipRoutePoints[gShipCurrentPoint][1],
                                                               gShipRoutePoints[gShipCurrentPoint][1],
                                                               gShipRoutePoints[gShipCurrentPoint][1]);
            return 1;
            }

            if(gShipCurrentPoint == 1) {
                SetTimer("StartMovingTimer",30*1000,0);
                    return 1;
            }

        MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
                                       gShipRoutePoints[gShipCurrentPoint][1],
                                                               gShipRoutePoints[gShipCurrentPoint][1],
                                                               SHIP_MOVE_SPEED,
                                                               gShipRoutePoints[gShipCurrentPoint][1],
                                                               gShipRoutePoints[gShipCurrentPoint][1],
                                                               gShipRoutePoints[gShipCurrentPoint][1]);

            return 1;
    }

   
    //=================================STOCK======================================//
    stock PlaySoundForPlayersInRange(soundid, Float:range, Float:x, Float:y, Float:z)
    {
            for(new i=0; i<MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i,range,x,y,z))
                {
                        PlayerPlaySound(i, soundid, x, y, z);
                }
            }
    }
Reply
#2

Can you give us the line of the error?
Reply
#3

says it in the code pal look for this

pawn Код:
{2616.2410, 486.0572, -0.2505,   259.1930, 92, 108},/*route 1 <----->This is the error line*/
Reply
#4

Didnt saw that,
Try to change :
Код:
new Float:gShipRoutePoints[NUM_SHIP_ROUTE_POINTS][2] = {
to:
Код:
new Float:gShipRoutePoints[NUM_SHIP_ROUTE_POINTS][2][6] = {
If its not working let me now.
Reply
#5

It's the spaces in the cords or what ever those are.... Remove the spaces and try
Reply
#6

dont work
Reply
#7

Does the compilation error give you a specific line as to where the error lies?

Edit: Sorry didn't refresh the browser.
Reply
#8

If you need FULL BLOWN help go ahead add me on skype: colefrick is the username
Reply
#9

Easy fix, you dont have the ship route points to two. so make
pawn Код:
#define NUM_SHIP_ROUTE_POINTS   25
//change it to how many route points you have so 2
#define NUM_SHIP_ROUTE_POINTS   2
and change this line
pawn Код:
new Float:gShipRoutePoints[NUM_SHIP_ROUTE_POINTS][2] = {
//change that too
new Float:gShipRoutePoints[NUM_SHIP_ROUTE_POINTS][6] = {
Change that to 6 cause on your route points you have x, y, z, rx, ry, rz

then to stop the ship at route 1 put this under OnObjectMoved
pawn Код:
if(gShipCurrentPoint == 1) {
        SendClientMessageToAll(0xFFFF0000, "Ferry ship as stopped!!");
        SendClientMessageToAll(0xFFFF0000, "****Estimated departure in 1 minute****");
        StopObject(gMainShipObjectId);//forgot to add this or your ship wont stop
        SetTimer("StartMovingTimer",60*1000,0); // pause at route 1 for 1 minute
        return 1;
    }
I have the same exact sript i modifyed that came with the 3d server package exept mine has 56 route points lol
Reply
#10

Your indentation is kinda suckish...
Reply
#11

pawn Code:
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*\
||                                                                                            ||
||                                              Created 8th April 2012 By Faisal Khan (faisal3325@gmail.com).                                 ||
||              WARNING: Do NOT Claim This As Your Own. Do NOT Re-Release This Without Permission.    ||
||                                                              DO NOT SELL THIS SCRIPT!                                                                  ||
||                                        Credits: Faisal_khan, Kye and Ahemad_khan                                                ||
\*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


//=================================INCLUDES=================================//
#include <a_samp>
//=================================DEFINES==================================//
#define FILTERSCRIPT
#define NUM_SHIP_ROUTE_POINTS   2
#define SHIP_MOVE_SPEED         30.0
#define SHIP_DRAW_DISTANCE      300.0
#define NUM_SHIP_ATTACHMENTS    10
#define SHIP_HULL_ID            9585
//--------------------------------------------------------------------------//
new gShipsAttachments[NUM_SHIP_ROUTE_POINTS];
new gMainShipObjectId;
new gShipCurrentPoint = 1;
new Float:gShipHullOrigin[3] =
{ -2409.8438, 1544.9453, 7.0000 }; // so we can convert world space to model space for attachment positions

new gShipAttachmentModelIds[NUM_SHIP_ATTACHMENTS] = {
9586, // Ship main platform
9761, // Ship rails
9584, // Bridge exterior
9698, // Bridge interior
9821, // Bridge interior doors
9818, // Bridge radio desk
9819, // Captain's desk
9822, // Captain's seat
9820, // Bridge ducts and lights
9590  // Cargo bay area
};

new Float:gShipAttachmentPos[NUM_SHIP_ATTACHMENTS][3] = {
// these are world space positions used on the original cargo ship in the game
// they will be converted to model space before attaching
{-2412.1250, 1544.9453, 17.0469},
{-2411.3906, 1544.9453, 27.0781},
{-2485.0781, 1544.9453, 26.1953},
{-2473.5859, 1543.7734, 29.0781},
{-2474.3594, 1547.2422, 24.7500},
{-2470.2656, 1544.9609, 33.8672},
{-2470.4531, 1551.1172, 33.1406},
{-2470.9375, 1550.7500, 32.9063},
{-2474.6250, 1545.0859, 33.0625},
{-2403.5078, 1544.9453, 8.7188}
};
//This is our ship route points you can modify this as to your wish
new Float:gShipRoutePoints[NUM_SHIP_ROUTE_POINTS][6] = {
{2616.2410, 486.0572, -0.2505,   259.1930, 92.0, 108.0},/*route 1 <----->This is the error line*/
{2767.4495, 445.9613, -0.2555,   260.4986, 92.0, 108.0}// route 2
};

//==================================FORWARDS============================================//
forward StartMovingTimer();
//=======================================================================================//
public OnFilterScriptInit()
{
    print("\n--------------------------------");
    print("Moving Ship By Faisal_khan");
    print("--------------------------------\n");

    gMainShipObjectId = CreateObject(SHIP_HULL_ID, gShipRoutePoints[0][0], gShipRoutePoints[0][1], gShipRoutePoints[0][1],
    gShipRoutePoints[0][1], gShipRoutePoints[0][1], gShipRoutePoints[0][1], SHIP_DRAW_DISTANCE);

    new x=0;
    while(x != NUM_SHIP_ATTACHMENTS)
    {
        gShipsAttachments[x] = CreateObject(gShipAttachmentModelIds[x], 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, SHIP_DRAW_DISTANCE);
        AttachObjectToObject(gShipsAttachments[x], gMainShipObjectId,
        gShipAttachmentPos[x][0] - gShipHullOrigin[0],
        gShipAttachmentPos[x][1] - gShipHullOrigin[1],
        gShipAttachmentPos[x][1] - gShipHullOrigin[1],
        0.0, 0.0, 0.0);
        x++;
    }
    SetTimer("StartMovingTimer",50*1000,0); // pause at route 0 for 50 seconds
    SendClientMessageToAll(0xDEEE20FF, "Ferry Has Docked At Bishop Tree Ferry Port");
    return 1;
}

public StartMovingTimer()
{
    MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
    gShipRoutePoints[gShipCurrentPoint][1],
    gShipRoutePoints[gShipCurrentPoint][1],
    SHIP_MOVE_SPEED / 3.0,
    gShipRoutePoints[gShipCurrentPoint][1],
    gShipRoutePoints[gShipCurrentPoint][1],
    gShipRoutePoints[gShipCurrentPoint][1]);
}

public OnObjectMoved(objectid)
{
    if(objectid != gMainShipObjectId) return 0;

    if(gShipCurrentPoint > 0 && !(gShipCurrentPoint % 1))
    {
        // play some seagulls audio every 5 points
        PlaySoundForPlayersInRange(6200, 200.0, gShipRoutePoints[gShipCurrentPoint][0],
        gShipRoutePoints[gShipCurrentPoint][1],
        gShipRoutePoints[gShipCurrentPoint][1]);
    }

    gShipCurrentPoint++;

    if(gShipCurrentPoint == NUM_SHIP_ROUTE_POINTS)
    {
        gShipCurrentPoint = 0;

        MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
        gShipRoutePoints[gShipCurrentPoint][1],
        gShipRoutePoints[gShipCurrentPoint][1],
        SHIP_MOVE_SPEED / 2.0,
        gShipRoutePoints[gShipCurrentPoint][1],
        gShipRoutePoints[gShipCurrentPoint][1],
        gShipRoutePoints[gShipCurrentPoint][1]);
        return 1;
    }

    if(gShipCurrentPoint == 1)
    {
        SetTimer("StartMovingTimer",30*1000,0);
        return 1;
    }

    MoveObject(gMainShipObjectId,gShipRoutePoints[gShipCurrentPoint][0],
    gShipRoutePoints[gShipCurrentPoint][1],
    gShipRoutePoints[gShipCurrentPoint][1],
    SHIP_MOVE_SPEED,
    gShipRoutePoints[gShipCurrentPoint][1],
    gShipRoutePoints[gShipCurrentPoint][1],
    gShipRoutePoints[gShipCurrentPoint][1]);

    return 1;
}


//=================================STOCK======================================//
stock PlaySoundForPlayersInRange(soundid, Float:range, Float:x, Float:y, Float:z)
{
    for(new i=0; i<MAX_PLAYERS; i++)
        if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(i,range,x,y,z))
            PlayerPlaySound(i, soundid, x, y, z);
}
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)