Help, 2 errors and can't fix.
#1

Hello, I am having 2 errors in a script I have made and can not find a fix for them, This is not a dynamic system by the way it is just a way for me to add more non buyable buildings in easier.

the error messages are:
Код:
../gamemodes/maps.pwn(6) : error 032: array index out of bounds (variable "BuildingEnterPos")
C:\Users\nathan\Dropbox\new 2r-rp\gamemodes\Main.pwn(1937) : error 035: argument type mismatch (argument 2)
The line for the first error which is:
../gamemodes/maps.pwn(6) : error 032: array index out of bounds (variable "BuildingEnterPos") is

pawn Код:
CreateDynamic3DTextLabel(string,0xFFFFFFFF,BuildingEnterPos[h][0], BuildingEnterPos[h][1], BuildingEnterPos[2]+0.75, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 100.0);
The full line of code for the first error is
pawn Код:
new Float:BuildingEnterPos[1][3] = {
{648.456481,-1353.883666,13.547086}
};

for(new h = 0; h < sizeof(BuildingEnterPos); h++)
    {
        new string[256];
        format(string, sizeof(string), "%s\nPress H to enter or\ntype /enter", BuildingNames[h]);
        CreateDynamic3DTextLabel(string,0xFFFFFFFF,BuildingEnterPos[h][0], BuildingEnterPos[h][1], BuildingEnterPos[2]+0.75, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 100.0);
        CreateDynamicPickup(1318, 1, BuildingEnterPos[h][0], BuildingEnterPos[h][1], BuildingEnterPos[h][2]);
    }
the next error message is on this line.

pawn Код:
SetPlayerInterior(playerid,BuildingInts[h]);
Full code is.
pawn Код:
new BuildingNames[1][128] = {
{"San News HQ"}
};

new Float:BuildingEnterPos[1][3] = {
{648.456481,-1353.883666,13.547086}
};

new Float:BuildingIntPos[1][3] = {
{3887.393310,-900.421936,1180.593994}
};

new BuildingInts[1][] = {
{1}
};

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_CTRL_BACK)
    {
        for(new h = 0; h < sizeof(BuildingEnterPos); h++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 3.0,BuildingEnterPos[h][0], BuildingEnterPos[h][1], BuildingEnterPos[h][2]))
            {
                TogglePlayerControllableEx(playerid,false);
                SetPlayerPos(playerid,BuildingIntPos[h][0], BuildingIntPos[h][1], BuildingIntPos[h][2]);
                SetPlayerInterior(playerid,BuildingInts[h]);
                SetPlayerVirtualWorld(playerid,h);
                SendClientMessage(playerid, COLOR_ORANGE, "You are now Frozen as we attempt to load the Objects around you.");
                SendClientMessage(playerid, COLOR_ORANGE, "This Often takes 6 seconds on custom made Interiors, If you have issues contact an admin.");
                // Start a 5 second timer to end the anti-spawnkill
                SetTimerEx("LoadObjects", 6000, false, "i", playerid);
            }
            if(IsPlayerInRangeOfPoint(playerid, 3.0,BuildingIntPos[h][0], BuildingIntPos[h][1], BuildingIntPos[h][2]))
            {
                TogglePlayerControllableEx(playerid,true);
                SetPlayerPos(playerid,BuildingEnterPos[h][0], BuildingEnterPos[h][1], BuildingEnterPos[h][2]);
                SetPlayerInterior(playerid,0);
                SetPlayerVirtualWorld(playerid,0);
            }
        }
    }
    return 1;
}
Reply
#2

For the first warning/error, this is your fault:
Код:
BuildingEnterPos[2]+0.75
The BuildingEnterPos has two dimensions, use "BuildingEnterPos[h][2]" like before.
Second: again two dimensions, use "BuildingInts[h][0]" or simply lose the second dimension and just use it like you did.
Reply
#3

Quote:
Originally Posted by Virtual1ty
Посмотреть сообщение
For the first warning/error, this is your fault:
Код:
BuildingEnterPos[2]+0.75
The BuildingEnterPos has two dimensions, use "BuildingEnterPos[h][2]" like before.
Second: again two dimensions, use "BuildingInts[h][0]" or simply lose the second dimension and just use it like you did.
Ok thanks I'm so dumb lol.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)