Jump to content
  • 0

Question

Posted

de ceva timp tot imi apare eroarea asta in log si nu imi dau seama de unde ar putea fi

eroarea: 

[08:56:16] [debug] AMX backtrace:
[08:56:16] [debug] #0 000518b0 in public OnObjectMoved (15) from FiveGame_v1.1.4.amx
[08:56:18] [debug] Run time error 4: "Array index out of bounds"
[08:56:18] [debug]  Attempted to read/write array element at index 999 in array of size 500
[08:56:18] [debug] AMX backtrace:
[08:56:18] [debug] #0 000518b0 in public OnObjectMoved (1) from FiveGame_v1.1.4.amx
[08:56:26] [debug] Run time error 4: "Array index out of bounds"
[08:56:26] [debug]  Attempted to read/write array element at index 999 in array of size 500

codul:

public OnObjectMoved(objectid)
{
    new i = Baller;
    if(ShootingBall == 2)
    {
		BallDown2(i);
		return 1;
    }
    else if(ShootingBall == 3)
    {
		BallDown3(i);
		return 1;
    }
    else if(ShootingBall == 4)
    {
		BallDown4(i);
		return 1;
    }
    else if(ShootingBall == 5)
    {
		BallDown5(i);
		return 1;
    }
    else if(ShootingBall == 6)
    {
        ApplyAnimation(i,"BSKTBALL","BBALL_walk",4.1,1,1,1,1,1);
		HavingBall[i] = 1;
		AnimBasket[i] = 0;
    }
    if(BallBounce == 1)
    {
        new Float:x, Float:y, Float:z;
	    GetObjectPos(Ball, x, y, z);
	    MoveObject(Ball, x, y, z+1.2, 4);
	    BallBounce = 2;
	}
	else if(BallBounce == 2)
    {
        new Float:x, Float:y, Float:z;
	    GetObjectPos(Ball, x, y, z);
	    MoveObject(Ball, x, y, z-1.2, 4);
	    BallBounce = 3;
	}
	else if(BallBounce == 3)
    {
        new Float:x, Float:y, Float:z;
	    GetObjectPos(Ball, x, y, z);
	    MoveObject(Ball, x, y, z+0.8, 3);
	    BallBounce = 4;
	}
	else if(BallBounce == 4)
    {
        new Float:x, Float:y, Float:z;
	    GetObjectPos(Ball, x, y, z);
	    MoveObject(Ball, x, y, z-0.8, 3);
	    BallBounce = 5;
	}
	else if(BallBounce == 5)
    {
        new Float:x, Float:y, Float:z;
	    GetObjectPos(Ball, x, y, z);
	    MoveObject(Ball, x, y, z+0.5, 2);
	    BallBounce = 6;
	}
	else if(BallBounce == 6)
    {
        new Float:x, Float:y, Float:z;
	    GetObjectPos(Ball, x, y, z);
	    MoveObject(Ball, x, y, z-0.5, 2);
	    BallBounce = 7;
	}
	else if(BallBounce == 7)
    {
        new Float:x, Float:y, Float:z;
	    GetObjectPos(Ball, x, y, z);
	    MoveObject(Ball, x, y, z+0.2, 1);
	    BallBounce = 8;
	}
	else if(BallBounce == 8)
    {
        new Float:x, Float:y, Float:z;
	    GetObjectPos(Ball, x, y, z);
	    MoveObject(Ball, x, y, z-0.2, 1);
	    BallBounce = 0;
	}
    if(!HavingBall[i]) return 1;
	new Keys, ud, lr;
	GetPlayerKeys(i, Keys, ud, lr);
    if(AnimBasket[i])
    {
        switch(BallStatus)
	    {
			case 0:
			{
				BallStatus = 1;
				new Float:x, Float:y, Float:z;
				GetPlayerPos(i, x, y, z);
				StopObject(Ball);
				new Float:x2, Float:y2;
		 	    GetXYInFrontOfPlayerBasket(i, x2, y2,0.4);
				MoveObject(Ball, x2, y2, z+0.1, 5.5);
			}
			case 1:
			{
        		BallStatus = 0;
        		new Float:x, Float:y, Float:z;
				GetPlayerPos(i, x, y, z);
				StopObject(Ball);
				new Float:x2, Float:y2;
				GetXYInFrontOfPlayerBasket(i, x2, y2,0.4);
				MoveObject(Ball, x2, y2, z-0.8, 5.5);
			}
		}
		return 1;
    }
    if(Keys & KEY_SPRINT)
	{
        ApplyAnimation(i,"BSKTBALL","BBALL_run",4.1,1,1,1,1,1);
        switch(BallStatus)
		{
			case 0:
			{
				BallStatus = 1;
				new Float:x, Float:y, Float:z;
				GetPlayerPos(i, x, y, z);
				StopObject(Ball);
				new Float:x2, Float:y2;
		        GetXYInFrontOfPlayerBasket(i, x2, y2,1.5);
				MoveObject(Ball, x2, y2, z+0.1, 8);
			}
			case 1:
			{
        		BallStatus = 0;
        		new Float:x, Float:y, Float:z;
				GetPlayerPos(i, x, y, z);
				StopObject(Ball);
				new Float:x2, Float:y2;
				GetXYInFrontOfPlayerBasket(i, x2, y2,1.5);
				MoveObject(Ball, x2, y2, z-0.8, 8);
			}
		}
		return 1;
    }
    else
    {
        ApplyAnimation(i,"BSKTBALL","BBALL_walk",4.1,1,1,1,1,1);
    }
	switch(BallStatus)
	{
		case 0:
		{
			BallStatus = 1;
			new Float:x, Float:y, Float:z;
			GetPlayerPos(i, x, y, z);
			StopObject(Ball);
			new Float:x2, Float:y2;
		    GetXYInFrontOfPlayerBasket(i, x2, y2,1.2);
			MoveObject(Ball, x2, y2, z+0.1, 5);
		}
		case 1:
		{
        	BallStatus = 0;
        	new Float:x, Float:y, Float:z;
			GetPlayerPos(i, x, y, z);
			StopObject(Ball);
			new Float:x2, Float:y2;
			GetXYInFrontOfPlayerBasket(i, x2, y2,1.2);
			MoveObject(Ball, x2, y2, z-0.8, 5);
		}
	}
    return 1;
}

 

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

