Jump to content
  • 0

PutPlayerInVehicle


k3nw00d_kri5ty

Question

6 answers to this question

Recommended Posts

//sus in script

new VehicleDrag[cate_vehicule_ai_la_drag-1];
//ongamemodeinit
VehicleDrag[0] = CreateVehicle(parametrii...);
VehicleDrag1] = CreateVehicle(parametrii...);
VehicleDrag[2] = CreateVehicle(parametrii...);
VehicleDrag[etc] = CreateVehicle(parametrii...);
//onplayercommandtext
if(strcmp(cmdtext, "/drag",true) == 0)
{
	SetPlayerPos(playerid, x,y,z);
	for(new i = 0; i <= sizeof(VehicleDrag); i ++ )
	{
		if(!IsVehicleOccupied(VehicleDrag[i])) 
		{
			SetVehiclePos(VehicleDrag[i], x_drag, y_drag, z_drag);
			PutPlayerInVehicle(playerid, VehicleDrag[i], 0);
			break;
		}
		if(IsVehicleOccupied(VehicleDrag[sizeof(VehicleDrag)])) return SendClientMessage(playerid, -1, "Nu sunt vehicule libere!");
	}
	return 1;
}
//undeva in script
function IsVehicleOccupied(vehicleid)
{
	for(new i=0;i<MAX_PLAYERS;i++)
	{
		if(IsPlayerInVehicle(i,vehicleid) && GetPlayerState(i) == PLAYER_STATE_DRIVER) return 1;
	}
	return 0;
}

Nu stiu daca merge, am creat asta acum. Daca nu merge, mai bine pui vehicule la spawn si sa-si aleaga fiecare un vehicul, metoda clasica :grin:

Link to comment
Share on other sites

Am primit o eroare de care nu pot scapa :|

error 032: array index out of bounds (variable "VehicleDrag")
Linia este:
if(IsVehicleOccupied(VehicleDrag[sizeof(VehicleDrag)])) return SendClientMessage(playerid, -1, "There are no free vehicles (with driver).");
Legat de VehicleDrag:
new VehicleDrag[4];

VehicleDrag[0] = CreateVehicle(Parametrii...);
VehicleDrag[1] = CreateVehicle(Parametrii...);
VehicleDrag[2] = CreateVehicle(Parametrii...);
VehicleDrag[3] = CreateVehicle(Parametrii...);

Link to comment
Share on other sites

Atunci in loc de

if(IsVehicleOccupied(VehicleDrag[sizeof(VehicleDrag)])) return SendClientMessage(playerid, -1, "There are no free vehicles (with driver).");
pune
if(IsVehicleOccupied(VehicleDrag[cate_vehicule_ai_pus_sus])) return SendClientMessage(playerid, -1, "There are no free vehicles (with driver).");

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • 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.