need help with /lock and unlock
#1

Код:
    if (strcmp(cmdtext, "/lock", true)==0)
	{
		if(PlayerInfo[playerid][Kidnap] == 1) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You've been kidnapped and cannot leave in this manner! ");
		if(PlayerInfo[playerid][Tazed] == 1) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You cannot use this action at the moment.");
		if(PlayerInfo[playerid][Tackle] == 1) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You cannot use this action at the moment.");
		if(PlayerInfo[playerid][Frozen] == 1) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You cannot use this action at the moment.");
		if(PlayerInfo[playerid][Tied] == 1) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You cannot use this action at the moment.");
		if(PlayerInfo[playerid][Leadby] != -255) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You cannot use this action at the moment.");

	    new PlayerVehicle;
		if(GetPlayerState(playerid) == 1)
		{
			PlayerVehicle = GetClosestCar(playerid);
		}
		else
		{
		    PlayerVehicle = GetPlayerVehicleID(playerid);
		}

		if(PlayerVehicle >= house0 && PlayerVehicle <= house194) //check car id
		{
			new playername[MAX_PLAYER_NAME], str[128];
	    	GetPlayerName(playerid, playername, 24);
			format(str, sizeof(str), "/Houses/Users/%s", udb_encode(playername));
			new houseid;
			houseid = (dini_Int(str, "Houseid"));

			new housecar,housestr[128];
			housecar = eVehInfo[PlayerVehicle][HID];
			format(housestr,sizeof(housestr),"Houses/houseid%d",housecar);

			if(houseid == housecar)
			{
				new engine,lights,alarm,doors,bonnet,boot,objective;
	            GetVehicleParamsEx(PlayerVehicle,engine,lights,alarm,doors,bonnet,boot,objective);
	            SetVehicleParamsEx(PlayerVehicle,engine,lights,alarm,1,bonnet,boot,objective);

				SendClientMessage(playerid, COLOR_GREEN, "{5c99ff}[Info:] {dfebff} Vehicle locked!");

				new Float:pX, Float:pY, Float:pZ;
				GetPlayerPos(playerid,pX,pY,pZ);
				PlayerPlaySound(playerid,1057,pX,pY,pZ);
				for(new l=0; l<MAX_PLAYERS; l++){
					if(IsPlayerConnected(l)){
						if(GetDistanceBetweenPlayers(playerid,l) <= 20 && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(l))){
						    new stringme[128];
							new sexverb[256];
							if(PlayerInfo[playerid][pSex] == 1) { sexverb = "his"; }
							else if(PlayerInfo[playerid][pSex] == 2) { sexverb = "her"; }
							else { sexverb = "their"; }
							format(stringme,sizeof(stringme),"* %s locks %s car's doors. *",getpName(playerid),sexverb);
	   						SendClientMessage(l,COLOR_CYAN,stringme);
				    	}
			   		}
				}
				return 1;
Код:
 if (strcmp(cmdtext, "/unlock", true)==0)
	{
		if(PlayerInfo[playerid][Kidnap] == 1) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You've been kidnapped and cannot leave in this manner! ");
		if(PlayerInfo[playerid][Tazed] == 1) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You cannot use this action at the moment.");
		if(PlayerInfo[playerid][Tackle] == 1) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You cannot use this action at the moment.");
		if(PlayerInfo[playerid][Frozen] == 1) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You cannot use this action at the moment.");
		if(PlayerInfo[playerid][Tied] == 1) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You cannot use this action at the moment.");
		if(PlayerInfo[playerid][Leadby] != -255) return SendClientMessage(playerid, c_r, "{5c99ff}[Info:] {dfebff} You cannot use this action at the moment.");

	    new PlayerVehicle;
		if(GetPlayerState(playerid) == 1)
		{
			PlayerVehicle = GetClosestCar(playerid);
		}
		else
		{
		    PlayerVehicle = GetPlayerVehicleID(playerid);
		}

		if(PlayerVehicle >= house0 && PlayerVehicle <= house194) //check car id
		{
			new playername[MAX_PLAYER_NAME], str[128];
	    	GetPlayerName(playerid, playername, 24);
			format(str, sizeof(str), "/Houses/Users/%s", udb_encode(playername));
			new houseid;
			houseid = (dini_Int(str, "Houseid"));

			new housecar,housestr[128];
			housecar = eVehInfo[PlayerVehicle][HID];
			format(housestr,sizeof(housestr),"Houses/houseid%d",housecar);

			if(houseid == housecar)
			{
				new engine,lights,alarm,doors,bonnet,boot,objective;
	            GetVehicleParamsEx(PlayerVehicle,engine,lights,alarm,doors,bonnet,boot,objective);
	            SetVehicleParamsEx(PlayerVehicle,engine,lights,alarm,0,bonnet,boot,objective);

				SendClientMessage(playerid, COLOR_GREEN, "{5c99ff}[Info:] {dfebff} Vehicle unlocked!");

				new Float:pX, Float:pY, Float:pZ;
				GetPlayerPos(playerid,pX,pY,pZ);
				PlayerPlaySound(playerid,1057,pX,pY,pZ);
				for(new l=0; l<MAX_PLAYERS; l++){
					if(IsPlayerConnected(l)){
						if(GetDistanceBetweenPlayers(playerid,l) <= 20 && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(l))){
						    new stringme[128];
							new sexverb[256];
							if(PlayerInfo[playerid][pSex] == 1) { sexverb = "his"; }
							else if(PlayerInfo[playerid][pSex] == 2) { sexverb = "her"; }
							else { sexverb = "their"; }
							format(stringme,sizeof(stringme),"* %s unlocks %s car's doors. *",getpName(playerid),sexverb);
	   						SendClientMessage(l,COLOR_CYAN,stringme);
				    	}
			   		}
				}
				return 1;
This is my current lock and unlock system. i dont get any errors when i compile. i dont know why it doesnt work to lock house cars it works to lock faction cars if you belong to the faction but doesnt work on the ones player buy for there houses
Reply


Messages In This Thread
need help with /lock and unlock - by Chris iceman - 13.06.2012, 06:26

Forum Jump:


Users browsing this thread: 1 Guest(s)