Recommended Posts

  • 0
  • Administrator
Posted

Ai un vector de 500 si elemente si tu vrei sa-l accesezi pe cel de pe pozitia 999.

  • 0
Posted
Acum 21 minute, WopsS a spus:

Ai un vector de 500 si elemente si tu vrei sa-l accesezi pe cel de pe pozitia 999.

nu inteleg la ce te referi

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
  • Administrator
Posted
2 minutes ago, Geani said:

nu inteleg la ce te referi

Ai un vector de 500 de elemente, deci ai elemente valide de la 0 la 499, cand tu accesezi o valoare in acel interval ([0, 499]) totul e bine, dar atunci cand acea valoare nu este in acel interval se intampla asta. Cred ca vectorii cu problema sunt HavingBall si AnimBasket.

  • 0
Posted
Acum 26 minute, WopsS a spus:

Ai un vector de 500 de elemente, deci ai elemente valide de la 0 la 499, cand tu accesezi o valoare in acel interval ([0, 499]) totul e bine, dar atunci cand acea valoare nu este in acel interval se intampla asta. Cred ca vectorii cu problema sunt HavingBall si AnimBasket.

sa fie problema asta if(HavingBall[playerid]) Baller = 999; ii pun si un printf sa vad ce are

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
  • Administrator
Posted
17 minutes ago, Geani said:

sa fie problema asta if(HavingBall[playerid]) Baller = 999; ii pun si un printf sa vad ce are

De la aia e. Regandeste sistemul.

  • 0
Posted

ok multumesc!

  • Upvote 1

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
Posted

nu reusesc sa ii gasesc greseala up va rog

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
Posted
Chiar acum, WopsS a spus:

Ce vrei sa faci acolo? De ce setezi variabila pe 999?

pai pe cat sa o setez pe 0?

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
  • Administrator
Posted
Just now, Geani said:

pai pe cat sa o setez pe 0?

Pe INVALID_PLAYER_ID daca il folosesti ca pe un ID al jucatorului si sa verifici daca Baller este diferit de INVALID_PLAYER_ID inainte sa executi tot codul.

  • 0
Posted
Acum 32 minute, WopsS a spus:

Pe INVALID_PLAYER_ID daca il folosesti ca pe un ID al jucatorului si sa verifici daca Baller este diferit de INVALID_PLAYER_ID inainte sa executi tot codul.

mie ce legatura are cu acest baller este 

if(HavingBall[playerid]) Baller = 999; //OnPlayerDisconnect
//Basket
	SetPVarInt(playerid, "laser", 0);
 	RemovePlayerAttachedObject(playerid, 0);
	if(usingcarwash == playerid)
	{
	    SetVehicleToRespawn(GetPlayerVehicleID(playerid));
	    usingcarwash = -1;
	    UpdateDynamic3DTextLabelText(entrancetext, 0x008B00FF, "Nimeni nu foloseste spalatoria acum..\nPret: $5 (/spalatorie)");
	}
si 
//Basket//
	    HavingBall[playerid] = 0;
	    catuse[playerid] = 0;
	    if(HavingBall[playerid]) Baller = 999;//
