Problem with onplayerupdate
#1

Hello, i have made this filterscript:

pawn Код:
//rb system for sfcnr


#include <a_samp>
#include <zcmd>
#include <streamer>
#include <airbreak>

//defines
#define MAX_RB 50
#define MAX_SPIKE 50
//enums

enum rb
{
    Float:Xpos,
    Float:Ypos,
    Float:Zpos,
    object
}
new RoadBlock[MAX_PLAYERS][MAX_RB][rb];

enum spike
{
    Float:Xco,
    Float:Yco,
    Float:Zco,
    objectid_
}
new Spikes[MAX_PLAYERS][MAX_SPIKE][spike];
//stocks
stock CreateSpike(playerid, Float:x, Float:y, Float:z, Float:a)
{
    for(new i = 0; i < sizeof(Spikes);i++)
    {
        Spikes[playerid][i][Xco] = x;
        Spikes[playerid][i][Yco] = y;
        Spikes[playerid][i][Zco] = z;
        Spikes[playerid][i][objectid_] = CreateDynamicObject(2899, x, y, z-0.9, 0, 0, a);
    }
    return 1;
}
stock CreateRB(playerid, Float:x, Float:y, Float:z, Float:a)
{
    for(new i = 0; i < sizeof(RoadBlock); i++)
    {
        RoadBlock[playerid][i][Xpos] = x;
        RoadBlock[playerid][i][Ypos] = y;
        RoadBlock[playerid][i][Zpos] = z-0.7;
        RoadBlock[playerid][i][object] = CreateDynamicObject(4504, x, y, z-0.9, 0, 0, a);
    }
    return 1;
}
new RoadBlocks[MAX_PLAYERS];

stock IsPlayerAiming(playerid)
{
        new anim = GetPlayerAnimationIndex(playerid);
        if (((anim >= 1160) && (anim <= 1163)) || (anim == 1167) || (anim == 1365) || (anim == 1643) || (anim == 1453) || (anim == 220)) return 1;
        return 0;
}

public OnPlayerAirbreak(playerid)
{
    SendClientMessage(playerid, -1, "Nice airbreak!");
    return 1;
}
public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" RB SYSTEM - BRENNAN BUTLER");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    print("Unloaded filterscript: roadblocks");
    return 1;
}

public OnPlayerConnect(playerid)
{
    RoadBlocks[playerid] = 0;
    SendClientMessage(playerid, -1, "Filterscript loaded.");
    return 1;
}

//commands
CMD:createrb(playerid, params[])
{
    if(RoadBlocks[playerid] != 1)
    {
        new Float:X, Float:Y, Float:Z, Float:A;
        GetPlayerPos(playerid, X, Y, Z);
        GetPlayerFacingAngle(playerid, A);
        CreateRB(playerid, X, Y, Z, A);
        RoadBlocks[playerid] = 1;
    }
    else
    {
        SendClientMessage(playerid, -1, "NONONO");
    }
    return 1;
}

CMD:createspike(playerid, params[])
{
    new Float:X, Float:Y, Float:Z, Float:A;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, A);
    CreateSpike(playerid, X, Y, Z, A);
    return 1;
}

CMD:destroyspike(playerid, params[])
{
    for(new i = 0; i < sizeof(RoadBlock);i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, Spikes[playerid][i][Xco], Spikes[playerid][i][Yco], Spikes[playerid][i][Zco]))
        {
            Spikes[playerid][i][Xco] = 0.0;
            Spikes[playerid][i][Yco] = 0.0;
            Spikes[playerid][i][Zco] = 0.0;
            DestroyDynamicObject(Spikes[playerid][i][objectid_]);
        }
    }
    return 1;
}

