Pickup armour
#1

Error on server log

Код:
[20:53:31] [debug] Run time error 4: "Array index out of bounds"
[20:53:31] [debug]  Accessing element at index 200 past array upper bound 199
[20:53:31] [debug] AMX backtrace:
[20:53:31] [debug] #0 000071ec in public OnPlayerPickUpDynamicPickup () from ArmourRegen.amx
[20:53:31] [debug] #1 native Streamer_CallbackHook () [648ab720] from streamer.DLL
[20:53:31] [debug] #2 00000710 in public OnPlayerPickUpPickup () from ArmourReg
OnPlayerPickUpDynamicPickUp

Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
	for(new i = 1; i <= MAX_REGEN; i++)
	{
		if(pickupid == ArmourRegen[i][APickup])
		{
			if(PlayerArmour(playerid) > 98)
			{
				SetPlayerArmour(playerid, 100);
				GameTextForPlayer(playerid,"~r~~h~~<~ Armour Full ~>~",2500,4);
			}
			else 
			{
				SetPlayerArmour(playerid, PlayerArmour(playerid)+ArmourRegen[i][AValue]);
				GameTextForPlayer(playerid,"~g~~h~~<~ Refill Armour ~>~",2500,4);
			}
                }
       }
       return 1;
}
Reply
#2

Quote:
Originally Posted by SilverStand
Посмотреть сообщение
Код:
public OnPlayerPickUpDynamicPickup(playerid, pickupid)
{
	for(new i = 1; i <= MAX_REGEN; i++)
        //...
}
You are accessing a value out of the array bounds.

ArmourRegen can only store 200 values (0-199) and MAX_REGEN is 200.

Change to
Код:
for(new i = 1; i < MAX_REGEN; i++)
Also, arrays start at 0 index, not sure if you intended to skip the first value of the array.
Код:
for(new i = 1; i < MAX_REGEN; i++)
Reply
#3

ty so much :> +REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)