SA-MP Forums Archive
Amx Backtrace - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Amx Backtrace (/showthread.php?tid=611342)



Amx Backtrace - TaylorShade - 05.07.2016

Logs:
Код:
[01:23:40] Brisanje fajla: |Vozila/Vozilo_723.ini|
[01:23:43] [debug] Run time error 4: "Array index out of bounds"
[01:23:43] [debug]  Accessing element at negative index -400
[01:23:43] [debug] AMX backtrace:
[01:23:43] [debug] #0 002b05b0 in public Odbrojavanja () from FGaming4.2.amx
[01:23:45] Igrac Selko_Kralj prebacen u AFK Zonu!
[01:23:45] [debug] Run time error 4: "Array index out of bounds"
[01:23:45] [debug]  Accessing element at negative index -400
[01:23:45] [debug] AMX backtrace:
[01:23:45] [debug] #0 002b05b0 in public Odbrojavanja () from FGaming4.2.amx
Code:
Код:
forward Odbrojavanja();
public Odbrojavanja()
{
	foreach(Player,i)
	{
	    if(UlogovanProvera[i] == 1)
  		{
			if(IsPlayerInRangeOfPoint(i,5.0, 1444.5909, -1328.7688, 13.5884))
		    {
				if(vratashop[i] == false)
				{
			        MoveDynamicObject(vratas2, 1444.5974, -1333.7252, 13.9780, 2.0);
	                MoveDynamicObject(vratas1, 1444.5974, -1323.7494, 13.9780, 2.0);
			        vratashop[i] = true;
	      		}
	      		else if(vratashop[i] == true)
	    		{
					MoveDynamicObject(vratas1, 1444.5974, -1325.4054, 13.9780, 2.0);
					MoveDynamicObject(vratas2, 1444.5974, -1332.0692, 13.9780, 2.0);
					vratashop[i] = false;
	    		}
//	      		return;
			}
  		    if(PI[i][Mutiran] > 0) PI[i][Mutiran]--;
			if(PI[i][pDzeparosVreme] > 0) PI[i][pDzeparosVreme] --;
			if(PI[i][MehanicarOdvoz] > 0) PI[i][MehanicarOdvoz] --;
			if(PI[i][pRobTime] > 0) PI[i][pRobTime]--;
			if(hPomoc[i] > 0)
			{
				hPomoc[i]--;
				if(hPomoc[i] == 0) POMOC[i][pPitao] = 0;
			}
			if(PI[i][UzeoOpremu] > 0)
			{
				PI[i][UzeoOpremu]--;
			}
			if(AFK[i] == true) AFKVreme[i]++;
			if(Robbingtime[i] > 0)
			{
				Robbingtime[i]--;
				new robovanje[40];
				format(robovanje, sizeof(robovanje), "PREOSTALO VREME: ~r~%d SEC", Robbingtime[i]);
				PlayerTextDrawSetString(i, RobbankTD[i][0], robovanje);
			}
			if(PI[i][pZatvorenVreme] > 0)
			{
			    PI[i][pZatvorenVreme]--;
			    new odbrojav[128];
			    format(odbrojav,sizeof(odbrojav),"~n~~n~~n~~n~~n~~n~~n~~r~~h~~h~Vreme zatvora:~n~~w~%s",KonvertujVreme(PI[i][pZatvorenVreme]));
				GameTextForPlayer(i, odbrojav, 1100, 3);
			}
			if(PI[i][pZatvorenVreme] <= 0 && PI[i][Zatvor] > 0)
			{
				PI[i][Zatvor] = 0;
				PI[i][pZatvorenVreme] = 0;
				SetPlayerWorldBounds(i,20000.0000,-20000.0000,20000.0000,-20000.0000);
				g_SetPlayerInterior(i, 0);
				g_SetPlayerVirtualWorld(i, 0);
				SetPlayerPos(i, 1800.1886,-1584.4720,13.4922);
				SetPlayerFacingAngle(i, 281.0);
				SetCameraBehindPlayer(i);
			    GameTextForPlayer(i, "~g~Sloboda~n~~w~Pokusajte biti bolji gradjanin", 5000, 1);
				SetPlayerColor(i, TEAM_HIT_COLOR);
			}
		    if(IsPlayerInAnyVehicle(i))
		   	{
		   	    if(!VoziloJeBicikla(GetVehicleModel(GetPlayerVehicleID(i))))
		   	    {
		   	    	new vstring2[24];
					if(VoziloJeDizelas(GetPlayerVehicleID(i)))
					{
	                    PlayerTextDrawSetString(i, BRZINOMER[i][6], "Dizel");
					}
					else if(IsVehicleLetelica(GetPlayerVehicleID(i)))
					{
	                    PlayerTextDrawSetString(i, BRZINOMER[i][6], "Kerozin");
					}
					else
	 				{
						PlayerTextDrawSetString(i, BRZINOMER[i][6], "Benzin");
					}
					new autostringg[64];
					format(autostringg, sizeof(autostringg), "%s", GetVehicleNameEx(GetVehicleModel(GetPlayerVehicleID(i))));
					PlayerTextDrawSetString(i, BRZINOMER[i][7], autostringg);
					if(Fuel[GetPlayerVehicleID(i)] > 100.0) format(vstring2, sizeof(vstring2), "N/A");
				  	else format(vstring2, sizeof(vstring2), "%.1f", Fuel[GetPlayerVehicleID(i)]);
					PlayerTextDrawSetString(i, BRZINOMER[i][5], vstring2);
					if(Fuel[GetPlayerVehicleID(i)] <= 0 && NestaloGoriva[i] == 0)
					{
					    NestaloGoriva[i] = 1;
						new engine, lights, alarm, doors, bonnet, boot, objective;
						GetVehicleParamsEx(GetPlayerVehicleID(i), engine, lights, alarm, doors, bonnet, boot, objective);
						SetVehicleParamsEx(GetPlayerVehicleID(i), 0, lights, alarm, doors, bonnet, boot, objective);
						GameTextForPlayer(i, "~w~Nema vise ~r~goriva ~w~u vozilu!", 5000, 3);
						SCM(i,ZUTA, "Vas rezervoar sa gorivom ostao je prazan,motor vozila vam se ugasio.");
					}
		   		}
		    }
		}
	}
	return 1;
}



