carrespawn command
#1

this commands not working, i get the unknown command error when i want to use
Код:
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;
}
Reply
#2

pawn Код:
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 commented out an if statement without commenting its' opening and closing brackets. Either comment out its' opening and closing brackets too or uncomment the if statement.
Reply
#3

still not working
Reply
#4

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.
Reply
#5

Quote:
Originally Posted by Rufio
Посмотреть сообщение
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.
Variables have default value in pawn.

Anyway, is your code made for respawning a vehicle? Have you crashdetect plugin ? If yes, does it detect something?
Reply
#6

Код:
[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
Reply
#7

Your Engine_SET function is faulty, post your Engine_SET function.
Reply
#8

Код:
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;
}
Reply
#9

Is Engine defined like Engine[MAX_VEHICLES]?
Reply
#10

Код:
new Engine[MAX_VEH]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)