/lock un /unlock kommandas

Ja kas neizprotams.

Moderator: Moderātori

Post Reply
User avatar
Tektro
Jauniņais
Jauniņais
Posts: 34
Joined: 23 Sep 2012, 12:40

/lock un /unlock kommandas

Post by Tektro » 30 Sep 2012, 12:51

Kaa var sitaadam

Code: Select all

if (strcmp(cmdtext, "/lock", true)==0)
{
	if(IsPlayerInAnyVehicle(playerid))
	{
		new State=GetPlayerState(playerid);
		if(State!=PLAYER_STATE_DRIVER)
		{
			SendClientMessage(playerid,0xFF004040,"Tu durvis vari aizsleegt tikai tad kad esi pie stuures.");
			return 1;
		}
		new i;
		for(i=0;i<MAX_PLAYERS;i++)
		{
			if(i != playerid)
			{
				SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
			}
		}
		SendClientMessage(playerid, 0x33AA33AA, "Transports Aizsleegts!");
		new Float:pX, Float:pY, Float:pZ;
		GetPlayerPos(playerid,pX,pY,pZ);
		PlayerPlaySound(playerid,1056,pX,pY,pZ);
	}
	else
	{
	SendClientMessage(playerid, 0xFF004040, "Tu neatrodies nevienaa trasportaa!");
	}
	return 1;
}
	if (strcmp(cmdtext, "/unlock", true)==0)
{
	if(IsPlayerInAnyVehicle(playerid))
	{
		new State=GetPlayerState(playerid);
		if(State!=PLAYER_STATE_DRIVER)
		{
			SendClientMessage(playerid,0xFF004040,"Tu so trasporta liidzekli vari atsleegt tikad tad kad esi pie stuures!");
			return 1;
		}
		new i;
		for(i=0;i<MAX_PLAYERS;i++)
		{
			SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
		}
		SendClientMessage(playerid, 0x33AA33AA, "Transports aizsleegts!");
		new Float:pX, Float:pY, Float:pZ;
		GetPlayerPos(playerid,pX,pY,pZ);
		PlayerPlaySound(playerid,1057,pX,pY,pZ);
	}
	else
	{
	SendClientMessage(playerid, 0xFF004040, "Tu neatrodies nevienaa transporta liidzeklii !");
	}
	return 1;
}
	return 0;
}
uzlikt taa lai vareetu aizsleegt tikai vienu masiinu!

User avatar
[NF]Magnifico
Censoņa
Censoņa
Posts: 245
Joined: 09 Oct 2011, 02:17
Location: Cēsis
Contact:

Re: /lock un /unlock kommandas

Post by [NF]Magnifico » 30 Sep 2012, 13:18

Izveido globālo mainīgo, katram spēlētajam savu.
Zem OnGameModeInit ieliec mainīgo piemēram uz 0
Kad spēlētājs aizslēdz mašīnu, tad pārbauda vai mainīgais ir 0, ja ir, tad aizslēdz mašīnu, ja ir piemēram 1, tad kaut ko citu izdara, piemēram uzraksta ka nevar aizslēgt vairāk. Aizslēdzot mašīnu vienkārši vajag uzstādīt mainīgo uz 1.


Nekas pārāk sarežģīts ko iesācējs nevarētu izdomāt. Tagad tikai Tev pašam jāizdomā kā šo izveidot.

User avatar
Tektro
Jauniņais
Jauniņais
Posts: 34
Joined: 23 Sep 2012, 12:40

Re: /lock un /unlock kommandas

Post by Tektro » 30 Sep 2012, 13:30

neko nesapraatu zinu ka tikai jaliek piem new lock un viss
nezinu kas taalaak jaadara

User avatar
Tektro
Jauniņais
Jauniņais
Posts: 34
Joined: 23 Sep 2012, 12:40

Re: /lock un /unlock kommandas

Post by Tektro » 07 Oct 2012, 00:08

Es apmeeram sapratu vai no sii ir kkas pareidzi?

Code: Select all

new lockedCar[MAX_VEHICLES];
new vehc[MAX_PLAYERS];
if	(strcmp(cmdtext, "/lock", true)==0)
        {
        if	(IsPlayerInAnyVehicle(playerid))
        	{
            new State=GetPlayerState(playerid);
            if  (State!=PLAYER_STATE_DRIVER)
                {
                SendClientMessage(playerid,0xFFFF00AA,"You can only lock the doors as the driver.");
                return 1;
                }
                vehc[GetPlayerVehicleID(playerid)]=0;
                new d;
                for (d=0;d<MAX_PLAYERS;d++)
                {
                if(d == 1)
                {
                SendClientMessage(playerid,0xFFFF00AA,"Tu vari aizsleegt tikai vienu transportaliidzekli.");
                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),d, 0, 0);
	            }
                return 1;
	            }
            lockedCar[GetPlayerVehicleID(playerid)]=1;
            new i;
	        for (i=0;i<MAX_PLAYERS;i++)
	            {
	                if(i != playerid)
	                {
	                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
	                }
	            }
	        SendClientMessage(playerid, 0xFFFF00AA, "Vehicle locked!");
	        new Float:pX, Float:pY, Float:pZ;
	        GetPlayerPos(playerid,pX,pY,pZ);
	        PlayerPlaySound(playerid,1056,pX,pY,pZ);
	        }
        else
            {
            SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
            }
        return 1;
        }

User avatar
[NF]Magnifico
Censoņa
Censoņa
Posts: 245
Joined: 09 Oct 2011, 02:17
Location: Cēsis
Contact:

Re: /lock un /unlock kommandas

Post by [NF]Magnifico » 07 Oct 2012, 19:22

Tektro wrote:Es apmeeram sapratu vai no sii ir kkas pareidzi?
Kaut kas ir pareizi.

Post Reply