Re: Amx Backtrace - Vince - 05.07.2016

I'm 99% sure this is caused by trying to get the name of an invalid vehicle. But because you have localized your variable's names I can't understand shit.


Re: Amx Backtrace - TaylorShade - 05.07.2016

you think its this part?

Код:
new autostringg[64];
					format(autostringg, sizeof(autostringg), "%s", GetVehicleNameEx(GetVehicleModel(GetPlayerVehicleID(i))));
					PlayerTextDrawSetString(i, BRZINOMER[i][7], autostringg);
					if(Fuel[GetPlayerVehicleID(i)] > 100.0) format(vstring2, sizeof(vstring2), "N/A");
				  	else format(vstring2, sizeof(vstring2), "%.1f", Fuel[GetPlayerVehicleID(i)]);
					PlayerTextDrawSetString(i, BRZINOMER[i][5], vstring2);
					if(Fuel[GetPlayerVehicleID(i)] <= 0 && NestaloGoriva[i] == 0)



Re: Amx Backtrace - Mencent - 05.07.2016

Hello!

Can you show us your function "GetVehicleNameEx", please?


Re: Amx Backtrace - Runn3R - 05.07.2016

probably needs GetVehicleModel() - 400


Re: Amx Backtrace - TaylorShade - 05.07.2016

