SA-MP Forums Archive
Same Objects Diferent ID help - 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: Same Objects Diferent ID help (/showthread.php?tid=520942)



Same Objects Diferent ID help - FullCircle - 20.06.2014

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


AW: Same Objects Diferent ID help - rospar - 21.06.2014

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;
}



Respuesta: AW: Same Objects Diferent ID help - FullCircle - 21.06.2014

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