CMD:destroyrb(playerid, params[])
{
    for(new i = 0; i < sizeof(RoadBlock);i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, RoadBlock[playerid][i][Xpos], RoadBlock[playerid][i][Ypos], RoadBlock[playerid][i][Zpos]))
        {
            RoadBlock[playerid][i][Xpos] = 0.0;
            RoadBlock[playerid][i][Ypos] = 0.0;
            RoadBlock[playerid][i][Zpos] = 0.0;
            DestroyDynamicObject(RoadBlock[playerid][i][object]);
            RoadBlocks[playerid] = 0;
        }
        else
        {
            for(new b, k = 1; b != k;b++)
            {
                SendClientMessage(playerid, -1, "not near");
            }
        }
    }
    return 1;
}
               
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        for(new i = 0; i < sizeof(Spikes);i++)
        {
            for(new p, a = MAX_PLAYERS; p != a;p++)
            {
                if(IsPlayerInRangeOfPoint(playerid, 1, Spikes[p][i][Xco], Spikes[p][i][Yco], Spikes[p][i][Zco]))
                {
                    new panels, doors, lights, tires;
                    new vehicleid = GetPlayerVehicleID(playerid);
                    GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
                    UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, 15);
                }
            }
        }
    }
    return 1;
}
firstly when i drive over spikes it puts this in the samp-server.exe
Код:
[13:13:05] [debug] Run time error 4: "Array index out of bounds"
[13:13:05] [debug]  Accessing element at index 50 past array upper bound 49
[13:13:05] [debug] AMX backtrace:
[13:13:05] [debug] #0 00001a24 in ?? () from roadblock.amx
[13:13:05] [debug] #1 0000248c in public cmd_createspike () from roadblock.amx
[13:13:05] [debug] #2 native CallLocalFunction () [00472c00] from samp-server.exe
[13:13:05] [debug] #3 00000468 in public OnPlayerCommandText () from roadblock.amx
[13:13:32] [debug] Run time error 4: "Array index out of bounds"
[13:13:32] [debug]  Accessing element at index 50 past array upper bound 49
[13:13:32] [debug] AMX backtrace:
[13:13:32] [debug] #0 00002518 in public cmd_destroyspike () from roadblock.amx
[13:13:32] [debug] #1 native CallLocalFunction () [00472c00] from samp-server.exe
[13:13:32] [debug] #2 00000468 in public OnPlayerCommandText () from roadblock.amx
[13:13:38] [debug] Run time error 4: "Array index out of bounds"
[13:13:38] [debug]  Accessing element at index 50 past array upper bound 49
[13:13:38] [debug] AMX backtrace:
[13:13:38] [debug] #0 00001cf8 in ?? () from roadblock.amx
[13:13:38] [debug] #1 0000233c in public cmd_createrb () from roadblock.amx
[13:13:38] [debug] #2 native CallLocalFunction () [00472c00] from samp-server.exe
[13:13:38] [debug] #3 00000468 in public OnPlayerCommandText () from roadblock.amx
[13:13:51] [debug] Run time error 4: "Array index out of bounds"
[13:13:51] [debug]  Accessing element at index 50 past array upper bound 49
[13:13:51] [debug] AMX backtrace:
[13:13:51] [debug] #0 00002888 in public cmd_destroyrb () from roadblock.amx
[13:13:51] [debug] #1 native CallLocalFunction () [00472c00] from samp-server.exe
[13:13:51] [debug] #2 00000468 in public OnPlayerCommandText () from roadblock.amx
[13:13:57] [debug] Run time error 4: "Array index out of bounds"
[13:13:57] [debug]  Accessing element at index 50 past array upper bound 49
[13:13:57] [debug] AMX backtrace:
[13:13:57] [debug] #0 00002888 in public cmd_destroyrb () from roadblock.amx
[13:13:57] [debug] #1 native CallLocalFunction () [00472c00] from samp-server.exe
[13:13:57] [debug] #2 00000468 in public OnPlayerCommandText () from roadblock.amx
[13:14:05] [debug] Run time error 4: "Array index out of bounds"
[13:14:05] [debug]  Accessing element at index 50 past array upper bound 49
[13:14:05] [debug] AMX backtrace:
[13:14:05] [debug] #0 00002888 in public cmd_destroyrb () from roadblock.amx
[13:14:05] [debug] #1 native CallLocalFunction () [00472c00] from samp-server.exe
[13:14:05] [debug] #2 00000468 in public OnPlayerCommandText () from roadblock.amx
And also when ever i do /createspike etc its saying the cmd doesnt work but it still does the cmd
Reply
#2

Код:
[13:13:05] [debug] #0 00001a24 in ?? () from roadblock.amx
[13:13:05] [debug] #1 0000248c in public cmd_createspike () from roadblock.amx
[13:13:05] [debug] #2 native CallLocalFunction () [00472c00] from samp-server.exe
[13:13:05] [debug] #3 00000468 in public OnPlayerCommandText () from roadblock.amx
What are the numbers? 0000248 c in public cm_createspike()
whats in that public? lol
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)