CMD:cr(playerid, params[])
{
new S[128];
//if(Account[playerid][Admin] >= 1)
{
for(new i_Vehicle; i_Vehicle < MAX_VEHICLES; i_Vehicle++)
{
if( !ValakiAKocsiban(i_Vehicle))
{
Engine_SET(playerid, i_Vehicle, 0);
SetVehiclePos(i_Vehicle, Vehicles[i_Vehicle][PosX],Vehicles[i_Vehicle][PosY],Vehicles[i_Vehicle][PosZ]);
SetVehicleZAngle(i_Vehicle, Vehicles[i_Vehicle][PosA]);
}
}
format(S, sizeof(S), "%s respawnolta a jбrműveket!", GetRoleplayName(playerid));
SendClientMessageToAll(COLOR_LBLUE, S);
}
return 1;
}
ALTCMD:carrespawn->cr;
stock ValakiAKocsiban(vehicleid)
{
for( new i; i < GetMaxPlayers(); i++ )
{
if(IsPlayerInVehicle(i, vehicleid)) return true;
}
return false;
}
CMD:cr(playerid, params[])
{
new S[128];
if(Account[playerid][Admin] >= 1)
{
for(new i_Vehicle; i_Vehicle < MAX_VEHICLES; i_Vehicle++)
{
if( !ValakiAKocsiban(i_Vehicle))
{
Engine_SET(playerid, i_Vehicle, 0);
SetVehiclePos(i_Vehicle, Vehicles[i_Vehicle][PosX],Vehicles[i_Vehicle][PosY],Vehicles[i_Vehicle][PosZ]);
SetVehicleZAngle(i_Vehicle, Vehicles[i_Vehicle][PosA]);
}
}
format(S, sizeof(S), "%s respawnolta a jбrműveket!", GetRoleplayName(playerid));
SendClientMessageToAll(COLOR_LBLUE, S);
}
return 1;
}
|
You haven't initiliazed your i_Vehicles properly, it does not have a starting value.
in your for(new i_Vehicles; .........) change it to for(new i_Vehicles = 0; ) Also use this to respawn your cars; https://sampwiki.blast.hk/wiki/SetVehicleToRespawn SetVehiclePos and SetVehicleZAngle are not needed. Also, consider using foreach for your vehicle loops. |
[14:35:42] [debug] Run time error 4: "Array index out of bounds" [14:35:42] [debug] Accessing element at index 200 past array upper bound 199 [14:35:42] [debug] AMX backtrace: [14:35:42] [debug] #0 000800c8 in Engine_SET (playerid=0, vid=200, State=0) at C:\Users\Lenovo\Downloads\Small-County-RP-Release (1)\gamemodes\SCRP-R39.pwn:5949 [14:35:42] [debug] #1 0008de6c in public cmd_cr (playerid=0, params[]=@0x00498428 "") at C:\Users\Lenovo\Downloads\Small-County-RP-Release (1)\gamemodes\SCRP-R39.pwn:7288 [14:35:42] [debug] #2 native CallLocalFunction () [080dfac0] from samp03svr [14:35:42] [debug] #3 000009b0 in public OnPlayerCommandText (playerid=0, cmdtext[]=@0x00498418 "/cr") at C:\Users\Lenovo\Downloads\szerofileok\pawn\pawno\include\zcmd.inc:102 [14:35:51] [debug] Run time error 4: "Array index out of bounds" [14:35:51] [debug] Accessing element at index 200 past array upper bound 199 [14:35:51] [debug] AMX backtrace: [14:35:51] [debug] #0 000800c8 in Engine_SET (playerid=0, vid=200, State=0) at C:\Users\Lenovo\Downloads\Small-County-RP-Release (1)\gamemodes\SCRP-R39.pwn:5949 [14:35:51] [debug] #1 0008de6c in public cmd_cr (playerid=0, params[]=@0x00498448 "") at C:\Users\Lenovo\Downloads\Small-County-RP-Release (1)\gamemodes\SCRP-R39.pwn:7288 [14:35:51] [debug] #2 0008e104 in public cmd_carrespawn (playerid=0, params[]=@0x00498448 "") at C:\Users\Lenovo\Downloads\Small-County-RP-Release (1)\gamemodes\SCRP-R39.pwn:7303 [14:35:51] [debug] #3 native CallLocalFunction () [080dfac0] from samp03svr [14:35:51] [debug] #4 000009b0 in public OnPlayerCommandText (playerid=0, cmdtext[]=@0x00498418 "/carrespawn") at C:\Users\Lenovo\Downloads\szerofileok\pawn\pawno\include\zcmd.inc:102
stock Engine_SET(playerid, vid, State)
{
GetVehicleParamsEx(vid, Engine[vid], Lights[vid], alarm[vid], doors[vid], bonnet[vid], boot[vid], objective[vid]);
if(Engine[vid] == State) return 1;
if(Engine[vid] == 0 || Engine[vid] && State == 1)
{
static Float:VehicleHP;
GetVehicleHealth(vid, VehicleHP);
if(VehicleHP <= 300.0) return SendLocalMessage(playerid, "* A motor nem indul be, miutбn sъlyos sйrьlйseket szenvedett. *", Range_Normal, COLOR_RP, COLOR_RP);
if(Vehicles[vid][Fuel] <= 0) return SendLocalMessage(playerid, "* A motor nem indul be a kevйs ьzemanyag miatt. *", Range_Normal, COLOR_RP, COLOR_RP);
SetVehicleParamsEx(vid,1,Lights[vid],alarm[vid],doors[vid],bonnet[vid],boot[vid],objective[vid]);
Engine[vid] = 1;
KillTimer(Vehicles[vid][FuelTimer]);
Vehicles[vid][FuelTimer] = SetTimerEx("ReduceFuel", MINUTES(1), true, "d", vid);
GameTextForPlayer(playerid, "~g~Engine On!", 2000, 4);
return 1;
}
else if(Engine[vid] == 1 && State == 0)
{
SetVehicleParamsEx(vid,0,Lights[vid],alarm[vid],doors[vid],bonnet[vid],boot[vid],objective[vid]);
Engine[vid] = 0;
KillTimer(Vehicles[vid][FuelTimer]);
return 1;
}
//printf("vid = %d, state: %d, playerid: %d, engine: %d", vid, State, playerid, Engine[vid]);
return 1;
}
new Engine[MAX_VEH]