//Basket
		OnWeaponDrop(playerid);
		if(usingcarwash == playerid)
		{
		    SetVehicleToRespawn(GetPlayerVehicleID(playerid));
		    usingcarwash = -1;
		    UpdateDynamic3DTextLabelText(entrancetext, 0x008B00FF, "Nimeni nu foloseste spalatoria acum..\nPret: $5 (/spalatorie)");
		}

 

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
Posted
Acum 1 minut, WopsS a spus:

Foloseste-l cum ti-am zis eu.

te referi la acel playerid?

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
  • Administrator
Posted
1 minute ago, Geani said:

te referi la acel playerid?

Nu, ma refer sa ii atribui valoarea INVALID_PLAYER_ID variabilei Baller atunci cand nici un jucator nu are mingea, Am uitat sa te intreb HavingBall si AnimBasket cum ii ai declarati?

  • 0
Posted
Acum 50 minute, WopsS a spus:

Nu, ma refer sa ii atribui valoarea INVALID_PLAYER_ID variabilei Baller atunci cand nici un jucator nu are mingea, Am uitat sa te intreb HavingBall si AnimBasket cum ii ai declarati?

if(newkeys & KEY_FIRE && !IsPlayerInAnyVehicle(playerid))
	{
        if(!HavingBall[playerid])
		{
			new Float:x, Float:y, Float:z;
			GetObjectPos(Ball, x, y, z);
			if(IsPlayerInRangeOfPoint(playerid, 1.5, x, y, z))
			{
				HavingBall[playerid] = 1;
				ApplyAnimation(playerid,"BSKTBALL","BBALL_pickup",4.0,0,0,0,0,0);
				if(Baller != 999)
				{
					HavingBall[Baller] = 0;
					ClearAnimations(Baller);
					ApplyAnimation(Baller, "CARRY", "crry_prtial", 1.0, 0, 0, 0, 0, 0);
					ApplyAnimation(playerid,"BSKTBALL","BBALL_walk",4.1,1,1,1,1,1);
				}
				Baller = playerid;
				BallStatus = 1;
				new Float:x2, Float:y2;
				GetXYInFrontOfPlayerBasket(playerid, x2, y2,0.8);
				GetPlayerPos(playerid, x, y, z);
				StopObject(Ball);
				MoveObject(Ball, x2, y2, z, 2.5);
				AnimBasket[playerid] = 0;
				BallBounce = 0;
			}
		}
		else

foreach(new i: Player)
			{
				if(IsPlayerConnected(i))
				{
					if(IsPlayerFacingPlayer(playerid, i, 15))
					{
						new Float:x, Float:y, Float:z;
						GetPlayerPos(i, x, y, z);
						if(IsPlayerInRangeOfPoint(playerid, 20.0, x, y, z))
						{
							Baller = i;
							HavingBall[playerid] = 0;
							ClearAnimations(playerid);
							ApplyAnimation(playerid,"BSKTBALL","BBALL_def_loop",4.0,1,0,0,0,0);
							SetTimerEx("ClearAnim", 700, 0, "d", playerid);
							MoveObject(Ball, x, y, z, 13+random(4));
							AnimBasket[i] = 0;
							ShootingBall = 6;
							ApplyAnimation(i,"BSKTBALL","BBALL_def_loop",4.0,1,0,0,0,0);
							return 1;
						}
					}
				}
			}


 

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
Posted
Acum 3 minute, WopsS a spus:

Cum le declari, nu cum le folosesti.

Public BallDown(playerid, Float:oldz)
{
    new Float:x, Float:y, Float:z;
    GetObjectPos(Ball, x, y, z);
    new Float:a;
    new Float:x2, Float:y2;
    GetPlayerPos(playerid, x2, y2, a);
    GetPlayerFacingAngle(playerid, a);
    x2 += (16 * floatsin(-a, degrees));
    y2 += (16 * floatcos(-a, degrees));
    MoveObject(Ball, x2, y2, oldz-0.8, 10.0+random(3));
    Baller = 999;
    ShootingBall = 0;
    BallBounce = 1;
    return 1;
}

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
Posted
Acum 2 ore, WopsS a spus:

Asta e folosire. Eu ma refer la


new HavingBall[...]

 

MAX_PLAYERS

 

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
Posted
Acum 10 ore, WopsS a spus:

Și AimBasket?

la fel este

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

  • 0
  • Administrator
Posted

Ai actualizat fisierele din pawno/include? Ia dai un printf la MAX_PLAYERS.

  • 0
Posted
Acum 10 ore, WopsS a spus:

Ai actualizat fisierele din pawno/include? Ia dai un printf la MAX_PLAYERS.

doar folderul YSI am actualizat am facut si un printf 

[07:23:08] [PAWN]: MAX_PLAYERS 500 

 

FiveGame  Lands

Pawno Developer, Mapping , Scripter

Since 2016

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.