Same Objects Diferent ID help
#1

Код:
CMD:bengala(playerid, params[])
{
    new playerState = GetPlayerState(playerid);
	new vehicleid = GetPlayerVehicleID(playerid);
	if(Informacion[playerid][VipD] == 0) return SendClientMessage(playerid, COLOR_GRIS, "No Autorizado.");
	if(playerState != PLAYER_STATE_DRIVER || !IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GRIS, "No estas en un vehiculo o no eres el conductor.");
	{
		if(IsPlayerConnected(playerid))
		{
		    if(Bengalas[vehicleid] == 0)
		   	{
		    	Bengalas[vehicleid] = 1;
			SendClientMessage(playerid, COLOR_GRIS, "Bengalas activadas");
		       	Bengala = CreateDynamicObject(18728, 0, 0, 0, 0, 0, 0, 0, -1, -1, 200.0);
		       	AttachDynamicObjectToVehicle(Bengala, vehicleid, -1, -2, -2, 0, 0, 0);
		       	Bengala2 = CreateDynamicObject(18728, 0, 0, 0, 0, 0, 0, 0, -1, -1, 200.0);
		       	AttachDynamicObjectToVehicle(Bengala2, vehicleid, 1, -2, -2, 0, 0, 0);
			}
			else
   			{
			    Bengalas[vehicleid] = 0;
		  		SendClientMessage(playerid, COLOR_GRIS, "Bengalas desactivadas");
		  		DestroyDynamicObject(Bengala);
		  		DestroyDynamicObject(Bengala2);
		  		return 1;
			}
		}
	}
	return 1;
}
The Cmd work very good, but, When I active in a car, and left, and active in second car and desactive, the objects are removed from the first car...
I think...
Is the objects ids...
Check for the 2 vehicles the same object ids
Reply
#2

Every Vehicle need his own Variable , in this Code you have just one so the Object will be removed if you use the CMD
with other Vehicles.
Sample:
Код:
new Bengala[MAX_VEHICLES][2];// Defines this Global

CMD:bengala(playerid, params[])
{
    new playerState = GetPlayerState(playerid);
	new vehicleid = GetPlayerVehicleID(playerid);
	if(Informacion[playerid][VipD] == 0) return SendClientMessage(playerid, COLOR_GRIS, "No Autorizado.");
	if(playerState != PLAYER_STATE_DRIVER || !IsPlayerInAnyVehicle(playerid)) return  SendClientMessage(playerid, COLOR_GRIS, "No estas en un vehiculo o no eres el conductor.");
	{
		if(IsPlayerConnected(playerid))
		{
		    if(Bengalas[vehicleid] == 0)
		   	{
		    	Bengalas[vehicleid] = 1;
				SendClientMessage(playerid, COLOR_GRIS, "Bengalas activadas");
		       	Bengala[vehicleid][0] = CreateDynamicObject(18728, 0, 0, 0, 0, 0, 0, 0, -1, -1, 200.0);
		       	AttachDynamicObjectToVehicle(Bengala[vehicleid][0], vehicleid, -1, -2, -2, 0, 0, 0);
		       	Bengala[vehicleid][1] = CreateDynamicObject(18728, 0, 0, 0, 0, 0, 0, 0, -1, -1, 200.0);
		       	AttachDynamicObjectToVehicle(Bengala[vehicleid][1], vehicleid, 1, -2, -2, 0, 0, 0);
			}
			else
   			{
			    Bengalas[vehicleid] = 0;
		  		SendClientMessage(playerid, COLOR_GRIS, "Bengalas desactivadas");
		  		DestroyDynamicObject(Bengala[vehicleid][0]);
		  		DestroyDynamicObject(Bengala[vehicleid][1]);
		  		return 1;
			}
		}
	}
	return 1;
}
Reply
#3

Quote:
Originally Posted by rospar
Посмотреть сообщение
Every Vehicle need his own Variable , in this Code you have just one so the Object will be removed if you use the CMD
with other Vehicles.
Sample:
Код:
new Bengala[MAX_VEHICLES][2];// Defines this Global

CMD:bengala(playerid, params[])
{
    new playerState = GetPlayerState(playerid);
	new vehicleid = GetPlayerVehicleID(playerid);
	if(Informacion[playerid][VipD] == 0) return SendClientMessage(playerid, COLOR_GRIS, "No Autorizado.");
	if(playerState != PLAYER_STATE_DRIVER || !IsPlayerInAnyVehicle(playerid)) return  SendClientMessage(playerid, COLOR_GRIS, "No estas en un vehiculo o no eres el conductor.");
	{
		if(IsPlayerConnected(playerid))
		{
		    if(Bengalas[vehicleid] == 0)
		   	{
		    	Bengalas[vehicleid] = 1;
				SendClientMessage(playerid, COLOR_GRIS, "Bengalas activadas");
		       	Bengala[vehicleid][0] = CreateDynamicObject(18728, 0, 0, 0, 0, 0, 0, 0, -1, -1, 200.0);
		       	AttachDynamicObjectToVehicle(Bengala[vehicleid][0], vehicleid, -1, -2, -2, 0, 0, 0);
		       	Bengala[vehicleid][1] = CreateDynamicObject(18728, 0, 0, 0, 0, 0, 0, 0, -1, -1, 200.0);
		       	AttachDynamicObjectToVehicle(Bengala[vehicleid][1], vehicleid, 1, -2, -2, 0, 0, 0);
			}
			else
   			{
			    Bengalas[vehicleid] = 0;
		  		SendClientMessage(playerid, COLOR_GRIS, "Bengalas desactivadas");
		  		DestroyDynamicObject(Bengala[vehicleid][0]);
		  		DestroyDynamicObject(Bengala[vehicleid][1]);
		  		return 1;
			}
		}
	}
	return 1;
}
Thanks
I know the 2D arrays, But not the uses...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)