Код:
#define GetVehicleNameEx(%0) ImenaVozila[(%0) - 400]
Код:
new ImenaVozila[212][] =
{
	{"Landstal"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"}, {"Dumper"},{"Firetruck"},{"Trashmaster"},{"Stretch"},{"Manana"},{"Infernus"},{"Voodoo"},{"Pony"},{"Mule"},{"Cheetah"},{"Ambulance"},{"Leviathan"},{"Moonbeam"},{"Esperanto"},{"Taxi"},
	{"Washington"},{"Bobcat"},{"Whoopee"},{"BF-INJ"},{"Hunter"},{"Premier"},{"Enforcer"},{"Securicar"},{"Banshee"},{"Predator"},{"Bus"},{"Rhino"},{"Barracks"},{"Hotknife"},{"Article TR"},{"Previon"},{"Coach"},{"Cabbie"},{"Stallion"},{"Rumpo"},{"RC Bandit"},{"Romero"},{"Packer"},{"Monster"},
	{"Admiral"},{"Squalo"},{"Seasparrow"},{"Pizzaboy"},{"Tram"},{"Article TR2"},{"Turismo"},{"Speeder"},{"Reefer"},{"Tropic"},{"Flatbed"},{"Yankee"},{"Caddy"},{"Solair"},{"Berkley's RC"},{"Skimmer"},{"PCJ-600"},{"Faggio"},{"Freeway"},{"RC Baron"},{"RC Raider"},{"Glendale"},{"Oceanic"},{"Sanchez"},
	{"Sparrow"},{"Patriot"},{"Quad"},{"Coastguard"},{"Dinghy"},{"Hermes"},{"Sabre"},{"Rustler"},{"ZR-350"},{"Walton"},{"Regina"},{"Comet"},{"BMX"},{"Burrito"},{"Camper"},{"Marquis"},{"Baggage"},{"Dozer"},{"Maverick"},{"Chopper"},{"Rancher"},{"FBI - Ra"},{"Virgo"},{"Greenwood"},{"Jetmax"},{"Hotring"},
	{"Sandking"},{"Blista Compact"},{"Police Maverick"},{"Boxville"},{"Benson"},{"Mesa"},{"RC Goblin"},{"HR - A"},{"HR - B"},{"Bloodring Banger"},{"Rancher"},{"Super GT"},{"Elegant"},{"Journey"},{"Bike"},{"Mountain Bike"},{"Beagle"},{"Cropdust"},{"Stuntplane"},{"Tanker"},{"Roadtrain"},
	{"Nebula"},{"Majestic"},{"Buccaneer"},{"Shamal"},{"Hydra"},{"FCR-900"},{"NRG-500"},{"HPV1000"},{"Cement Truck"},{"Tow Truck"},{"Fortune"},{"Cadrona"},{"FBI Truck"},{"Willard"},{"Forklift"},{"Tractor"},{"Combine"},{"Feltzer"},{"Remington"},{"Slamvan"},{"Blade"},{"Freight"},{"Streak"},{"Vortex"},
	{"Vincent"},{"Bullet"},{"Clover"},{"Sadler"},{"Firetruck LA"},{"Hustler"},{"Intruder"},{"Primo"},{"Cargobob"},{"Tampa"},{"Sunrise"},{"Merit"},{"Utility"},{"Nevada"},{"Yosemite"},{"Windsor"},{"Monster A"},{"Monster B"},{"Uranus"},{"Jester"},{"Sultan"},{"Stratum"},{"Elegy"},{"Raindance"},
	{"RC Tiger"},{"Flash"},{"Tahoma"},{"Savanna"},{"Bandito"},{"Freight Flat"},{"Streak Carriage"},{"Kart"},{"Mower"},{"Dunerider"},{"Sweeper"},{"Broadway"},{"Tornado"},{"AT-400"},{"DFT-30"},{"Huntley"},{"Stafford"},{"BF-400"},{"Newsvan"},{"Tug"},{"Article Trailer 3"},{"Emperor"},{"Wayfarer"},{"Euros"},{"Mobile Hotdog"},
	{"Club"},{"Carriage"},{"Trailer 3"},{"Andromada"},{"Dodo"},{"RC Cam"},{"Launch"},{"Police"},{"Police"},{"Police"},{"LSPD-Ranger"},{"Picador"},{"SWAT Van"},{"Alpha"},{"Phoenix"},{"Glendale"},{"Sadler"},{"Luggage TR A"},{"Luggage TR B"},{"Stair Trailer"},
	{"Boxville"},{"Farm Plow"},{"Utility TR"}
};



Re: Amx Backtrace - Konstantinos - 05.07.2016

Remove the #define pattern and have it as a function:
pawn Код:
GetVehicleNameEx(modelid)
{
    new v_name[18];
    if (400 <= modelid <= 611) strcat(v_name, ImenaVozila[modelid - 400]);
    return v_name;
}
and you don't need the brackets around each name of the vehicles.


Re: Amx Backtrace - TaylorShade - 05.07.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Remove the #define pattern and have it as a function:
pawn Код:
GetVehicleNameEx(modelid)
{
    new v_name[18];
    if (400 <= modelid <= 611) strcat(v_name, ImenaVozila[modelid - 400]);
    return v_name;
}
and you don't need the brackets around each name of the vehicles.
Thanks